Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsNativeAppSupportWin.cpp File Reference
#include "nsNativeAppSupportBase.h"
#include "nsNativeAppSupportWin.h"
#include "nsAppRunner.h"
#include "nsXULAppAPI.h"
#include "nsString.h"
#include "nsIBrowserDOMWindow.h"
#include "nsICommandLineRunner.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIDOMWindow.h"
#include "nsIDOMChromeWindow.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsISupportsArray.h"
#include "nsIWindowWatcher.h"
#include "nsIDOMWindowInternal.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIBaseWindow.h"
#include "nsIWidget.h"
#include "nsIAppShellService.h"
#include "nsIProfileInternal.h"
#include "nsIXULWindow.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIPromptService.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsIDOMLocation.h"
#include "nsIJSContextStack.h"
#include "nsIWebNavigation.h"
#include "nsIWindowMediator.h"
#include "nsNativeCharsetUtils.h"
#include <windows.h>
#include <shellapi.h>
#include <ddeml.h>
#include <stdlib.h>
#include <stdio.h>
#include <io.h>
#include <direct.h>
#include <fcntl.h>

Go to the source code of this file.

Classes

struct  Mutex
class  nsNativeAppSupportWin
struct  MessageWindow
class  SafeJSContext

Defines

#define MOZ_DDE_APPLICATION   "Mozilla"
#define MOZ_STARTUP_MUTEX_NAME   "StartupMutex"
#define MOZ_DDE_START_TIMEOUT   30000
#define MOZ_DDE_STOP_TIMEOUT   15000
#define MOZ_DDE_EXEC_TIMEOUT   15000

Functions

static HWND hwndForDOMWindow (nsISupports *)
static nsresult GetMostRecentWindow (const PRUnichar *aType, nsIDOMWindowInternal **aWindow)
static void activateWindow (nsIDOMWindowInternal *win)
nsresult NS_CreateNativeAppSupport (nsINativeAppSupport **aResult)
 Create the nativeappsupport implementation.
static PRBool isDefaultBrowser ()
static nsCString hszValue (DWORD, HSZ)
static void escapeQuotes (nsAString &aString)
static PRInt32 advanceToEndOfQuotedArg (const char *p, PRInt32 offset, PRInt32 len)

Variables

const char *const topicNames []
static nsCString uTypeDesc (UINT)
static const char sJSStackContractID [] = "@mozilla.org/js/xpc/ContextStack;1"

Define Documentation

#define MOZ_DDE_APPLICATION   "Mozilla"

Definition at line 465 of file nsNativeAppSupportWin.cpp.

Definition at line 469 of file nsNativeAppSupportWin.cpp.

Definition at line 467 of file nsNativeAppSupportWin.cpp.

Definition at line 468 of file nsNativeAppSupportWin.cpp.

#define MOZ_STARTUP_MUTEX_NAME   "StartupMutex"

Definition at line 466 of file nsNativeAppSupportWin.cpp.


Function Documentation

static void activateWindow ( nsIDOMWindowInternal win) [static]

Definition at line 109 of file nsNativeAppSupportWin.cpp.

                                            {
    // Try to get native window handle.
    HWND hwnd = hwndForDOMWindow( win );
    if ( hwnd ) {
        // Restore the window if it is minimized.
        if ( ::IsIconic( hwnd ) ) {
            ::ShowWindow( hwnd, SW_RESTORE );
        }
        // Use the OS call, if possible.
        ::SetForegroundWindow( hwnd );
    } else {
        // Use internal method.
        win->Focus();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRInt32 advanceToEndOfQuotedArg ( const char *  p,
PRInt32  offset,
PRInt32  len 
) [static]

Definition at line 1215 of file nsNativeAppSupportWin.cpp.

                                                                                     {
    // Check whether the current arg is quoted.
    if ( p[++offset] == '"' ) {
        // Advance past the closing quote.
        while ( offset < len && p[++offset] != '"' ) {
            // If the current character is a backslash, then the
            // next character can't be a *real* '"', so skip it.
            if ( p[offset] == '\\' ) {
                offset++;
            }
        }
    }
    return offset;
}

Here is the caller graph for this function:

static void escapeQuotes ( nsAString &  aString) [static]

Definition at line 935 of file nsNativeAppSupportWin.cpp.

                                               {
    PRInt32 offset = -1;
    while( 1 ) {
       // Find next '"'.
       offset = aString.FindChar( '"', ++offset );
       if ( offset == kNotFound ) {
           // No more quotes, exit.
           break;
       } else {
           // Insert back-slash ahead of the '"'.
           aString.Insert( PRUnichar('\\'), offset );
           // Increment offset because we just inserted a slash
           offset++;
       }
    }
    return;
}

Here is the caller graph for this function:

static nsresult GetMostRecentWindow ( const PRUnichar aType,
nsIDOMWindowInternal **  aWindow 
) [static]

Definition at line 95 of file nsNativeAppSupportWin.cpp.

                                                                            {
    nsresult rv;
    nsCOMPtr<nsIWindowMediator> med( do_GetService( NS_WINDOWMEDIATOR_CONTRACTID, &rv ) );
    if ( NS_FAILED( rv ) )
        return rv;

    if ( med )
        return med->GetMostRecentWindow( aType, aWindow );

    return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsCString hszValue ( DWORD  ,
HSZ   
) [static]

Definition at line 928 of file nsNativeAppSupportWin.cpp.

                                        {
    return nsCString( "?" );
}

Here is the caller graph for this function:

static HWND hwndForDOMWindow ( nsISupports *  window) [static]
static PRBool isDefaultBrowser ( ) [static]

Definition at line 735 of file nsNativeAppSupportWin.cpp.

{
#ifdef MOZ_PHOENIX
  nsCOMPtr<nsIShellService> shell(do_GetService("@mozilla.org/browser/shell-service;1"));
  PRBool isDefault;
  shell->IsDefaultBrowser(PR_FALSE, &isDefault);
  return isDefault;
#else
  return FALSE;
#endif
}

Here is the call graph for this function:

Create the nativeappsupport implementation.

Note:
XPCOMInit has not happened yet.

Definition at line 451 of file nsNativeAppSupportWin.cpp.

                                                           {
    nsNativeAppSupportWin *pNative = new nsNativeAppSupportWin;
    if (!pNative) return NS_ERROR_OUT_OF_MEMORY;

    // Check for dynamic console creation request.
    pNative->CheckConsole();

    *aResult = pNative;
    NS_ADDREF( *aResult );

    return NS_OK;
}

Here is the call graph for this function:


Variable Documentation

const char sJSStackContractID[] = "@mozilla.org/js/xpc/ContextStack;1" [static]

Definition at line 1514 of file nsNativeAppSupportWin.cpp.

Initial value:
 { "WWW_OpenURL",
                                    "WWW_Activate",
                                    "WWW_CancelProgress",
                                    "WWW_Version",
                                    "WWW_RegisterViewer",
                                    "WWW_UnRegisterViewer",
                                    "WWW_GetWindowInfo" }

Definition at line 472 of file nsNativeAppSupportWin.cpp.

Definition at line 925 of file nsNativeAppSupportWin.cpp.

                                   {
    return nsCString( "?" );
}