diff --git a/mozilla/xpfe/bootstrap/nsAppRunner.cpp b/mozilla/xpfe/bootstrap/nsAppRunner.cpp index 7ab94e1dfa5..d16d4da8073 100644 --- a/mozilla/xpfe/bootstrap/nsAppRunner.cpp +++ b/mozilla/xpfe/bootstrap/nsAppRunner.cpp @@ -793,8 +793,27 @@ static nsresult OpenBrowserWindow(PRInt32 height, PRInt32 width) static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs) -{ - nsresult rv; +{ + nsresult rv; + +#ifdef XP_WIN32 + // If starting up in server mode, then we do things differently. + nsCOMPtr nativeApp; + rv = GetNativeAppSupport(getter_AddRefs(nativeApp)); + if (NS_SUCCEEDED(rv)) { + PRBool isServerMode = PR_FALSE; + nativeApp->GetIsServerMode(&isServerMode); + if (isServerMode) { + nativeApp->StartServerMode(); + } + PRBool shouldShowUI = PR_TRUE; + nativeApp->GetShouldShowUI(&shouldShowUI); + if (!shouldShowUI) { + return NS_OK; + } + } +#endif + nsCOMPtr windowMediator(do_GetService(kWindowMediatorCID, &rv)); if (NS_FAILED(rv)) @@ -809,21 +828,6 @@ static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs) windowEnumerator->HasMoreElements(&more); if ( !more ) { - #ifdef XP_WIN32 - // If starting up in server mode, then we do things differently. - nsCOMPtr nativeApp; - rv = GetNativeAppSupport(getter_AddRefs(nativeApp)); - // Create special Nav window. - if (NS_SUCCEEDED(rv)) { - PRBool shouldShowUI = PR_TRUE; - nativeApp->GetShouldShowUI(&shouldShowUI); - if (!shouldShowUI) { - nativeApp->StartServerMode(); - return NS_OK; - } - } - #endif - // No window exists so lets create a browser one PRInt32 height = NS_SIZETOCONTENT; PRInt32 width = NS_SIZETOCONTENT; diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp index b0e742f0c0e..38fe41b4ee5 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp @@ -603,7 +603,29 @@ nsNativeAppSupportWin::CheckConsole() { // Ignore other args. break; } - } + } + // check if this is a restart of the browser after quiting from + // the servermoded browser instance. + if (!mServerMode ) { + HKEY key; + LONG result = ::RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_QUERY_VALUE, &key ); + if ( result == ERROR_SUCCESS ) { + BYTE regvalue[_MAX_PATH]; + DWORD type, len = sizeof(regvalue); + result = ::RegQueryValueEx( key, NS_QUICKLAUNCH_RUN_KEY, NULL, &type, regvalue, &len); + ::RegCloseKey( key ); + if ( result == ERROR_SUCCESS && len > 0 ) { + // Make sure the filename in the quicklaunch command matches us + char fileName[_MAX_PATH]; + int rv = ::GetModuleFileName( NULL, fileName, sizeof fileName ); + if (rv && !PL_strncasecmp(fileName, (const char *)regvalue, PR_MIN(len, strlen(fileName)))) { + mServerMode = PR_TRUE; + mShouldShowUI = PR_TRUE; + } + } + } + } + return; } @@ -919,19 +941,6 @@ nsNativeAppSupportWin::Start( PRBool *aResult ) { startupLock.Unlock(); - PRBool serverMode = PR_FALSE; - GetIsServerMode( &serverMode ); - if ( !serverMode ) { // okay, so it's not -turbo - HKEY key; - LONG result = ::RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_QUERY_VALUE, &key ); - if ( result == ERROR_SUCCESS ) { - result = ::RegQueryValueEx( key, NS_QUICKLAUNCH_RUN_KEY, NULL, NULL, NULL, NULL ); - ::RegCloseKey( key ); - if ( result == ERROR_SUCCESS ) - SetIsServerMode( PR_TRUE ); - } - } - return rv; } @@ -1896,6 +1905,15 @@ nsNativeAppSupportWin::StartServerMode() { // Turn on system tray icon. SetupSysTrayIcon(); + + if (mShouldShowUI) { + // We dont have to anything anymore. The native UI + // will create the window + return NS_OK; + } + + // Since native UI wont create any window, we create a hidden window + // so thing work alright. // Create some of the objects we'll need. nsCOMPtr ww(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); @@ -1919,24 +1937,24 @@ nsNativeAppSupportWin::StartServerMode() { // Put args into array. if ( NS_FAILED( argArray->AppendElement( arg1 ) ) || - NS_FAILED( argArray->AppendElement( arg2 ) ) ) { + NS_FAILED( argArray->AppendElement( arg2 ) ) ) { return NS_OK; } - + // Now open the window. nsCOMPtr newWindow; ww->OpenWindow( 0, - "chrome://navigator/content", - "_blank", - "chrome,dialog=no,toolbar=no", - argArray, - getter_AddRefs( newWindow ) ); - + "chrome://navigator/content", + "_blank", + "chrome,dialog=no,toolbar=no", + argArray, + getter_AddRefs( newWindow ) ); + if ( !newWindow ) { return NS_OK; } mInitialWindow = newWindow; - + // Hide this window by re-parenting it (to ensure it doesn't appear). ReParent( newWindow, (HWND)MessageWindow() );