diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index e8fb9b0660e5..1681312263e6 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -86,6 +86,8 @@ pref("browser.toolbars.showbutton.net2phone", true); pref("browser.toolbars.showbutton.print", true); pref("browser.toolbars.showbutton.search", true); +pref("browser.turbo.enabled", true); + pref("browser.helperApps.alwaysAsk.force", false); pref("browser.helperApps.neverAsk.saveToDisk", ""); pref("browser.helperApps.neverAsk.openFile", ""); diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index 6b2279b3de0f..6d2ecd9eba88 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -78,6 +78,7 @@ #include "nsXRemoteClientCID.h" #include "nsIXRemoteClient.h" #endif +#define TURBO_PREF "browser.turbo.enabled" #ifdef NS_TRACE_MALLOC #include "nsTraceMalloc.h" @@ -826,13 +827,13 @@ static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs) { // If starting up in server mode, then we do things differently. nsCOMPtr nativeApp; - PRBool serverMode; + PRBool serverMode = PR_FALSE; rv = GetNativeAppSupport(getter_AddRefs(nativeApp)); - if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(nativeApp->GetIsServerMode(&serverMode)) && serverMode) { - // Create special Nav window. - nativeApp->StartServerMode(); - return NS_OK; - } + // Create special Nav window. + if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(nativeApp->GetIsStartupServerMode(&serverMode)) && serverMode) { + nativeApp->StartServerMode(); + return NS_OK; + } // No window exists so lets create a browser one PRInt32 height = NS_SIZETOCONTENT; @@ -1268,10 +1269,22 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) // if the profile manager ever switches to using nsIDOMWindowInternal stuff, this might have to change appShell->CreateHiddenWindow(); - // This will go away once Components are handling there own commandlines - // if we have no command line arguments, we need to heed the - // "general.startup.*" prefs - // if we had no command line arguments, argc == 1. + nsCOMPtr nativeApps; + rv = GetNativeAppSupport(getter_AddRefs(nativeApps)); + if (NS_SUCCEEDED(rv)) { + nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID, &rv)); + if (NS_SUCCEEDED(rv) && prefs) { + PRBool serverMode = PR_FALSE; + prefs->GetBoolPref(TURBO_PREF, &serverMode); + nativeApps->SetIsServerMode(serverMode); + } + } + + // This will go away once Components are handling there own commandlines + // if we have no command line arguments, we need to heed the + // "general.startup.*" prefs + // if we had no command line arguments, argc == 1. + #ifdef XP_MAC // if we do no command line args on the mac, it says argc is 0, and not 1 rv = DoCommandLines( cmdLineArgs, ((argc == 1) || (argc == 0)) ); diff --git a/xpfe/bootstrap/nsNativeAppSupportBase.cpp b/xpfe/bootstrap/nsNativeAppSupportBase.cpp index f338cf751e11..f295e59e271b 100644 --- a/xpfe/bootstrap/nsNativeAppSupportBase.cpp +++ b/xpfe/bootstrap/nsNativeAppSupportBase.cpp @@ -26,6 +26,7 @@ nsNativeAppSupportBase::nsNativeAppSupportBase() : mRefCnt( 0 ), mSplash( 0 ), mServerMode( PR_FALSE ), + mStartupServerMode( PR_FALSE ), mNeedsProfileUI( PR_FALSE ) { } @@ -93,6 +94,13 @@ nsNativeAppSupportBase::GetIsServerMode(PRBool *aIsServerMode) { return NS_OK; } +NS_IMETHODIMP +nsNativeAppSupportBase::GetIsStartupServerMode(PRBool *aIsStartupServerMode) { + NS_ENSURE_ARG( aIsStartupServerMode ); + *aIsStartupServerMode = mStartupServerMode; + return NS_OK; +} + NS_IMETHODIMP nsNativeAppSupportBase::GetNeedsProfileUI(PRBool *aNeedsProfileUI) { NS_ENSURE_ARG_POINTER(aNeedsProfileUI); @@ -158,3 +166,4 @@ nsNativeAppSupportBase::QueryInterface( const nsIID &iid, void**p ) { return rv; } + diff --git a/xpfe/bootstrap/nsNativeAppSupportBase.h b/xpfe/bootstrap/nsNativeAppSupportBase.h index bd05c7ac7fd9..b4bf1b7a422f 100644 --- a/xpfe/bootstrap/nsNativeAppSupportBase.h +++ b/xpfe/bootstrap/nsNativeAppSupportBase.h @@ -53,6 +53,7 @@ public: nsrefcnt mRefCnt; nsCOMPtr mSplash; PRBool mServerMode; + PRBool mStartupServerMode; PRBool mNeedsProfileUI; }; // class nsSplashScreenWin diff --git a/xpfe/bootstrap/nsNativeAppSupportWin.cpp b/xpfe/bootstrap/nsNativeAppSupportWin.cpp index fbe77a59f1e1..74b944938a84 100644 --- a/xpfe/bootstrap/nsNativeAppSupportWin.cpp +++ b/xpfe/bootstrap/nsNativeAppSupportWin.cpp @@ -585,7 +585,7 @@ nsNativeAppSupportWin::CheckConsole() { || strcmp( "/server", __argv[i] ) == 0 ) { // Start in server mode (and suppress splash screen). - SetIsServerMode( PR_TRUE ); + mStartupServerMode = PR_TRUE; __argv[i] = "-nosplash"; // Bit of a hack, but it works! // Ignore other args. break; @@ -1730,9 +1730,7 @@ nsNativeAppSupportWin::SetupSysTrayIcon() { delete [] exitACPText ; } } - else { - ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_QUIT, exitText.get() ); - } + } // Add the tray icon. @@ -1758,6 +1756,7 @@ nsNativeAppSupportWin::RemoveSysTrayIcon() { // - Pass magic arg to cause window to close in onload handler. NS_IMETHODIMP nsNativeAppSupportWin::StartServerMode() { + // Turn on system tray icon. SetupSysTrayIcon(); @@ -1812,6 +1811,9 @@ nsNativeAppSupportWin::SetIsServerMode( PRBool isServerMode ) { if ( mServerMode && !isServerMode ) { RemoveSysTrayIcon(); } + else if ( !mServerMode && isServerMode) { + SetupSysTrayIcon(); + } return nsNativeAppSupportBase::SetIsServerMode( isServerMode ); } diff --git a/xpfe/components/prefwindow/resources/content/pref-advanced.xul b/xpfe/components/prefwindow/resources/content/pref-advanced.xul index 446ce60cc904..ef21a63b088c 100644 --- a/xpfe/components/prefwindow/resources/content/pref-advanced.xul +++ b/xpfe/components/prefwindow/resources/content/pref-advanced.xul @@ -75,37 +75,12 @@ function turboCheck() { - var aframe = document.getElementById("perfSettings"); - var abox = document.getElementById("perfLabel"); - var alabel = document.getElementById("perfBox"); - var acheckbox = document.getElementById("enableTurbo"); - if ( navigator.platform != "Win32" ) { - aframe.setAttribute( "style", "visibility: hidden" ); - return; - } - else - aframe.setAttribute( "style", "visibility: visible" ); - - /* find out what the setting should be and reflect it in the UI */ - - try { - hooks = Components.classes["@mozilla.org/winhooks;1"]; - if ( hooks ) { - hooks = hooks.getService(Components.interfaces.nsIWindowsHooks); - } - if ( hooks ) { - var isEnabled = hooks.isStartupTurboEnabled(); - if ( isEnabled == true ) { - acheckbox.setAttribute( "checked", true ); - } - else { - acheckbox.setAttribute( "checked", false ); - } - } - } catch( ex ) { - } - - parent.hPrefWindow.registerOKCallbackFunc( saveTurboSetting ); + var frame = document.getElementById("perfSettings"); + if (navigator.platform != "Win32") { + frame.setAttribute("hidden", "true"); + return; + } + parent.hPrefWindow.registerOKCallbackFunc( saveTurboSetting ); } /* @@ -125,25 +100,31 @@ function saveTurboSetting() { - if ( navigator.platform != "Win32" ) { + if ( navigator.platform != "Win32" ) return; - } - var acheckbox = document.getElementById("enableTurbo"); + var acheckbox = document.getElementById("enableTurbo"); try { - hooks = Components.classes["@mozilla.org/winhooks;1"]; - if ( hooks ) { - hooks = hooks.getService(Components.interfaces.nsIWindowsHooks); - } - if ( hooks ) { - var isEnabled = acheckbox.checked; - if ( isEnabled == true ) { - hooks.startupTurboEnable(); - } - else { - hooks.startupTurboDisable(); - } - } + hooks = Components.classes["@mozilla.org/winhooks;1"]; + if ( hooks ) + hooks = hooks.getService(Components.interfaces.nsIWindowsHooks); + if ( hooks ) { + var isEnabled = acheckbox.checked; + if ( isEnabled == true ) + hooks.startupTurboEnable(); + else + hooks.startupTurboDisable(); + var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService(); + appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService ); + var nativeAppSupport = null; + try { + nativeAppSupport = appShell.nativeAppSupport; + } + catch ( ex ) { + } + if (nativeAppSupport) + nativeAppSupport.isServerMode = isEnabled; + } } catch( ex ) { } } @@ -184,7 +165,8 @@