Enabling and disabling turbo should not require a restart (89504). Also fixes 85437, 81715, 91221, 91350, 92292. r=ccarlen sr=ben

This commit is contained in:
blakeross%telocity.com 2001-08-16 03:21:40 +00:00
Родитель 0f3e3a87b9
Коммит 6a13fe367b
6 изменённых файлов: 71 добавлений и 62 удалений

Просмотреть файл

@ -86,6 +86,8 @@ pref("browser.toolbars.showbutton.net2phone", true);
pref("browser.toolbars.showbutton.print", true); pref("browser.toolbars.showbutton.print", true);
pref("browser.toolbars.showbutton.search", true); pref("browser.toolbars.showbutton.search", true);
pref("browser.turbo.enabled", true);
pref("browser.helperApps.alwaysAsk.force", false); pref("browser.helperApps.alwaysAsk.force", false);
pref("browser.helperApps.neverAsk.saveToDisk", ""); pref("browser.helperApps.neverAsk.saveToDisk", "");
pref("browser.helperApps.neverAsk.openFile", ""); pref("browser.helperApps.neverAsk.openFile", "");

Просмотреть файл

@ -78,6 +78,7 @@
#include "nsXRemoteClientCID.h" #include "nsXRemoteClientCID.h"
#include "nsIXRemoteClient.h" #include "nsIXRemoteClient.h"
#endif #endif
#define TURBO_PREF "browser.turbo.enabled"
#ifdef NS_TRACE_MALLOC #ifdef NS_TRACE_MALLOC
#include "nsTraceMalloc.h" #include "nsTraceMalloc.h"
@ -826,13 +827,13 @@ static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs)
{ {
// If starting up in server mode, then we do things differently. // If starting up in server mode, then we do things differently.
nsCOMPtr<nsINativeAppSupport> nativeApp; nsCOMPtr<nsINativeAppSupport> nativeApp;
PRBool serverMode; PRBool serverMode = PR_FALSE;
rv = GetNativeAppSupport(getter_AddRefs(nativeApp)); rv = GetNativeAppSupport(getter_AddRefs(nativeApp));
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(nativeApp->GetIsServerMode(&serverMode)) && serverMode) { // Create special Nav window.
// Create special Nav window. if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(nativeApp->GetIsStartupServerMode(&serverMode)) && serverMode) {
nativeApp->StartServerMode(); nativeApp->StartServerMode();
return NS_OK; return NS_OK;
} }
// No window exists so lets create a browser one // No window exists so lets create a browser one
PRInt32 height = NS_SIZETOCONTENT; 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 // if the profile manager ever switches to using nsIDOMWindowInternal stuff, this might have to change
appShell->CreateHiddenWindow(); appShell->CreateHiddenWindow();
// This will go away once Components are handling there own commandlines nsCOMPtr<nsINativeAppSupport> nativeApps;
// if we have no command line arguments, we need to heed the rv = GetNativeAppSupport(getter_AddRefs(nativeApps));
// "general.startup.*" prefs if (NS_SUCCEEDED(rv)) {
// if we had no command line arguments, argc == 1. nsCOMPtr<nsIPref> 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 #ifdef XP_MAC
// if we do no command line args on the mac, it says argc is 0, and not 1 // 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)) ); rv = DoCommandLines( cmdLineArgs, ((argc == 1) || (argc == 0)) );

Просмотреть файл

@ -26,6 +26,7 @@ nsNativeAppSupportBase::nsNativeAppSupportBase()
: mRefCnt( 0 ), : mRefCnt( 0 ),
mSplash( 0 ), mSplash( 0 ),
mServerMode( PR_FALSE ), mServerMode( PR_FALSE ),
mStartupServerMode( PR_FALSE ),
mNeedsProfileUI( PR_FALSE ) { mNeedsProfileUI( PR_FALSE ) {
} }
@ -93,6 +94,13 @@ nsNativeAppSupportBase::GetIsServerMode(PRBool *aIsServerMode) {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsNativeAppSupportBase::GetIsStartupServerMode(PRBool *aIsStartupServerMode) {
NS_ENSURE_ARG( aIsStartupServerMode );
*aIsStartupServerMode = mStartupServerMode;
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsNativeAppSupportBase::GetNeedsProfileUI(PRBool *aNeedsProfileUI) { nsNativeAppSupportBase::GetNeedsProfileUI(PRBool *aNeedsProfileUI) {
NS_ENSURE_ARG_POINTER(aNeedsProfileUI); NS_ENSURE_ARG_POINTER(aNeedsProfileUI);
@ -158,3 +166,4 @@ nsNativeAppSupportBase::QueryInterface( const nsIID &iid, void**p ) {
return rv; return rv;
} }

Просмотреть файл

@ -53,6 +53,7 @@ public:
nsrefcnt mRefCnt; nsrefcnt mRefCnt;
nsCOMPtr<nsISplashScreen> mSplash; nsCOMPtr<nsISplashScreen> mSplash;
PRBool mServerMode; PRBool mServerMode;
PRBool mStartupServerMode;
PRBool mNeedsProfileUI; PRBool mNeedsProfileUI;
}; // class nsSplashScreenWin }; // class nsSplashScreenWin

Просмотреть файл

@ -585,7 +585,7 @@ nsNativeAppSupportWin::CheckConsole() {
|| ||
strcmp( "/server", __argv[i] ) == 0 ) { strcmp( "/server", __argv[i] ) == 0 ) {
// Start in server mode (and suppress splash screen). // Start in server mode (and suppress splash screen).
SetIsServerMode( PR_TRUE ); mStartupServerMode = PR_TRUE;
__argv[i] = "-nosplash"; // Bit of a hack, but it works! __argv[i] = "-nosplash"; // Bit of a hack, but it works!
// Ignore other args. // Ignore other args.
break; break;
@ -1730,9 +1730,7 @@ nsNativeAppSupportWin::SetupSysTrayIcon() {
delete [] exitACPText ; delete [] exitACPText ;
} }
} }
else {
::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_QUIT, exitText.get() );
}
} }
// Add the tray icon. // Add the tray icon.
@ -1758,6 +1756,7 @@ nsNativeAppSupportWin::RemoveSysTrayIcon() {
// - Pass magic arg to cause window to close in onload handler. // - Pass magic arg to cause window to close in onload handler.
NS_IMETHODIMP NS_IMETHODIMP
nsNativeAppSupportWin::StartServerMode() { nsNativeAppSupportWin::StartServerMode() {
// Turn on system tray icon. // Turn on system tray icon.
SetupSysTrayIcon(); SetupSysTrayIcon();
@ -1812,6 +1811,9 @@ nsNativeAppSupportWin::SetIsServerMode( PRBool isServerMode ) {
if ( mServerMode && !isServerMode ) { if ( mServerMode && !isServerMode ) {
RemoveSysTrayIcon(); RemoveSysTrayIcon();
} }
else if ( !mServerMode && isServerMode) {
SetupSysTrayIcon();
}
return nsNativeAppSupportBase::SetIsServerMode( isServerMode ); return nsNativeAppSupportBase::SetIsServerMode( isServerMode );
} }

Просмотреть файл

@ -75,37 +75,12 @@
function turboCheck() function turboCheck()
{ {
var aframe = document.getElementById("perfSettings"); var frame = document.getElementById("perfSettings");
var abox = document.getElementById("perfLabel"); if (navigator.platform != "Win32") {
var alabel = document.getElementById("perfBox"); frame.setAttribute("hidden", "true");
var acheckbox = document.getElementById("enableTurbo"); return;
if ( navigator.platform != "Win32" ) { }
aframe.setAttribute( "style", "visibility: hidden" ); parent.hPrefWindow.registerOKCallbackFunc( saveTurboSetting );
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 );
} }
/* /*
@ -125,25 +100,31 @@
function saveTurboSetting() function saveTurboSetting()
{ {
if ( navigator.platform != "Win32" ) { if ( navigator.platform != "Win32" )
return; return;
}
var acheckbox = document.getElementById("enableTurbo"); var acheckbox = document.getElementById("enableTurbo");
try { try {
hooks = Components.classes["@mozilla.org/winhooks;1"]; hooks = Components.classes["@mozilla.org/winhooks;1"];
if ( hooks ) { if ( hooks )
hooks = hooks.getService(Components.interfaces.nsIWindowsHooks); hooks = hooks.getService(Components.interfaces.nsIWindowsHooks);
} if ( hooks ) {
if ( hooks ) { var isEnabled = acheckbox.checked;
var isEnabled = acheckbox.checked; if ( isEnabled == true )
if ( isEnabled == true ) { hooks.startupTurboEnable();
hooks.startupTurboEnable(); else
} hooks.startupTurboDisable();
else { var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService();
hooks.startupTurboDisable(); appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService );
} var nativeAppSupport = null;
} try {
nativeAppSupport = appShell.nativeAppSupport;
}
catch ( ex ) {
}
if (nativeAppSupport)
nativeAppSupport.isServerMode = isEnabled;
}
} catch( ex ) { } catch( ex ) {
} }
} }
@ -184,7 +165,8 @@
<groupbox orient="vertical" id="perfSettings"> <groupbox orient="vertical" id="perfSettings">
<label id="perfLabel" value="&perfTitle.label;"/> <label id="perfLabel" value="&perfTitle.label;"/>
<vbox id="perfBox" align="start"> <vbox id="perfBox" align="start">
<checkbox id="enableTurbo" label="&enableTurbo.label;" accesskey="&enableTurboCheck.accesskey;"/> <checkbox id="enableTurbo" label="&enableTurbo.label;" accesskey="&enableTurboCheck.accesskey;"
pref="true" preftype="bool" prefstring="browser.turbo.enabled" prefattribute="checked"/>
</vbox> </vbox>
</groupbox> </groupbox>