diff --git a/mozilla/browser/base/content/browser.js b/mozilla/browser/base/content/browser.js index e07324f3c76..2011bba4c85 100644 --- a/mozilla/browser/base/content/browser.js +++ b/mozilla/browser/base/content/browser.js @@ -2632,7 +2632,6 @@ var DownloadsButtonDNDObserver = { saveURL(url, name, null, true, true); } }, - getSupportedFlavours: function () { var flavourSet = new FlavourSet(); @@ -5409,7 +5408,7 @@ var MailIntegration = { readNews: function () { - var shell = window.getShellService(); + var shell = getShellService(); if (shell) shell.openPreferredApplication(Components.interfaces.nsIShellService.APPLICATION_NEWS); }, diff --git a/mozilla/browser/base/content/browser.xul b/mozilla/browser/base/content/browser.xul index 34704153a3c..bd70a051d0d 100644 --- a/mozilla/browser/base/content/browser.xul +++ b/mozilla/browser/base/content/browser.xul @@ -20,7 +20,7 @@ # Rights Reserved. # # Contributor(s): -# Blake Ross +# Blake Ross # David Hyatt # Joe Hewitt # Pierre Chanial diff --git a/mozilla/browser/components/build/nsModule.cpp b/mozilla/browser/components/build/nsModule.cpp index 4a5633d9ec0..2b91a50b5d6 100644 --- a/mozilla/browser/components/build/nsModule.cpp +++ b/mozilla/browser/components/build/nsModule.cpp @@ -99,7 +99,8 @@ static const nsModuleComponentInfo components[] = { "Browser Shell Shervice", NS_SHELLSERVICE_CID, NS_SHELLSERVICE_CONTRACTID, - nsWindowsShellServiceConstructor }, + nsWindowsShellServiceConstructor, + nsWindowsShellService::Register }, #elif defined (XP_MACOSX) { "Browser Shell Shervice", diff --git a/mozilla/browser/components/shell/public/nsIWindowsShellService.idl b/mozilla/browser/components/shell/public/nsIWindowsShellService.idl index 9d9e8370108..232884292a2 100644 --- a/mozilla/browser/components/shell/public/nsIWindowsShellService.idl +++ b/mozilla/browser/components/shell/public/nsIWindowsShellService.idl @@ -77,5 +77,7 @@ interface nsIWindowsShellService : nsIShellService */ string getRegistryEntry(in long aHKeyConstant, in string aSubKeyName, in string aValueName); + void registerDDESupport(); + void unregisterDDESupport(); }; diff --git a/mozilla/browser/components/shell/src/Makefile.in b/mozilla/browser/components/shell/src/Makefile.in index 3a8d9ce4b47..f0634bc01ab 100644 --- a/mozilla/browser/components/shell/src/Makefile.in +++ b/mozilla/browser/components/shell/src/Makefile.in @@ -40,6 +40,7 @@ REQUIRES = \ layout \ content \ widget \ + browsercomps \ imglib2 \ gfx \ locale \ diff --git a/mozilla/browser/components/shell/src/nsWindowsShellService.cpp b/mozilla/browser/components/shell/src/nsWindowsShellService.cpp index 4f7d4218dae..c5876a13d47 100644 --- a/mozilla/browser/components/shell/src/nsWindowsShellService.cpp +++ b/mozilla/browser/components/shell/src/nsWindowsShellService.cpp @@ -55,6 +55,9 @@ #include "nsNetUtil.h" #include "nsShellService.h" #include "nsWindowsShellService.h" +#include "nsIObserverService.h" +#include "nsICategoryManager.h" +#include "nsBrowserCompsCID.h" #define MOZ_HWND_BROADCAST_MSG_TIMEOUT 5000 #define MOZ_BACKUP_REGISTRY "SOFTWARE\\Mozilla\\Desktop" @@ -69,7 +72,7 @@ #define REG_FAILED(val) \ (val != ERROR_SUCCESS) -NS_IMPL_ISUPPORTS2(nsWindowsShellService, nsIWindowsShellService, nsIShellService) +NS_IMPL_ISUPPORTS3(nsWindowsShellService, nsIWindowsShellService, nsIShellService, nsIObserver) static nsresult OpenUserKeyForReading(HKEY aStartKey, const char* aKeyName, HKEY* aKey) @@ -230,28 +233,6 @@ static SETTING gSettings[] = { { MAKE_KEY_NAME2(CLS, "CHROME", DI), "", VAL_ICON, PATH_SUBSTITUTION | NON_ESSENTIAL }, { MAKE_KEY_NAME2(CLS, "CHROME", SOP), "", VAL_OPEN, PATH_SUBSTITUTION | NON_ESSENTIAL }, - // DDE settings - { MAKE_KEY_NAME2(CLS, "HTTP", DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "HTTP", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "HTTP", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "HTTP", DDE, "ifexec"), "", "StartDDE", NO_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, "HTTPS", DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "HTTPS", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "HTTPS", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "HTTPS", DDE, "ifexec"), "", "StartDDE", NO_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, "FTP", DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "FTP", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "FTP", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION }, - { MAKE_KEY_NAME3(CLS, "FTP", DDE, "ifexec"), "", "StartDDE", NO_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, "GOPHER", DDE), "", DDE_COMMAND, NO_SUBSTITUTION | NON_ESSENTIAL }, - { MAKE_KEY_NAME3(CLS, "GOPHER", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION | NON_ESSENTIAL }, - { MAKE_KEY_NAME3(CLS, "GOPHER", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION | NON_ESSENTIAL }, - { MAKE_KEY_NAME3(CLS, "GOPHER", DDE, "ifexec"), "", "StartDDE", NO_SUBSTITUTION }, - { MAKE_KEY_NAME2(CLS, "CHROME", DDE), "", DDE_COMMAND, NO_SUBSTITUTION | NON_ESSENTIAL }, - { MAKE_KEY_NAME3(CLS, "CHROME", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION | NON_ESSENTIAL }, - { MAKE_KEY_NAME3(CLS, "CHROME", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION | NON_ESSENTIAL }, - { MAKE_KEY_NAME3(CLS, "CHROME", DDE, "ifexec"), "", "StartDDE", NO_SUBSTITUTION }, - // Windows XP Start Menu { MAKE_KEY_NAME2(SMI, "%APPEXE%", DI), "", @@ -271,6 +252,67 @@ static SETTING gSettings[] = { // firefox.exe\shell\properties (default) REG_SZ Firefox &Options }; +static SETTING gDDESettings[] = { + { MAKE_KEY_NAME2(CLS, "HTTP", DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, + { MAKE_KEY_NAME3(CLS, "HTTP", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, + { MAKE_KEY_NAME3(CLS, "HTTP", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION }, + { MAKE_KEY_NAME2(CLS, "HTTPS", DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, + { MAKE_KEY_NAME3(CLS, "HTTPS", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, + { MAKE_KEY_NAME3(CLS, "HTTPS", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION }, + { MAKE_KEY_NAME2(CLS, "FTP", DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, + { MAKE_KEY_NAME3(CLS, "FTP", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, + { MAKE_KEY_NAME3(CLS, "FTP", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION }, + { MAKE_KEY_NAME2(CLS, "GOPHER", DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, + { MAKE_KEY_NAME3(CLS, "GOPHER", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, + { MAKE_KEY_NAME3(CLS, "GOPHER", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION }, + { MAKE_KEY_NAME2(CLS, "CHROME", DDE), "", DDE_COMMAND, NO_SUBSTITUTION }, + { MAKE_KEY_NAME3(CLS, "CHROME", DDE, "Application"), "", DDE_NAME, NO_SUBSTITUTION }, + { MAKE_KEY_NAME3(CLS, "CHROME", DDE, "Topic"), "", "WWW_OpenURL", NO_SUBSTITUTION } +}; + +NS_IMETHODIMP +nsWindowsShellService::Register(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, + const char *componentType, const nsModuleComponentInfo *info) +{ + nsresult rv; + nsCOMPtr catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); + if (NS_FAILED(rv)) return rv; + + return catman->AddCategoryEntry("app-startup", "Windows Shell Service", "service," NS_SHELLSERVICE_CONTRACTID, PR_TRUE, PR_TRUE, nsnull); +} + +nsWindowsShellService::nsWindowsShellService() +:mCheckedThisSession(PR_FALSE) +{ + nsCOMPtr obsServ (do_GetService("@mozilla.org/observer-service;1")); + obsServ->AddObserver(this, "quit-application", PR_FALSE); +} + +NS_IMETHODIMP +nsWindowsShellService::RegisterDDESupport() +{ + SETTING* end = gDDESettings + sizeof(gDDESettings)/sizeof(SETTING); + for (SETTING* settings = gDDESettings; settings < end; ++settings) { + nsCAutoString key(settings->keyName); + nsCAutoString data(settings->valueData); + + SetRegKey(key.get(), settings->valueName, data.get(), + PR_FALSE, 0, PR_TRUE, PR_TRUE); + } + return NS_OK; +} + +NS_IMETHODIMP +nsWindowsShellService::UnregisterDDESupport() +{ + DeleteRegKey(HKEY_CLASSES_ROOT, "HTTP\\shell\\open\\ddeexec"); + DeleteRegKey(HKEY_CLASSES_ROOT, "HTTPS\\shell\\open\\ddeexec"); + DeleteRegKey(HKEY_CLASSES_ROOT, "FTP\\shell\\open\\ddeexec"); + DeleteRegKey(HKEY_CLASSES_ROOT, "CHROME\\shell\\open\\ddeexec"); + DeleteRegKey(HKEY_CLASSES_ROOT, "GOPHER\\shell\\open\\ddeexec"); + return NS_OK; +} + NS_IMETHODIMP nsWindowsShellService::IsDefaultBrowser(PRBool aStartupCheck, PRBool* aIsDefaultBrowser) { @@ -408,6 +450,9 @@ nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUs SetRegKey(key2.get(), "", NS_ConvertUCS2toUTF8(optionsTitle).get(), PR_TRUE, backupKey, aClaimAllTypes, aForAllUsers); + // We need to reregister DDE support + RegisterDDESupport(); + // Refresh the Shell ::SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, NULL, (LPARAM)"SOFTWARE\\Clients\\StartMenuInternet", @@ -453,6 +498,43 @@ nsWindowsShellService::RestoreFileSettings(PRBool aForAllUsers) return NS_OK; } +// Utility function to delete a registry subkey. +DWORD +nsWindowsShellService::DeleteRegKey(HKEY baseKey, const char *keyName) +{ + // Make sure input subkey isn't null. + if (!keyName || !::strlen(keyName)) + return ERROR_BADKEY; + + DWORD rc; + // Open subkey. + HKEY key; + rc = ::RegOpenKeyEx(baseKey, keyName, 0, KEY_ENUMERATE_SUB_KEYS | DELETE, &key); + + // Continue till we get an error or are done. + while (rc == ERROR_SUCCESS) { + char subkeyName[_MAX_PATH]; + DWORD len = sizeof subkeyName; + // Get first subkey name. Note that we always get the + // first one, then delete it. So we need to get + // the first one next time, also. + rc = ::RegEnumKeyEx(key, 0, subkeyName, &len, 0, 0, 0, 0); + if (rc == ERROR_NO_MORE_ITEMS) { + // No more subkeys. Delete the main one. + rc = ::RegDeleteKey(baseKey, keyName); + break; + } + if (rc == ERROR_SUCCESS) { + // Another subkey, delete it, recursively. + rc = DeleteRegKey(key, subkeyName); + } + } + + // Close the key we opened. + ::RegCloseKey(key); + return rc; +} + void nsWindowsShellService::SetRegKey(const char* aKeyName, const char* aValueName, const char* aValue, PRBool aBackup, @@ -913,4 +995,20 @@ nsWindowsShellService::GetRegistryEntry(PRInt32 aHKEYConstant, return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } +NS_IMETHODIMP +nsWindowsShellService::Observe(nsISupports* aObject, const char* aTopic, const PRUnichar* aMessage) +{ + PRBool isDefault; + IsDefaultBrowser(PR_TRUE, &isDefault); + if (!isDefault) + return NS_OK; + + if (!nsCRT::strcmp("app-startup", aTopic)) + return RegisterDDESupport(); + + if (!nsCRT::strcmp("quit-application", aTopic)) + return UnregisterDDESupport(); + + return NS_OK; +} diff --git a/mozilla/browser/components/shell/src/nsWindowsShellService.h b/mozilla/browser/components/shell/src/nsWindowsShellService.h index b1ee50b88b3..8075976d696 100644 --- a/mozilla/browser/components/shell/src/nsWindowsShellService.h +++ b/mozilla/browser/components/shell/src/nsWindowsShellService.h @@ -41,25 +41,32 @@ #include "nscore.h" #include "nsIWindowsShellService.h" +#include "nsIObserver.h" +#include "nsIGenericFactory.h" #include -class nsWindowsShellService : public nsIWindowsShellService +class nsWindowsShellService : public nsIWindowsShellService, + public nsIObserver { public: - nsWindowsShellService() : mCheckedThisSession(PR_FALSE) {}; + nsWindowsShellService(); virtual ~nsWindowsShellService() {}; NS_DECL_ISUPPORTS NS_DECL_NSISHELLSERVICE NS_DECL_NSIWINDOWSSHELLSERVICE + NS_DECL_NSIOBSERVER + + static NS_METHOD Register(nsIComponentManager *aCompMgr, nsIFile *aPath, const char *registryLocation, + const char *componentType, const nsModuleComponentInfo *info); protected: PRBool GetMailAccountKey(HKEY* aResult); void SetRegKey(const char* aKeyName, const char* aValueName, const char* aValue, PRBool aBackup, HKEY aBackupKey, PRBool aReplaceExisting, PRBool aForAllUsers); - + DWORD DeleteRegKey(HKEY baseKey, const char *keyName); private: PRBool mCheckedThisSession; }; diff --git a/mozilla/toolkit/xre/nsNativeAppSupportWin.cpp b/mozilla/toolkit/xre/nsNativeAppSupportWin.cpp index 2565c64d039..9dc66261efe 100644 --- a/mozilla/toolkit/xre/nsNativeAppSupportWin.cpp +++ b/mozilla/toolkit/xre/nsNativeAppSupportWin.cpp @@ -65,9 +65,6 @@ #include "nsNetCID.h" #include "nsIObserverService.h" #include "nsXPCOM.h" -#ifdef MOZ_PHOENIX -#include "nsIShellService.h" -#endif // These are needed to load a URL in a browser window. #include "nsIDOMLocation.h" @@ -651,64 +648,6 @@ nsNativeAppSupportWin::FindTopic( HSZ topic ) { return -1; } -// Utility function that determines if we're handling http Internet shortcuts. -static PRBool isDefaultBrowser() -{ -#ifdef MOZ_PHOENIX - nsCOMPtr shell(do_GetService("@mozilla.org/browser/shell-service;1")); - PRBool isDefault; - shell->IsDefaultBrowser(PR_FALSE, &isDefault); - return isDefault; -#else - return FALSE; -#endif -} - -// Utility function to delete a registry subkey. -static DWORD deleteKey( HKEY baseKey, const char *keyName ) { - // Make sure input subkey isn't null. - DWORD rc; - if ( keyName && ::strlen(keyName) ) { - // Open subkey. - HKEY key; - rc = ::RegOpenKeyEx( baseKey, - keyName, - 0, - KEY_ENUMERATE_SUB_KEYS | DELETE, - &key ); - // Continue till we get an error or are done. - while ( rc == ERROR_SUCCESS ) { - char subkeyName[_MAX_PATH]; - DWORD len = sizeof subkeyName; - // Get first subkey name. Note that we always get the - // first one, then delete it. So we need to get - // the first one next time, also. - rc = ::RegEnumKeyEx( key, - 0, - subkeyName, - &len, - 0, - 0, - 0, - 0 ); - if ( rc == ERROR_NO_MORE_ITEMS ) { - // No more subkeys. Delete the main one. - rc = ::RegDeleteKey( baseKey, keyName ); - break; - } else if ( rc == ERROR_SUCCESS ) { - // Another subkey, delete it, recursively. - rc = deleteKey( key, subkeyName ); - } - } - // Close the key we opened. - ::RegCloseKey( key ); - } else { - rc = ERROR_BADKEY; - } - return rc; -} - - // Start DDE server. // // This used to be the Start() method when we were using DDE as the