From 58210fe3905cfec985c6f8bf0875d81095e9405f Mon Sep 17 00:00:00 2001 From: "blakeross%telocity.com" Date: Mon, 10 Sep 2001 23:48:09 +0000 Subject: [PATCH] Turbo landing: - Turbo mode should run Mozilla from registry (88844). r=ccarlen sr=ben - Systray menu for turbo should include components (89532). r=syd sr=ben - Installer checkbox needs to turn turbo on properly (96936, 97338). r=ccarlen sr=ben - Add 'Disable Quick Launch' menuitem to turbo systray icon (98770). r=syd sr=ben - Need confirmation dialog when 'Disable Quick Launch' is selected (98805). r=syd sr=ben - Show dialog when last window is closed in turbo mode (89166). r=ccarlen sr=ben and some cleanup. --- .../locale/en-US/mailTurboMenu.properties | 0 mailnews/jar.mn | 1 + themes/classic/navigator/win/jar.mn | 4 - .../classic/navigator/win/turbo-systray.gif | 0 themes/classic/navigator/win/turbo.css | 4 + themes/modern/global/menulist.css | 5 +- themes/modern/jar.mn | 2 + themes/modern/navigator/turbo-systray.gif | 0 themes/modern/navigator/turbo.css | 0 xpfe/appshell/public/nsINativeAppSupport.idl | 8 +- xpfe/appshell/src/nsAppShellService.cpp | 9 +- xpfe/bootstrap/nsAppRunner.cpp | 182 +++------- xpfe/bootstrap/nsNativeAppSupportBase.cpp | 13 +- xpfe/bootstrap/nsNativeAppSupportBase.h | 3 +- xpfe/bootstrap/nsNativeAppSupportOS2.cpp | 76 ++-- xpfe/bootstrap/nsNativeAppSupportWin.cpp | 340 +++++++++++++----- xpfe/browser/jar.mn | 3 + .../browser/resources/content/turboDialog.xul | 94 +++++ .../resources/locale/en-US/turboDialog.dtd | 4 + .../locale/en-US/turboMenu.properties | 6 + .../resources/content/pref-advanced.xul | 142 ++++---- .../startup/public/nsINativeAppSupport.idl | 8 +- xpfe/components/winhooks/nsIWindowsHooks.idl | 38 +- xpfe/components/winhooks/nsWindowsHooks.cpp | 226 +++--------- 24 files changed, 620 insertions(+), 548 deletions(-) create mode 100644 mailnews/base/resources/locale/en-US/mailTurboMenu.properties create mode 100644 themes/classic/navigator/win/turbo-systray.gif create mode 100644 themes/classic/navigator/win/turbo.css create mode 100644 themes/modern/navigator/turbo-systray.gif create mode 100644 themes/modern/navigator/turbo.css create mode 100644 xpfe/browser/resources/content/turboDialog.xul create mode 100644 xpfe/browser/resources/locale/en-US/turboDialog.dtd create mode 100644 xpfe/browser/resources/locale/en-US/turboMenu.properties diff --git a/mailnews/base/resources/locale/en-US/mailTurboMenu.properties b/mailnews/base/resources/locale/en-US/mailTurboMenu.properties new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mailnews/jar.mn b/mailnews/jar.mn index 1c669d8433f..83f51947b6b 100644 --- a/mailnews/jar.mn +++ b/mailnews/jar.mn @@ -196,6 +196,7 @@ en-US.jar: locale/en-US/messenger/msgFolderPickerOverlay.dtd (base/resources/locale/en-US/msgFolderPickerOverlay.dtd) locale/en-US/messenger/msgHdrViewOverlay.dtd (base/resources/locale/en-US/msgHdrViewOverlay.dtd) locale/en-US/messenger/mailTasksOverlay.dtd (base/resources/locale/en-US/mailTasksOverlay.dtd) + locale/en-US/messenger/mailTurboMenu.properties (base/resources/locale/en-US/mailTurboMenu.properties) locale/en-US/messenger/mailNavigatorOverlay.dtd (base/resources/locale/en-US/mailNavigatorOverlay.dtd) locale/en-US/messenger/mailEditorOverlay.dtd (base/resources/locale/en-US/mailEditorOverlay.dtd) locale/en-US/messenger/mailOverlay.dtd (base/resources/locale/en-US/mailOverlay.dtd) diff --git a/themes/classic/navigator/win/jar.mn b/themes/classic/navigator/win/jar.mn index ace6955d31f..e69de29bb2d 100644 --- a/themes/classic/navigator/win/jar.mn +++ b/themes/classic/navigator/win/jar.mn @@ -1,4 +0,0 @@ -classic.jar: - skin/classic/navigator/navigator.css - skin/classic/navigator/resources.xml - diff --git a/themes/classic/navigator/win/turbo-systray.gif b/themes/classic/navigator/win/turbo-systray.gif new file mode 100644 index 00000000000..e69de29bb2d diff --git a/themes/classic/navigator/win/turbo.css b/themes/classic/navigator/win/turbo.css new file mode 100644 index 00000000000..9e0b0ac928c --- /dev/null +++ b/themes/classic/navigator/win/turbo.css @@ -0,0 +1,4 @@ +#turboTrayImage { + list-style-image: url("chrome://navigator/skin/turbo-systray.gif"); + border: 2px inset ThreeDHighlight !important; +} diff --git a/themes/modern/global/menulist.css b/themes/modern/global/menulist.css index f6bc162baa1..0f74ce9d37b 100644 --- a/themes/modern/global/menulist.css +++ b/themes/modern/global/menulist.css @@ -272,12 +272,15 @@ menulist[editable="true"] { .menulist-editable-box { border: 1px solid #5D616E; + padding: 1px 0px 1px 2px; } html|*.menulist-editable-text { - border: none !important; margin: 0px !important; + border: none !important; padding: 0px !important; + background-color: inherit; + font: inherit; } menulist[editable="true"]> .menulist-editable-box > .menu-dropmarker-box > .menu-dropmarker { diff --git a/themes/modern/jar.mn b/themes/modern/jar.mn index 4e3c61aa5d7..0478f684347 100644 --- a/themes/modern/jar.mn +++ b/themes/modern/jar.mn @@ -752,6 +752,8 @@ modern.jar: skin/modern/navigator/navigatorBindings.xml (navigator/navigatorBindings.xml) skin/modern/navigator/personalToolbar.css (navigator/personalToolbar.css) skin/modern/navigator/resources.xml (navigator/resources.xml) + skin/modern/navigator/turbo-systray.gif (navigator/turbo-systray.gif) + skin/modern/navigator/turbo.css (navigator/turbo.css) skin/modern/navigator/btn1/back-act.gif (navigator/btn1/back-act.gif) skin/modern/navigator/btn1/back-dis.gif (navigator/btn1/back-dis.gif) skin/modern/navigator/btn1/back-hov.gif (navigator/btn1/back-hov.gif) diff --git a/themes/modern/navigator/turbo-systray.gif b/themes/modern/navigator/turbo-systray.gif new file mode 100644 index 00000000000..e69de29bb2d diff --git a/themes/modern/navigator/turbo.css b/themes/modern/navigator/turbo.css new file mode 100644 index 00000000000..e69de29bb2d diff --git a/xpfe/appshell/public/nsINativeAppSupport.idl b/xpfe/appshell/public/nsINativeAppSupport.idl index d11ce0b30e0..e1385b92ca6 100644 --- a/xpfe/appshell/public/nsINativeAppSupport.idl +++ b/xpfe/appshell/public/nsINativeAppSupport.idl @@ -149,14 +149,8 @@ * Windows startup folder at system initialization. * * - * needsProfileUI - Boolean attribute used when running in "server mode." - * If the "server mode" caused profile dialogs to be - * suppressed, this should be set to true. When the server - * starts a real session, it will call on the profile mgr - * to do what it needed to do when this attribute is true. */ -interface nsIDOMWindow; interface nsIXULWindow; [scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)] @@ -172,8 +166,8 @@ interface nsINativeAppSupport : nsISupports { // Server mode. attribute boolean isServerMode; + attribute boolean shouldShowUI; void startServerMode(); - attribute boolean needsProfileUI; void onLastWindowClosing(in nsIXULWindow aWindow); }; diff --git a/xpfe/appshell/src/nsAppShellService.cpp b/xpfe/appshell/src/nsAppShellService.cpp index 99e86792daf..cfd5532f27b 100644 --- a/xpfe/appshell/src/nsAppShellService.cpp +++ b/xpfe/appshell/src/nsAppShellService.cpp @@ -222,14 +222,11 @@ nsAppShellService::DoProfileStartup(nsICmdLineService *aCmdLineService, PRBool c PRBool saveQuitOnLastWindowClosing = mQuitOnLastWindowClosing; mQuitOnLastWindowClosing = PR_FALSE; - // If we are in server mode, profile mgr cannot show UI + // If we being launched in turbo mode, profile mgr cannot show UI rv = profileMgr->StartupWithArgs(aCmdLineService, canInteract); - NS_ASSERTION(NS_SUCCEEDED(rv), "StartupWithArgs failed\n"); if (!canInteract && rv == NS_ERROR_PROFILE_REQUIRES_INTERACTION) { - if (mNativeAppSupport) { - mNativeAppSupport->SetNeedsProfileUI(PR_TRUE); - rv = NS_OK; - } + NS_WARNING("nsIProfileInternal::StartupWithArgs returned NS_ERROR_PROFILE_REQUIRES_INTERACTION"); + rv = NS_OK; } mQuitOnLastWindowClosing = saveQuitOnLastWindowClosing; diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index bd9f4ce45f9..a7082ae9bf7 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -56,8 +56,8 @@ #include "nsIContentHandler.h" #include "nsIBrowserInstance.h" #include "nsIEventQueueService.h" -#include "nsMPFileLocProvider.h" -#include "nsDirectoryServiceDefs.h" +#include "nsMPFileLocProvider.h" +#include "nsDirectoryServiceDefs.h" #include "nsIHttpProtocolHandler.h" #include "nsBuildID.h" #include "nsWindowCreator.h" @@ -79,7 +79,6 @@ #include "nsIXRemoteClient.h" #include "nsIXRemoteService.h" #endif -#define TURBO_PREF "browser.turbo.enabled" #ifdef NS_TRACE_MALLOC #include "nsTraceMalloc.h" @@ -91,12 +90,8 @@ #define DEBUG_CMD_LINE #endif -// Standalone App defines -#define STANDALONE_APP_PREF "profile.standalone_app.enable" -#define STANDALONE_APP_DIR_PREF "profile.standalone_app.directory" - static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID); -static NS_DEFINE_CID(kIProcessCID, NS_PROCESS_CID); +static NS_DEFINE_CID(kIProcessCID, NS_PROCESS_CID); static NS_DEFINE_CID(kChromeRegistryCID, NS_CHROMEREGISTRY_CID); #define UILOCALE_CMD_LINE_ARG "-UILocale" @@ -227,10 +222,10 @@ public: { // TSM is initialized in InitializeMacToolbox }; - + ~stTSMCloser() { -#if !TARGET_CARBON +#if !TARGET_CARBON (void)CloseTSMAwareApplication(); #endif } @@ -255,7 +250,7 @@ static char *sWatcherServiceContractID = "@mozilla.org/embedcomp/window-watcher; #if !defined (XP_MAC ) && !defined(NTO) && !defined( XP_PC ) && !defined( XP_BEOS ) nsresult NS_CreateSplashScreen( nsISplashScreen **aResult ) -{ +{ nsresult rv = NS_OK; if ( aResult ) { *aResult = 0; @@ -305,11 +300,11 @@ static nsresult GetNativeAppSupport(nsINativeAppSupport** aNativeApp) { NS_ENSURE_ARG_POINTER(aNativeApp); *aNativeApp = nsnull; - + nsCOMPtr appShellService(do_GetService(kAppShellServiceCID)); if (appShellService) appShellService->GetNativeAppSupport(aNativeApp); - + return *aNativeApp ? NS_OK : NS_ERROR_FAILURE; } @@ -494,7 +489,7 @@ LaunchApplicationWithArgs(const char *commandLineArg, NS_ENSURE_ARG(aParam); nsresult rv; - + nsCOMPtr cmdLine = do_GetService("@mozilla.org/appshell/commandLineService;1",&rv); if (NS_FAILED(rv)) return rv; @@ -643,13 +638,13 @@ static nsresult HandleArbitraryStartup( nsICmdLineService* cmdLineArgs, nsIPref // Get the value of -width option rv = cmdLineArgs->GetCmdLineValue("-width", getter_Copies(tempString)); if (NS_FAILED(rv)) return rv; - + if ((const char*)tempString) PR_sscanf(tempString, "%d", &width); - + // Get the value of -height option rv = cmdLineArgs->GetCmdLineValue("-height", getter_Copies(tempString)); if (NS_FAILED(rv)) return rv; - + if ((const char*)tempString) PR_sscanf(tempString, "%d", &height); if (heedGeneralStartupPrefs) { @@ -707,7 +702,7 @@ static nsresult HandleArbitraryStartup( nsICmdLineService* cmdLineArgs, nsIPref static nsresult DoCommandLines(nsICmdLineService* cmdLine, PRBool heedGeneralStartupPrefs) { nsresult rv; - + nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; @@ -801,19 +796,24 @@ static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs) if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator)))) { PRBool more; - + windowEnumerator->HasMoreElements(&more); if ( !more ) { - // If starting up in server mode, then we do things differently. - nsCOMPtr nativeApp; - PRBool serverMode = PR_FALSE; - rv = GetNativeAppSupport(getter_AddRefs(nativeApp)); - // Create special Nav window. - if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(nativeApp->GetIsServerMode(&serverMode)) && serverMode) { - nativeApp->StartServerMode(); - return NS_OK; - } + #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 = nsIAppShellService::SIZE_TO_CONTENT; @@ -826,8 +826,8 @@ static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs) return rv; if ((const char*)tempString) PR_sscanf(tempString, "%d", &width); - - + + // Get the value of -height option rv = cmdLineArgs->GetCmdLineValue("-height", getter_Copies(tempString)); if (NS_FAILED(rv)) @@ -835,7 +835,7 @@ static nsresult Ensure1Window( nsICmdLineService* cmdLineArgs) if ((const char*)tempString) PR_sscanf(tempString, "%d", &height); - + rv = OpenBrowserWindow(height, width); } } @@ -871,76 +871,18 @@ static nsresult InstallGlobalLocale(nsICmdLineService *cmdLineArgs) return NS_OK; } -// Do the righe thing to provide locations depending on whether an -// application is standalone or not static nsresult InitializeProfileService(nsICmdLineService *cmdLineArgs) { + // If we are being launched in -turbo mode, we cannot show UI + PRBool shouldShowUI = PR_TRUE; + nsCOMPtr nativeApp; + if (NS_SUCCEEDED(GetNativeAppSupport(getter_AddRefs(nativeApp)))) + nativeApp->GetShouldShowUI(&shouldShowUI); nsresult rv; + nsCOMPtr appShellService(do_GetService(kAppShellServiceCID, &rv)); + if (NS_FAILED(rv)) return rv; + rv = appShellService->DoProfileStartup(cmdLineArgs, shouldShowUI); - PRBool standaloneApp = PR_FALSE; - nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID, &rv)); - if (NS_FAILED(rv)) return rv; - rv = prefs->GetBoolPref(STANDALONE_APP_PREF, &standaloneApp); - if (NS_SUCCEEDED(rv) && standaloneApp) - { - nsMPFileLocProvider *fileLocProvider = new nsMPFileLocProvider; - NS_ENSURE_TRUE(fileLocProvider, NS_ERROR_OUT_OF_MEMORY); - // Specify the dir that standalone app will use for its "profile" dir - nsCOMPtr parentDir; - - PRBool exists = PR_FALSE; -#ifdef XP_OS2 - rv = NS_GetSpecialDirectory(NS_OS2_HOME_DIR, getter_AddRefs(parentDir)); - - if (NS_SUCCEEDED(rv)) - rv = parentDir->Exists(&exists); - if (NS_FAILED(rv) || !exists) - return rv; -#elif defined(XP_PC) - rv = NS_GetSpecialDirectory(NS_WIN_APPDATA_DIR, getter_AddRefs(parentDir)); - if (NS_SUCCEEDED(rv)) - rv = parentDir->Exists(&exists); - if (NS_FAILED(rv) || !exists) - { - parentDir = nsnull; - rv = NS_GetSpecialDirectory(NS_WIN_WINDOWS_DIR, getter_AddRefs(parentDir)); - } - - if (NS_FAILED(rv)) - return rv; -#else - rv = NS_GetSpecialDirectory(NS_OS_HOME_DIR, getter_AddRefs(parentDir)); - - if (NS_SUCCEEDED(rv)) - rv = parentDir->Exists(&exists); - if (NS_FAILED(rv) || !exists) - return rv; -#endif - - // Get standalone app dir name from prefs and initialize mpfilelocprovider - nsXPIDLCString appDir; - rv = prefs->CopyCharPref(STANDALONE_APP_DIR_PREF, getter_Copies(appDir)); - if (NS_FAILED(rv) || (nsCRT::strlen(appDir) == 0)) - return NS_ERROR_FAILURE; - rv = fileLocProvider->Initialize(parentDir, appDir); - if (NS_FAILED(rv)) return rv; - - rv = prefs->ResetPrefs(); - if (NS_FAILED(rv)) return rv; - rv = prefs->ReadUserPrefs(nsnull); - if (NS_FAILED(rv)) return rv; - } - else - { - nsCOMPtr appShellService(do_GetService(kAppShellServiceCID, &rv)); - if (NS_FAILED(rv)) return rv; - nsCOMPtr nativeAppSupport; - PRBool serverMode = PR_FALSE; - ::GetNativeAppSupport(getter_AddRefs(nativeAppSupport)); - if (nativeAppSupport) - nativeAppSupport->GetIsServerMode(&serverMode); - rv = appShellService->DoProfileStartup(cmdLineArgs, !serverMode); - } return rv; } @@ -976,8 +918,8 @@ static void ShowOSAlertFromFile(int argc, char **argv, const char *alert_filenam directoryService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - rv = directoryService->Get(NS_APP_RES_DIR, - NS_GET_IID(nsIFile), + rv = directoryService->Get(NS_APP_RES_DIR, + NS_GET_IID(nsIFile), getter_AddRefs(fileName)); if (NS_SUCCEEDED(rv) && fileName) { fileName->Append(alert_filename); @@ -1005,12 +947,12 @@ static nsresult VerifyInstallation(int argc, char **argv) nsresult rv; nsCOMPtr registryFile; - nsCOMPtr directoryService = + nsCOMPtr directoryService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return NS_OK; - rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, - NS_GET_IID(nsIFile), + rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR, + NS_GET_IID(nsIFile), getter_AddRefs(registryFile)); if (NS_FAILED(rv) || !registryFile) return NS_OK; @@ -1028,7 +970,7 @@ static nsresult VerifyInstallation(int argc, char **argv) char* lastResortMessage = "A previous install did not complete correctly. Finishing install."; ShowOSAlertFromFile(argc, argv, CLEANUP_MESSAGE_FILENAME, lastResortMessage); - + nsCOMPtr cleanupUtility; registryFile->Clone(getter_AddRefs(cleanupUtility)); cleanupUtility->SetLeafName(CLEANUP_UTIL); @@ -1038,7 +980,7 @@ static nsresult VerifyInstallation(int argc, char **argv) rv = cleanupProcess->Init(cleanupUtility); if (NS_SUCCEEDED(rv)) rv = cleanupProcess->Run(PR_FALSE,nsnull, 0, nsnull); - + //We must exit because all open files must be released by the system return NS_ERROR_FAILURE; } @@ -1051,11 +993,11 @@ static nsresult VerifyPsmAbsentOrSane(int argc, char **argv) nsCOMPtr enCol = do_GetService(NS_ENTROPYCOLLECTOR_CONTRACTID, &rv); - + if (rv == NS_ERROR_ABORT) { - // In case the security component can not do its internal initialization, + // In case the security component can not do its internal initialization, // we must warn the user and exit. - + char *panicMsg = "Could not initialize the browser's security component. " "The most likely cause is problems with files in your " "browser's profile directory. Please check that this " @@ -1063,9 +1005,9 @@ static nsresult VerifyPsmAbsentOrSane(int argc, char **argv) "hard disk is not full or close to full."; char *panicMessageFilename = "nssifail.txt"; - + ShowOSAlertFromFile(argc, argv, panicMessageFilename, panicMsg); - + return rv; } @@ -1260,7 +1202,7 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize appshell"); if (NS_FAILED(rv)) return rv; - + rv = InitializeWindowCreator(); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize window creator"); if (NS_FAILED(rv)) return rv; @@ -1288,20 +1230,6 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ) appShell->CreateHiddenWindow(); NS_TIMELINE_LEAVE("appShell->CreateHiddenWindow"); - 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; - nativeApps->GetIsServerMode(&serverMode); - if (!serverMode) { // okay, so it's not -turbo - 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 @@ -1447,7 +1375,7 @@ static nsresult DumpVersion(char *appname) nsXPIDLCString agent; httpHandler->GetUserAgent(getter_Copies(agent)); - + printf("%s", agent.get()); if(buildID) { @@ -1455,7 +1383,7 @@ static nsresult DumpVersion(char *appname) } else { printf(" \n"); } - + return rv; } @@ -1593,7 +1521,7 @@ int main(int argc, char* argv[]) // They should% return quick, so we deal with them here. if (HandleDumpArguments(argc, argv)) return 0; - + #ifdef NS_TRACE_MALLOC argc = NS_TraceMallocStartupArgs(argc, argv); #endif diff --git a/xpfe/bootstrap/nsNativeAppSupportBase.cpp b/xpfe/bootstrap/nsNativeAppSupportBase.cpp index 85cb153072c..3384da1638d 100644 --- a/xpfe/bootstrap/nsNativeAppSupportBase.cpp +++ b/xpfe/bootstrap/nsNativeAppSupportBase.cpp @@ -26,7 +26,8 @@ nsNativeAppSupportBase::nsNativeAppSupportBase() : mRefCnt( 0 ), mSplash( 0 ), mServerMode( PR_FALSE ), - mNeedsProfileUI( PR_FALSE ) { + mShouldShowUI( PR_TRUE ), + mShownTurboDialog( PR_FALSE ) { } nsNativeAppSupportBase::~nsNativeAppSupportBase() { @@ -94,15 +95,15 @@ nsNativeAppSupportBase::GetIsServerMode(PRBool *aIsServerMode) { } NS_IMETHODIMP -nsNativeAppSupportBase::GetNeedsProfileUI(PRBool *aNeedsProfileUI) { - NS_ENSURE_ARG_POINTER(aNeedsProfileUI); - *aNeedsProfileUI = mNeedsProfileUI; +nsNativeAppSupportBase::SetShouldShowUI(PRBool aShouldShowUI) { + mShouldShowUI = aShouldShowUI; return NS_OK; } NS_IMETHODIMP -nsNativeAppSupportBase::SetNeedsProfileUI(PRBool aNeedsProfileUI) { - mNeedsProfileUI = aNeedsProfileUI; +nsNativeAppSupportBase::GetShouldShowUI(PRBool *aShouldShowUI) { + NS_ENSURE_ARG( aShouldShowUI ); + *aShouldShowUI = mShouldShowUI; return NS_OK; } diff --git a/xpfe/bootstrap/nsNativeAppSupportBase.h b/xpfe/bootstrap/nsNativeAppSupportBase.h index bd05c7ac7fd..4fe567acac8 100644 --- a/xpfe/bootstrap/nsNativeAppSupportBase.h +++ b/xpfe/bootstrap/nsNativeAppSupportBase.h @@ -53,6 +53,7 @@ public: nsrefcnt mRefCnt; nsCOMPtr mSplash; PRBool mServerMode; - PRBool mNeedsProfileUI; + PRBool mShouldShowUI; + PRBool mShownTurboDialog; }; // class nsSplashScreenWin diff --git a/xpfe/bootstrap/nsNativeAppSupportOS2.cpp b/xpfe/bootstrap/nsNativeAppSupportOS2.cpp index 2789e938240..b4e022c6fae 100644 --- a/xpfe/bootstrap/nsNativeAppSupportOS2.cpp +++ b/xpfe/bootstrap/nsNativeAppSupportOS2.cpp @@ -346,6 +346,7 @@ public: NS_IMETHOD Quit(); NS_IMETHOD StartServerMode(); NS_IMETHOD SetIsServerMode( PRBool isServerMode ); + NS_IMETHOD OnLastWindowClosing( nsIXULWindow *aWindow ); // The "old" Start method (renamed). NS_IMETHOD StartDDE(); @@ -1766,41 +1767,33 @@ nsNativeAppSupportOS2::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu return rv; } -// Check the needsProfileUI attribute of the native app and, -// if so, do it. Once this suceeds, set the attribute to false -// so we can only do this once. +// Check to see if we have a profile. We will not have a profile +// at this point if we were launched invisibly in -turbo mode, and +// the profile mgr needed to show UI (to pick from multiple profiles). +// At this point, we can show UI, so call DoProfileStartUp(). + nsresult nsNativeAppSupportOS2::EnsureProfile(nsICmdLineService* args) { - nsresult rv = NS_OK; - nsCOMPtr appShell = do_GetService( "@mozilla.org/appshell/appShellService;1", &rv ); - if (NS_FAILED(rv)) return rv; - nsCOMPtr nativeApp; - rv = appShell->GetNativeAppSupport(getter_AddRefs(nativeApp)); - if (NS_FAILED(rv)) return rv; - PRBool needsProfileUI; - rv = nativeApp->GetNeedsProfileUI(&needsProfileUI); - if (NS_FAILED(rv)) return rv; + nsresult rv; nsCOMPtr profileMgr(do_GetService(NS_PROFILE_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; + nsCOMPtr appShell(do_GetService("@mozilla.org/appshell/appShellService;1", &rv)); + if (NS_FAILED(rv)) return rv; + + // If we have a profile, everything is fine. + PRBool haveProfile; + rv = profileMgr->IsCurrentProfileAvailable(&haveProfile); + if (NS_SUCCEEDED(rv) && haveProfile) + return NS_OK; - if (needsProfileUI) { - // We need profile UI because we started in - // server mode and could not show it then. - rv = profileMgr->StartupWithArgs(args, PR_TRUE); - if (NS_FAILED(rv)) return rv; - nativeApp->SetNeedsProfileUI(PR_FALSE); - } - else { - // Even if not started in server mode, ensure - // that we have a profile. We can hit this case - // if somebody double-clicks the app twice. - PRBool haveProfile = PR_FALSE; - (void)profileMgr->IsCurrentProfileAvailable(&haveProfile); - if (!haveProfile) return NS_ERROR_FAILURE; - } - return NS_OK; + // If the profile selection is happening, fail. + PRBool doingProfileStartup; + rv = profileMgr->GetIsStartingUp(&doingProfileStartup); + if (NS_FAILED(rv) || doingProfileStartup) return NS_ERROR_FAILURE; + rv = appShell->DoProfileStartup(args, PR_TRUE); + return rv; } nsresult @@ -2142,6 +2135,33 @@ nsNativeAppSupportOS2::SetIsServerMode( PRBool isServerMode ) { return nsNativeAppSupportBase::SetIsServerMode( isServerMode ); } +NS_IMETHODIMP +nsNativeAppSupportOS2::OnLastWindowClosing( nsIXULWindow *aWindow ) { + + nsresult rv; + + if (!mServerMode) + return NS_OK; + + // If the last window closed is our special "turbo" window made + // in StartServerMode(), don't do anything. + nsCOMPtr docShell; + (void)aWindow->GetDocShell(getter_AddRefs(docShell)); + nsCOMPtr domWindow(do_GetInterface(docShell)); + if (domWindow == mInitialWindow) { + mInitialWindow = nsnull; + return NS_OK; + } + + nsCOMPtr profileMgr(do_GetService(NS_PROFILE_CONTRACTID, &rv)); + if (NS_FAILED(rv)) return rv; + rv = profileMgr->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST); + if (NS_FAILED(rv)) return rv; + + return NS_OK; +} + + // go through the command line arguments, and try to load a handler // for one, and when we do, get the chrome URL for its task diff --git a/xpfe/bootstrap/nsNativeAppSupportWin.cpp b/xpfe/bootstrap/nsNativeAppSupportWin.cpp index f8f7ae08e45..f6ad8af69b9 100644 --- a/xpfe/bootstrap/nsNativeAppSupportWin.cpp +++ b/xpfe/bootstrap/nsNativeAppSupportWin.cpp @@ -17,7 +17,7 @@ * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * - * Contributor(s): + * Contributor(s): * Bill Law law@netscape.com */ @@ -38,8 +38,8 @@ #include "nsIWindowWatcher.h" #include "nsIDOMWindowInternal.h" #include "nsIScriptGlobalObject.h" -#include "nsIDocShell.h" -#include "nsIBaseWindow.h" +#include "nsIDocShell.h" +#include "nsIBaseWindow.h" #include "nsIWidget.h" #include "nsIAppShellService.h" #include "nsIProfileInternal.h" @@ -47,6 +47,11 @@ #include "nsIXULWindow.h" #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" +#include "nsIPref.h" +#include "nsIWindowsHooks.h" +#include "nsIPromptService.h" +#include "nsNetCID.h" +#include "nsIHttpProtocolHandler.h" // These are needed to load a URL in a browser window. #include "nsIDOMLocation.h" @@ -61,9 +66,15 @@ #include #include -#define TURBO_QUIT 1 +#define TURBO_NAVIGATOR 1 +#define TURBO_MAIL 2 +#define TURBO_EDITOR 3 +#define TURBO_ADDRESSBOOK 4 +#define TURBO_DISABLE 5 +#define TURBO_EXIT 6 static HWND hwndForDOMWindow( nsISupports * ); +static NS_DEFINE_CID(kHttpHandlerCID, NS_HTTPPROTOCOLHANDLER_CID); static nsresult @@ -255,13 +266,13 @@ private: * code consists of initializing DDE and doing a DdeConnect to Mozilla's * application/topic. If that connection succeeds, then a server process * must be running already. - * + * * Otherwise, no server has started. In that case, the current process * calls DdeNameService to register that application/topic. Only at that * point does the mutex get released. * * There are a couple of subtleties that one should be aware of: - * + * * 1. It is imperative that DdeInitialize be called only after the mutex * lock has been obtained. The reason is that at shutdown, DDE * notifications go out to all initialized DDE processes. Thus, if @@ -274,7 +285,7 @@ private: * * 2. All mutex requests are made with a reasonably long timeout value and * are designed to "fail safe" (i.e., a timeout is treated as failure). - * + * * 3. An attempt has been made to minimize the degree to which the main * Mozilla application logic needs to be aware of the DDE mechanisms * implemented herein. As a result, this module surfaces a very @@ -367,7 +378,6 @@ private: static DWORD mInstance; static char *mAppName; static nsIDOMWindow *mInitialWindow; - static nsXPIDLString mLastProfileName; friend struct MessageWindow; }; // nsNativeAppSupportWin @@ -467,10 +477,10 @@ nsSplashScreenWin::DialogProc( HWND dlg, UINT msg, WPARAM wp, LPARAM lp ) { splashScreen->LoadBitmap(); } - /* Size and center the splash screen correctly. The flags in the - * dialog template do not do the right thing if the user's + /* Size and center the splash screen correctly. The flags in the + * dialog template do not do the right thing if the user's * machine is using large fonts. - */ + */ HWND bitmapControl = GetDlgItem( dlg, IDB_SPLASH ); if ( bitmapControl ) { HBITMAP hbitmap = (HBITMAP)SendMessage( bitmapControl, @@ -587,14 +597,15 @@ nsNativeAppSupportWin::CheckConsole() { || strcmp( "/turbo", __argv[i] ) == 0 || - strcmp( "-server", __argv[i] ) == 0 + strcmp( "-server", __argv[i] ) == 0 || - strcmp( "/server", __argv[i] ) == 0 ) { - // Start in server mode (and suppress splash screen). + strcmp( "/server", __argv[i] ) == 0 ) { + // Start in server mode (and suppress splash screen). mServerMode = PR_TRUE; + mShouldShowUI = PR_FALSE; __argv[i] = "-nosplash"; // Bit of a hack, but it works! - // Ignore other args. - break; + // Ignore other args. + break; } } return; @@ -606,11 +617,11 @@ nsresult NS_CreateNativeAppSupport( nsINativeAppSupport **aResult ) { if ( aResult ) { nsNativeAppSupportWin *pNative = new nsNativeAppSupportWin; - if ( pNative ) { - *aResult = pNative; - NS_ADDREF( *aResult ); - // Check for dynamic console creation request. - pNative->CheckConsole(); + if ( pNative ) { + *aResult = pNative; + NS_ADDREF( *aResult ); + // Check for dynamic console creation request. + pNative->CheckConsole(); } else { return NS_ERROR_OUT_OF_MEMORY; } @@ -668,11 +679,10 @@ HSZ nsNativeAppSupportWin::mApplication = 0; HSZ nsNativeAppSupportWin::mTopics[nsNativeAppSupportWin::topicCount] = { 0 }; DWORD nsNativeAppSupportWin::mInstance = 0; nsIDOMWindow* nsNativeAppSupportWin::mInitialWindow = nsnull; -nsXPIDLString nsNativeAppSupportWin::mLastProfileName; NOTIFYICONDATA nsNativeAppSupportWin::mIconData = { sizeof(NOTIFYICONDATA), 0, - 1, + 1, NIF_ICON | NIF_MESSAGE | NIF_TIP, WM_USER, 0, @@ -685,7 +695,7 @@ struct MessageWindow { // ctor/dtor are simplistic MessageWindow() { // Try to find window. - mHandle = ::FindWindow( className(), 0 ); + mHandle = ::FindWindow( className(), 0 ); } // Act like an HWND. @@ -697,7 +707,7 @@ struct MessageWindow { static const char *className() { static char classNameBuffer[128]; static char *mClassName = 0; - if ( !mClassName ) { + if ( !mClassName ) { ::_snprintf( classNameBuffer, sizeof classNameBuffer, "%s%s", @@ -763,7 +773,7 @@ struct MessageWindow { // Show menu with Exit disabled/enabled appropriately. nsCOMPtr win; GetMostRecentWindow( 0, getter_AddRefs( win ) ); - ::EnableMenuItem( nsNativeAppSupportWin::mTrayIconMenu, 1, win ? MF_GRAYED : MF_ENABLED ); + ::EnableMenuItem( nsNativeAppSupportWin::mTrayIconMenu, TURBO_EXIT, win ? MF_GRAYED : MF_ENABLED ); POINT pt; GetCursorPos( &pt ); @@ -778,9 +788,61 @@ struct MessageWindow { 0 ); switch (selectedItem) { - case TURBO_QUIT: + case TURBO_NAVIGATOR: + (void)nsNativeAppSupportWin::HandleRequest( (LPBYTE)"mozilla" ); + break; + case TURBO_MAIL: + (void)nsNativeAppSupportWin::HandleRequest( (LPBYTE)"mozilla -mail" ); + break; + case TURBO_EDITOR: + (void)nsNativeAppSupportWin::HandleRequest( (LPBYTE)"mozilla -editor" ); + break; + case TURBO_ADDRESSBOOK: + (void)nsNativeAppSupportWin::HandleRequest( (LPBYTE)"mozilla -addressbook" ); + break; + case TURBO_EXIT: (void)nsNativeAppSupportWin::HandleRequest( (LPBYTE)"mozilla -kill" ); break; + case TURBO_DISABLE: + nsresult rv; + nsCOMPtr winHooksService ( do_GetService( NS_IWINDOWSHOOKS_CONTRACTID, &rv ) ); + if ( NS_SUCCEEDED( rv ) ) + winHooksService->StartupTurboDisable(); + nsCOMPtr stringBundleService( do_GetService( NS_STRINGBUNDLE_CONTRACTID ) ); + nsCOMPtr turboMenuBundle; + nsCOMPtr brandBundle; + if ( stringBundleService ) { + stringBundleService->CreateBundle( "chrome://global/locale/brand.properties", getter_AddRefs( brandBundle ) ); + stringBundleService->CreateBundle( "chrome://navigator/locale/turboMenu.properties", + getter_AddRefs( turboMenuBundle ) ); + } + nsXPIDLString dialogMsg; + nsXPIDLString dialogTitle; + nsXPIDLString brandName; + if ( brandBundle && turboMenuBundle ) { + brandBundle->GetStringFromName( NS_LITERAL_STRING( "brandShortName" ).get(), + getter_Copies( brandName ) ); + const PRUnichar *formatStrings[] = { brandName.get() }; + turboMenuBundle->GetStringFromName( NS_LITERAL_STRING( "DisableDlgMsg" ).get(), + getter_Copies( dialogMsg ) ); + turboMenuBundle->FormatStringFromName( NS_LITERAL_STRING( "DisableDlgTitle" ).get(), formatStrings, + 1, getter_Copies( dialogTitle ) ); + } + if ( dialogMsg.get() && dialogTitle.get() && brandName.get() ) { + nsCOMPtr dialog( do_GetService( "@mozilla.org/embedcomp/prompt-service;1" ) ); + if ( dialog ) + dialog->Alert( nsnull, dialogTitle.get(), dialogMsg.get() ); + } + nsCOMPtr appShell = do_GetService( "@mozilla.org/appshell/appShellService;1", &rv ); + if ( NS_SUCCEEDED( rv ) ) { + nsCOMPtr native; + rv = appShell->GetNativeAppSupport( getter_AddRefs( native ) ); + if ( NS_SUCCEEDED( rv ) ) + native->SetIsServerMode( PR_FALSE ); + if ( !win ) + appShell->Quit(); + } + break; } PostMessage(msgWindow, WM_NULL, 0, 0); } else if ( lp == WM_LBUTTONDBLCLK ) { @@ -810,7 +872,7 @@ char *nsNativeAppSupportWin::mAppName = nameBuffer; * case, we use the handle to the "message" window and send * a request corresponding to this process's command line * options. - * + * * If not, then this is the first instance of Mozilla. In * that case, we create and set up the message window. * @@ -861,6 +923,26 @@ 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 ) { + nsresult res; + nsCOMPtr http ( do_GetService( kHttpHandlerCID, &res ) ); + if ( NS_FAILED( res ) ) return rv; + nsXPIDLCString appName; + http->GetAppName( getter_Copies( appName ) ); + nsCString fullValue; fullValue.Assign( appName ); + fullValue.Append( " Quick Launch" ); + result = ::RegQueryValueEx( key, fullValue, NULL, NULL, NULL, NULL ); + ::RegCloseKey( key ); + if ( result == ERROR_SUCCESS ) + SetIsServerMode( PR_TRUE ); + } + } + return rv; } @@ -903,8 +985,8 @@ nsNativeAppSupportWin::StartDDE() { nsNativeAppSupportWin::HandleDDENotification, APPCLASS_STANDARD, 0 ), - NS_ERROR_FAILURE ); - + NS_ERROR_FAILURE ); + // Allocate DDE strings. NS_ENSURE_TRUE( ( mApplication = DdeCreateStringHandle( mInstance, mAppName, CP_WINANSI ) ) && InitTopicStrings(), NS_ERROR_FAILURE ); @@ -1169,7 +1251,7 @@ nsCString nsNativeAppSupportWin::ParseDDEArg( HSZ args, int index ) { end = temp.Length(); } // Extract result. - result.Assign( temp.get() + offset, end - offset ); + result.Assign( temp.get() + offset, end - offset ); } } @@ -1207,7 +1289,7 @@ HDDEDATA nsNativeAppSupportWin::CreateDDEData( DWORD value ) { void nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) { // Parse command line. - + nsCOMPtr args; nsresult rv; @@ -1255,7 +1337,7 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) { nsCOMPtr appShell = do_GetService( "@mozilla.org/appshell/appShellService;1", &rv); if (NS_FAILED(rv)) return; - + nsCOMPtr native; rv = appShell->GetNativeAppSupport( getter_AddRefs( native )); if (NS_SUCCEEDED(rv)) { @@ -1276,7 +1358,7 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) { } - // ok, no idea what the param is. + // ok, no idea what the param is. #if MOZ_DEBUG_DDE printf( "Unknown request [%s]\n", (char*) request ); #endif @@ -1285,14 +1367,14 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) { "@mozilla.org/commandlinehandler/general-startup;1?type=browser"; nsCOMPtr handler = do_GetService(contractID, &rv); if (NS_FAILED(rv)) return; - + rv = EnsureProfile(args); if (NS_FAILED(rv)) return; - + nsXPIDLString defaultArgs; rv = handler->GetDefaultArgs(getter_Copies(defaultArgs)); if (NS_FAILED(rv) || !defaultArgs) return; - + if (defaultArgs) { nsCAutoString url; url.AssignWithConversion( defaultArgs ); @@ -1355,7 +1437,7 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu // We are processing the contents of an argument. // Check for whitespace or end. if ( *p == 0 || ( !quoted && isspace( *p ) ) ) { - // Process pending backslashes (interpret them + // Process pending backslashes (interpret them // literally since they're not followed by a "). while( bSlashCount ) { arg += '\\'; @@ -1364,7 +1446,7 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu // End current arg. if ( !justCounting ) { argv[argc] = new char[ arg.Length() + 1 ]; - strcpy( argv[argc], arg.get() ); + strcpy( argv[argc], arg.get() ); } argc++; // We're now between args. @@ -1426,7 +1508,7 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu if ( justCounting ) { // Allocate argv array. argv = new char*[ argc ]; - + // Start second pass justCounting = 0; init = 1; @@ -1458,13 +1540,14 @@ nsNativeAppSupportWin::GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResu return rv; } -// Check the needsProfileUI attribute of the native app and, -// if so, do it. Once this suceeds, set the attribute to false -// so we can only do this once. +// Check to see if we have a profile. We will not have a profile +// at this point if we were launched invisibly in -turbo mode, and +// the profile mgr needed to show UI (to pick from multiple profiles). +// At this point, we can show UI, so call DoProfileStartUp(). nsresult nsNativeAppSupportWin::EnsureProfile(nsICmdLineService* args) { - nsresult rv; + nsresult rv; nsCOMPtr profileMgr(do_GetService(NS_PROFILE_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; @@ -1476,23 +1559,13 @@ nsNativeAppSupportWin::EnsureProfile(nsICmdLineService* args) rv = profileMgr->IsCurrentProfileAvailable(&haveProfile); if (NS_SUCCEEDED(rv) && haveProfile) return NS_OK; - + // If the profile selection is happening, fail. PRBool doingProfileStartup; rv = profileMgr->GetIsStartingUp(&doingProfileStartup); if (NS_FAILED(rv) || doingProfileStartup) return NS_ERROR_FAILURE; - nsCOMPtr nativeApp; - rv = appShell->GetNativeAppSupport(getter_AddRefs(nativeApp)); - if (NS_FAILED(rv)) return rv; - PRBool needsProfileUI; - rv = nativeApp->GetNeedsProfileUI(&needsProfileUI); - if (NS_FAILED(rv)) return rv; - - if (needsProfileUI) - rv = appShell->DoProfileStartup(args, PR_TRUE); - else - rv = profileMgr->SetCurrentProfile(mLastProfileName.get()); + rv = appShell->DoProfileStartup(args, PR_TRUE); return rv; } @@ -1566,7 +1639,7 @@ nsNativeAppSupportWin::ReParent( nsISupports *window, HWND newParent ) { return NS_ERROR_FAILURE; } - // Filter out WM_SETFOCUS messages while reparenting to + // Filter out WM_SETFOCUS messages while reparenting to // other than the desktop. // // For some reason, Windows generates one and it causes @@ -1638,7 +1711,7 @@ nsresult SafeJSContext::Push() { mContext = 0; } } - return mContext ? NS_OK : NS_ERROR_FAILURE; + return mContext ? NS_OK : NS_ERROR_FAILURE; } @@ -1647,7 +1720,7 @@ nsNativeAppSupportWin::OpenBrowserWindow( const char *args, PRBool newWindow ) { nsresult rv = NS_OK; // Open the argument URL in the most recently used Navigator window. // If there is no Nav window, open a new one. - + // Get most recently used Nav window. nsCOMPtr navWin; GetMostRecentWindow( NS_LITERAL_STRING( "navigator:browser" ).get(), getter_AddRefs( navWin ) ); @@ -1698,7 +1771,16 @@ nsNativeAppSupportWin::OpenBrowserWindow( const char *args, PRBool newWindow ) { return OpenWindow( "chrome://navigator/content", args ); } +void AppendMenuItem( HMENU& menu, PRInt32 aIdentifier, const nsString& aText ) { + char* ACPText = GetACPString( aText ); + if ( ACPText ) { + ::AppendMenu( menu, MF_STRING, aIdentifier, ACPText ); + delete [] ACPText; + } +} + // Utility function that sets up system tray icon. + void nsNativeAppSupportWin::SetupSysTrayIcon() { // Messages go to the hidden window. @@ -1711,46 +1793,102 @@ nsNativeAppSupportWin::SetupSysTrayIcon() { mIconData.szTip[0] = 0; nsCOMPtr svc( do_GetService( NS_STRINGBUNDLE_CONTRACTID ) ); if ( svc ) { - nsCOMPtr bundle1; - svc->CreateBundle( "chrome://global/locale/brand.properties", getter_AddRefs( bundle1 ) ); - if ( bundle1 ) { - nsXPIDLString tooltip; - bundle1->GetStringFromName( NS_LITERAL_STRING( "brandShortName" ).get(), - getter_Copies( tooltip ) ); + nsCOMPtr brandBundle; + nsXPIDLString tooltip; + svc->CreateBundle( "chrome://global/locale/brand.properties", getter_AddRefs( brandBundle ) ); + if ( brandBundle ) { + brandBundle->GetStringFromName( NS_LITERAL_STRING( "brandShortName" ).get(), + getter_Copies( tooltip ) ); // (damned strings...) nsAutoString autoTip( tooltip ); - nsAutoCString tip( autoTip ); + nsAutoCString tip( autoTip ); ::strncpy( mIconData.szTip, (const char*)tip, sizeof mIconData.szTip - 1 ); } // Build menu. - nsCOMPtr bundle2; - svc->CreateBundle( "chrome://communicator/locale/profile/profileManager.properties", - getter_AddRefs( bundle2 ) ); + nsCOMPtr turboBundle; + nsCOMPtr mailBundle; + svc->CreateBundle( "chrome://navigator/locale/turboMenu.properties", + getter_AddRefs( turboBundle ) ); + nsresult rv = svc->CreateBundle( "chrome://messenger/locale/mailTurboMenu.properties", + getter_AddRefs( mailBundle ) ); + PRBool isMail = NS_SUCCEEDED(rv) && mailBundle; nsAutoString exitText; - if ( bundle2 ) { - nsXPIDLString text; - bundle2->GetStringFromName( NS_LITERAL_STRING( "exitButton" ).get(), - getter_Copies( text ) ); - exitText = (const PRUnichar*)text; + nsAutoString disableText; + nsAutoString navigatorText; + nsAutoString editorText; + nsAutoString mailText; + nsAutoString addressbookText; + nsXPIDLString text; + if ( turboBundle ) { + if ( brandBundle ) { + const PRUnichar* formatStrings[] = { tooltip.get() }; + turboBundle->FormatStringFromName( NS_LITERAL_STRING( "Exit" ).get(), formatStrings, 1, + getter_Copies( text ) ); + exitText = (const PRUnichar*)text; + } + turboBundle->GetStringFromName( NS_LITERAL_STRING( "Disable" ).get(), + getter_Copies( text ) ); + disableText = (const PRUnichar*)text; + turboBundle->GetStringFromName( NS_LITERAL_STRING( "Navigator" ).get(), + getter_Copies( text ) ); + navigatorText = (const PRUnichar*)text; + turboBundle->GetStringFromName( NS_LITERAL_STRING( "Editor" ).get(), + getter_Copies( text ) ); + editorText = (const PRUnichar*)text; } - if ( exitText.IsEmpty() ) { - // Fall back to this. - exitText = NS_LITERAL_STRING( "Exit" ); + if (isMail) { + mailBundle->GetStringFromName( NS_LITERAL_STRING( "MailNews" ).get(), + getter_Copies( text ) ); + mailText = (const PRUnichar*)text; + mailBundle->GetStringFromName( NS_LITERAL_STRING( "Addressbook" ).get(), + getter_Copies( text ) ); + addressbookText = (const PRUnichar*)text; } + if ( exitText.IsEmpty() ) + exitText = NS_LITERAL_STRING( "&Exit Mozilla" ); + + if ( disableText.IsEmpty() ) + disableText = NS_LITERAL_STRING( "&Disable Quick Launch" ); + + if ( navigatorText.IsEmpty() ) + navigatorText = NS_LITERAL_STRING( "&Navigator" ); + + if ( editorText.IsEmpty() ) + editorText = NS_LITERAL_STRING( "&Composer" ); + + if ( isMail ) { + if ( mailText.IsEmpty() ) + mailText = NS_LITERAL_STRING( "&Mail && Newsgroups" ); + if ( addressbookText.IsEmpty() ) + addressbookText = NS_LITERAL_STRING( "&Address Book" ); + } // Create menu and add item. mTrayIconMenu = ::CreatePopupMenu(); - ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_QUIT, exitText.get() ); + ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_NAVIGATOR, navigatorText.get() ); if ( ::GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) { - char* exitACPText = GetACPString( exitText ); - if ( exitACPText ) { - ::AppendMenu( mTrayIconMenu, MF_STRING, TURBO_QUIT, exitACPText ); - delete [] exitACPText ; - } + AppendMenuItem( mTrayIconMenu, TURBO_NAVIGATOR, navigatorText ); + if ( isMail ) + AppendMenuItem( mTrayIconMenu, TURBO_MAIL, mailText ); + AppendMenuItem( mTrayIconMenu, TURBO_EDITOR, editorText ); + if ( isMail ) + AppendMenuItem( mTrayIconMenu, TURBO_ADDRESSBOOK, addressbookText ); + ::AppendMenu( mTrayIconMenu, MF_SEPARATOR, NULL, NULL ); + AppendMenuItem( mTrayIconMenu, TURBO_DISABLE, disableText ); + AppendMenuItem( mTrayIconMenu, TURBO_EXIT, exitText ); + } + else { + if (isMail) + ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_MAIL, mailText.get() ); + ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_EDITOR, editorText.get() ); + if (isMail) + ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_ADDRESSBOOK, addressbookText.get() ); + ::AppendMenuW( mTrayIconMenu, MF_SEPARATOR, NULL, NULL ); + ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_DISABLE, disableText.get() ); + ::AppendMenuW( mTrayIconMenu, MF_STRING, TURBO_EXIT, exitText.get() ); } - } - + // Add the tray icon. ::Shell_NotifyIcon( NIM_ADD, &mIconData ); } @@ -1838,26 +1976,38 @@ nsNativeAppSupportWin::SetIsServerMode( PRBool isServerMode ) { NS_IMETHODIMP nsNativeAppSupportWin::OnLastWindowClosing( nsIXULWindow *aWindow ) { - - nsresult rv; - if (!mServerMode) + if ( !mServerMode ) return NS_OK; // If the last window closed is our special "turbo" window made // in StartServerMode(), don't do anything. nsCOMPtr docShell; - (void)aWindow->GetDocShell(getter_AddRefs(docShell)); - nsCOMPtr domWindow(do_GetInterface(docShell)); - if (domWindow == mInitialWindow) { + ( void )aWindow->GetDocShell( getter_AddRefs( docShell ) ); + nsCOMPtr domWindow( do_GetInterface( docShell ) ); + if ( domWindow == mInitialWindow ) { mInitialWindow = nsnull; return NS_OK; } + nsresult rv; + if ( !mShownTurboDialog ) { + PRBool showDialog = PR_TRUE; + nsCOMPtr prefService ( do_GetService( NS_PREF_CONTRACTID, &rv ) ); + if ( NS_SUCCEEDED( rv ) ) + prefService->GetBoolPref( "browser.turbo.showDialog", &showDialog ); + nsCOMPtr domWindowInt ( do_GetInterface( docShell ) ); + if ( showDialog && domWindowInt ) { + nsCOMPtr newWindow; + mShownTurboDialog = PR_TRUE; + domWindowInt->OpenDialog( NS_LITERAL_STRING( "chrome://navigator/content/turboDialog.xul" ), + NS_LITERAL_STRING( "_blank" ), + NS_LITERAL_STRING( "chrome,modal,titlebar,centerscreen,dialog" ), + nsnull, getter_AddRefs( newWindow ) ); + } + } nsCOMPtr profileMgr(do_GetService(NS_PROFILE_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; - rv = profileMgr->GetCurrentProfile(getter_Copies(mLastProfileName)); - if (NS_FAILED(rv)) return rv; rv = profileMgr->ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST); if (NS_FAILED(rv)) return rv; @@ -1870,13 +2020,13 @@ nsresult nsNativeAppSupportWin::GetStartupURL(nsICmdLineService *args, nsCString& taskURL) { nsresult rv; - + nsCOMPtr handler; // see if there is a handler rv = args->GetHandlerForParam(nsnull, getter_AddRefs(handler)); if (NS_FAILED(rv)) return rv; - + // ok, from here on out, failures really are fatal nsXPIDLCString url; rv = handler->GetChromeUrlForTask(getter_Copies(url)); diff --git a/xpfe/browser/jar.mn b/xpfe/browser/jar.mn index 71f5e925c91..97a2fee052e 100644 --- a/xpfe/browser/jar.mn +++ b/xpfe/browser/jar.mn @@ -19,6 +19,7 @@ comm.jar: content/navigator/metadata.xul (resources/content/metadata.xul) content/navigator/metadata.js (resources/content/metadata.js) content/navigator/personalToolbar.js (resources/content/personalToolbar.js) + content/navigator/turboDialog.xul (resources/content/turboDialog.xul) en-US.jar: locale/en-US/navigator/contents.rdf (resources/locale/en-US/contents.rdf) locale/en-US/navigator/viewSource.dtd (resources/locale/en-US/viewSource.dtd) @@ -28,6 +29,8 @@ en-US.jar: locale/en-US/navigator/metadata.dtd (resources/locale/en-US/metadata.dtd) locale/en-US/navigator/metadata.properties (resources/locale/en-US/metadata.properties) locale/en-US/navigator/pageInfo.properties (resources/locale/en-US/pageInfo.properties) + locale/en-US/navigator/turboDialog.dtd (resources/locale/en-US/turboDialog.dtd) + locale/en-US/navigator/turboMenu.properties (resources/locale/en-US/turboMenu.properties) US.jar: locale/US/navigator-region/contents.rdf (resources/locale/en-US/contents-region.rdf) diff --git a/xpfe/browser/resources/content/turboDialog.xul b/xpfe/browser/resources/content/turboDialog.xul new file mode 100644 index 00000000000..74300a055d5 --- /dev/null +++ b/xpfe/browser/resources/content/turboDialog.xul @@ -0,0 +1,94 @@ + + + + + + + + %turboDialogDTD; + + %dialogOverlayDTD; + + %brandDTD; +]> + + + + + + + + + + + + + + &exitWarningMsg.label; + + + + + + + + + + + + + + + + + + + + +