From ac233ca8d6345366ac21129b5685ce9bd98fc0a4 Mon Sep 17 00:00:00 2001 From: "syd%netscape.com" Date: Thu, 13 Sep 2001 09:09:06 +0000 Subject: [PATCH] Trunk version of latest 88844 stuff, look for "Mozilla Quick Launch" instead of trying to construct a string based on the app name, which is not working. r=ssu, sr=brendan, a=asa --- xpfe/bootstrap/nsNativeAppSupportWin.cpp | 29 ++++++++------------ xpfe/components/winhooks/nsIWindowsHooks.idl | 3 ++ xpfe/components/winhooks/nsWindowsHooks.cpp | 28 ++----------------- 3 files changed, 17 insertions(+), 43 deletions(-) diff --git a/xpfe/bootstrap/nsNativeAppSupportWin.cpp b/xpfe/bootstrap/nsNativeAppSupportWin.cpp index c687bd61ef0..47739f22399 100644 --- a/xpfe/bootstrap/nsNativeAppSupportWin.cpp +++ b/xpfe/bootstrap/nsNativeAppSupportWin.cpp @@ -51,7 +51,6 @@ #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" @@ -74,7 +73,6 @@ #define TURBO_EXIT 6 static HWND hwndForDOMWindow( nsISupports * ); -static NS_DEFINE_CID(kHttpHandlerCID, NS_HTTPPROTOCOLHANDLER_CID); static nsresult @@ -925,29 +923,24 @@ nsNativeAppSupportWin::Start( PRBool *aResult ) { PRBool serverMode = PR_FALSE; GetIsServerMode( &serverMode ); -#if 0 -/* temporarily disabling to clear smoketest blocker 99286 - don't create an http protocol handler service before XPCOM is initialized - (danm for dp) */ - + // This code CANNOT be enabled here. This happens before XPCOM is initialized. + // SetIsServerMode() requires string bundle which requires XPCOM + // We should have this happen on a callback on first page load complete + // or some such thing. 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 ); + result = ::RegQueryValueEx( key, NS_QUICKLAUNCH_RUN_KEY, NULL, NULL, NULL, NULL ); ::RegCloseKey( key ); - if ( result == ERROR_SUCCESS ) - SetIsServerMode( PR_TRUE ); + if ( result == ERROR_SUCCESS ) { + // XXX To make absolutely sure, we should check the value to see if this is + // XXX us or one of our predecessors - bascially distinguish betn mozilla and + // XXX mozilla based browsers + SetIsServerMode( PR_TRUE ); + } } } -#endif return rv; } diff --git a/xpfe/components/winhooks/nsIWindowsHooks.idl b/xpfe/components/winhooks/nsIWindowsHooks.idl index 531ac7fe95e..8cfde0ebe4a 100644 --- a/xpfe/components/winhooks/nsIWindowsHooks.idl +++ b/xpfe/components/winhooks/nsIWindowsHooks.idl @@ -174,4 +174,7 @@ interface nsIWindowsHooks : nsISupports { %{C++ #define NS_IWINDOWSHOOKS_CONTRACTID "@mozilla.org/winhooks;1" #define NS_IWINDOWSHOOKS_CLASSNAME "Mozilla Windows Integration Hooks" + +// The key that is used to write the quick launch appname in the windows registry +#define NS_QUICKLAUNCH_RUN_KEY "Mozilla Quick Launch" %} diff --git a/xpfe/components/winhooks/nsWindowsHooks.cpp b/xpfe/components/winhooks/nsWindowsHooks.cpp index d68a5b3d66d..a365bea4430 100644 --- a/xpfe/components/winhooks/nsWindowsHooks.cpp +++ b/xpfe/components/winhooks/nsWindowsHooks.cpp @@ -36,7 +36,6 @@ #include "nsXPIDLString.h" #include "nsString.h" #include "nsMemory.h" -#include "nsIHttpProtocolHandler.h" #include "nsNetCID.h" // The order of these headers is important on Win2K because CreateDirectory // is |#undef|-ed in nsFileSpec.h, so we need to pull in windows.h for the @@ -54,7 +53,6 @@ static ProtocolRegistryEntry ftp( "ftp" ), chrome( "chrome" ), gopher( "gopher" ); -static NS_DEFINE_CID(kHttpHandlerCID, NS_HTTPPROTOCOLHANDLER_CID); const char *jpgExts[] = { ".jpg", ".jpeg", 0 }; const char *gifExts[] = { ".gif", 0 }; const char *pngExts[] = { ".png", 0 }; @@ -528,14 +526,7 @@ NS_IMETHODIMP nsWindowsHooks::IsStartupTurboEnabled(PRBool *_retval) HKEY key; LONG result = ::RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_QUERY_VALUE, &key ); if ( result == ERROR_SUCCESS ) { - nsresult rv; - nsCOMPtr http ( do_GetService( kHttpHandlerCID, &rv ) ); - if ( NS_FAILED( rv ) ) 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 ); + result = ::RegQueryValueEx( key, NS_QUICKLAUNCH_RUN_KEY, NULL, NULL, NULL, NULL ); ::RegCloseKey( key ); if ( result == ERROR_SUCCESS ) *_retval = PR_TRUE; @@ -560,13 +551,7 @@ NS_IMETHODIMP nsWindowsHooks::StartupTurboEnable() if ( rv ) { strcat( fileName, " -turbo" ); nsresult rv; - nsCOMPtr http ( do_GetService( kHttpHandlerCID, &rv ) ); - if ( NS_FAILED( rv ) ) return rv; - nsXPIDLCString appName; - http->GetAppName( getter_Copies( appName ) ); - nsCString fullValue; fullValue.Assign( appName ); - fullValue.Append( " Quick Launch" ); - ::RegSetValueEx( hKey, fullValue, 0, REG_SZ, ( LPBYTE )fileName, strlen( fileName ) ); + ::RegSetValueEx( hKey, NS_QUICKLAUNCH_RUN_KEY, 0, REG_SZ, ( LPBYTE )fileName, strlen( fileName ) ); } ::RegCloseKey( hKey ); return NS_OK; @@ -583,14 +568,7 @@ NS_IMETHODIMP nsWindowsHooks::StartupTurboDisable() LONG res = ::RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_SET_VALUE, &hKey ); if ( res != ERROR_SUCCESS ) return NS_OK; - nsresult rv; - nsCOMPtr http ( do_GetService( kHttpHandlerCID, &rv ) ); - if ( NS_FAILED( rv ) ) return rv; - nsXPIDLCString appName; - http->GetAppName( getter_Copies( appName ) ); - nsCString fullValue; fullValue.Assign( appName ); - fullValue.Append( " Quick Launch" ); - res = ::RegDeleteValue( hKey, fullValue ); + res = ::RegDeleteValue( hKey, NS_QUICKLAUNCH_RUN_KEY ); ::RegCloseKey( hKey ); return NS_OK; }