From edb10a6aacbfe22c17517922a72ef6b272b84d6a Mon Sep 17 00:00:00 2001 From: "henry.jia%sun.com" Date: Tue, 6 Aug 2002 05:11:23 +0000 Subject: [PATCH] 2nd patch for bug 158080 Description: replace the hardcode of "@mozilla.org/embedcomp/window-watcher;1" with NS_WINDOWWATCHER_CONTRACTID Patch by Henry.Jia@sun.com r=anto, sr=alecf --- security/manager/ssl/src/nsSDR.cpp | 2 +- webshell/tests/viewer/nsViewerApp.cpp | 2 +- xpfe/appshell/src/nsAppShellService.cpp | 4 ++-- xpfe/appshell/src/nsCommandLineServiceMac.cpp | 2 +- xpfe/appshell/src/nsWindowMediator.cpp | 2 +- xpfe/appshell/src/nsXULWindow.cpp | 4 ++-- xpfe/bootstrap/nsAppRunner.cpp | 6 ++---- xpfe/bootstrap/nsNativeAppSupportOS2.cpp | 4 ++-- xpfe/bootstrap/nsNativeAppSupportWin.cpp | 4 ++-- xpfe/browser/src/nsBrowserInstance.cpp | 2 +- xpfe/components/alerts/src/nsAlertsService.cpp | 2 +- xpfe/components/bookmarks/src/nsBookmarksService.cpp | 4 ++-- xpfe/components/directory/nsDirectoryViewer.cpp | 4 ++-- xpfe/components/download-manager/src/nsDownloadManager.cpp | 2 +- xpfe/components/intl/nsFontPackageHandler.cpp | 2 +- xpfe/components/startup/src/nsCommandLineServiceMac.cpp | 2 +- xpfe/components/xremote/src/XRemoteService.cpp | 2 +- xpinstall/src/nsXPInstallManager.cpp | 2 +- 18 files changed, 25 insertions(+), 27 deletions(-) diff --git a/security/manager/ssl/src/nsSDR.cpp b/security/manager/ssl/src/nsSDR.cpp index e87e1402f42..9902acc635d 100644 --- a/security/manager/ssl/src/nsSDR.cpp +++ b/security/manager/ssl/src/nsSDR.cpp @@ -79,7 +79,7 @@ NS_IMETHODIMP nsSDRContext::GetInterface(const nsIID & uuid, void * *result) if (!proxyman) return NS_ERROR_FAILURE; nsCOMPtr prompter; - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); if (wwatch) { wwatch->GetNewPrompter(0, getter_AddRefs(prompter)); if (prompter) { diff --git a/webshell/tests/viewer/nsViewerApp.cpp b/webshell/tests/viewer/nsViewerApp.cpp index a86bc03b575..e459a128114 100644 --- a/webshell/tests/viewer/nsViewerApp.cpp +++ b/webshell/tests/viewer/nsViewerApp.cpp @@ -337,7 +337,7 @@ nsViewerApp::InitializeWindowCreator() if (creatorCallback) { nsCOMPtr windowCreator(dont_QueryInterface(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback))); if (windowCreator) { - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); if (wwatch) { wwatch->SetWindowCreator(windowCreator); return NS_OK; diff --git a/xpfe/appshell/src/nsAppShellService.cpp b/xpfe/appshell/src/nsAppShellService.cpp index 73b62585750..7b88398ec97 100644 --- a/xpfe/appshell/src/nsAppShellService.cpp +++ b/xpfe/appshell/src/nsAppShellService.cpp @@ -54,6 +54,7 @@ #include "nsIAppShell.h" #include "nsIWidget.h" +#include "nsIWindowWatcher.h" #include "nsIDOMWindowInternal.h" #include "nsIWebShellWindow.h" #include "nsWebShellWindow.h" @@ -95,7 +96,6 @@ static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID); static NS_DEFINE_CID(kXPConnectCID, NS_XPCONNECT_CID); -#define sWindowWatcherContractID "@mozilla.org/embedcomp/window-watcher;1" #define gEQActivatedNotification "nsIEventQueueActivated" #define gEQDestroyedNotification "nsIEventQueueDestroyed" #define gSkinSelectedTopic "skin-selected" @@ -178,7 +178,7 @@ nsAppShellService::Initialize( nsICmdLineService *aCmdLineService, // enable window mediation (and fail if we can't get the mediator) mWindowMediator = do_GetService(kWindowMediatorCID, &rv); - mWindowWatcher = do_GetService(sWindowWatcherContractID); + mWindowWatcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID); done: return rv; diff --git a/xpfe/appshell/src/nsCommandLineServiceMac.cpp b/xpfe/appshell/src/nsCommandLineServiceMac.cpp index acabe1deee4..d084dc4e6c1 100644 --- a/xpfe/appshell/src/nsCommandLineServiceMac.cpp +++ b/xpfe/appshell/src/nsCommandLineServiceMac.cpp @@ -321,7 +321,7 @@ OSErr nsMacCommandLine::HandlePrintOneDoc(const FSSpec& inFileSpec, OSType fileT nsresult nsMacCommandLine::OpenWindow(const char *chrome, const PRUnichar *url) //---------------------------------------------------------------------------------------- { - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr urlWrapper(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); if (!wwatch || !urlWrapper) return NS_ERROR_FAILURE; diff --git a/xpfe/appshell/src/nsWindowMediator.cpp b/xpfe/appshell/src/nsWindowMediator.cpp index 626412560f5..22f532bd9e6 100644 --- a/xpfe/appshell/src/nsWindowMediator.cpp +++ b/xpfe/appshell/src/nsWindowMediator.cpp @@ -670,7 +670,7 @@ nsWindowMediator::Init() return NS_ERROR_OUT_OF_MEMORY; } - mWatcher = do_GetService("@mozilla.org/embedcomp/window-watcher;1", &rv); + mWatcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; diff --git a/xpfe/appshell/src/nsXULWindow.cpp b/xpfe/appshell/src/nsXULWindow.cpp index 0729c3b556e..07cdc23a092 100644 --- a/xpfe/appshell/src/nsXULWindow.cpp +++ b/xpfe/appshell/src/nsXULWindow.cpp @@ -770,7 +770,7 @@ NS_IMETHODIMP nsXULWindow::EnsurePrompter() nsCOMPtr ourWindow; nsresult rv = GetWindowDOMWindow(getter_AddRefs(ourWindow)); if (NS_SUCCEEDED(rv)) { - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); if (wwatch) wwatch->GetNewPrompter(ourWindow, getter_AddRefs(mPrompter)); } @@ -785,7 +785,7 @@ NS_IMETHODIMP nsXULWindow::EnsureAuthPrompter() nsCOMPtr ourWindow; nsresult rv = GetWindowDOMWindow(getter_AddRefs(ourWindow)); if (NS_SUCCEEDED(rv)) { - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); if (wwatch) wwatch->GetNewAuthPrompter(ourWindow, getter_AddRefs(mAuthPrompter)); } diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index 643a3ba0f4f..9ed2f1eca5b 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -334,8 +334,6 @@ static void InitializeMacOSXApp(int argc, char* argv[]) /* Define Class IDs */ static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID); -static const char sWatcherServiceContractID[] = "@mozilla.org/embedcomp/window-watcher;1"; - #include "nsNativeAppSupport.h" @@ -456,7 +454,7 @@ static nsresult OpenWindow(const nsAFlatCString& aChromeURL, aWidth, aHeight); #endif /* DEBUG_CMD_LINE */ - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr sarg(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); if (!wwatch || !sarg) return NS_ERROR_FAILURE; @@ -1182,7 +1180,7 @@ static nsresult InitializeWindowCreator() nsCOMPtr windowCreator(NS_STATIC_CAST(nsIWindowCreator *, creatorCallback)); if (windowCreator) { - nsCOMPtr wwatch(do_GetService(sWatcherServiceContractID)); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); if (wwatch) { wwatch->SetWindowCreator(windowCreator); return NS_OK; diff --git a/xpfe/bootstrap/nsNativeAppSupportOS2.cpp b/xpfe/bootstrap/nsNativeAppSupportOS2.cpp index 6e89bc82076..e2dea75307f 100644 --- a/xpfe/bootstrap/nsNativeAppSupportOS2.cpp +++ b/xpfe/bootstrap/nsNativeAppSupportOS2.cpp @@ -1909,7 +1909,7 @@ nsNativeAppSupportOS2::OpenWindow( const char*urlstr, const char *args ) { nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr sarg(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID)); if (sarg) sarg->SetData(args); @@ -2188,7 +2188,7 @@ nsNativeAppSupportOS2::StartServerMode() { #endif /* DOWENEED */ // Create some of the objects we'll need. - nsCOMPtr ww(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr ww(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr arg1(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); nsCOMPtr arg2(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); if ( !ww || !arg1 || !arg2 ) { diff --git a/xpfe/bootstrap/nsNativeAppSupportWin.cpp b/xpfe/bootstrap/nsNativeAppSupportWin.cpp index c19fb3f136e..a5d82391b67 100644 --- a/xpfe/bootstrap/nsNativeAppSupportWin.cpp +++ b/xpfe/bootstrap/nsNativeAppSupportWin.cpp @@ -2088,7 +2088,7 @@ nsNativeAppSupportWin::OpenWindow( const char*urlstr, const char *args ) { nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr sarg(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID)); if (sarg) sarg->SetData(args); @@ -2449,7 +2449,7 @@ nsNativeAppSupportWin::StartServerMode() { // so thing work alright. // Create some of the objects we'll need. - nsCOMPtr ww(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr ww(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr arg1(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); nsCOMPtr arg2(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); if ( !ww || !arg1 || !arg2 ) { diff --git a/xpfe/browser/src/nsBrowserInstance.cpp b/xpfe/browser/src/nsBrowserInstance.cpp index 63342b99d90..e331cc27e5a 100644 --- a/xpfe/browser/src/nsBrowserInstance.cpp +++ b/xpfe/browser/src/nsBrowserInstance.cpp @@ -831,7 +831,7 @@ NS_IMETHODIMP nsBrowserContentHandler::HandleContent(const char * aContentType, nsCAutoString spec; uri->GetSpec(spec); - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); if (wwatch) { nsCOMPtr newWindow; wwatch->OpenWindow(parentWindow, spec.get(), "", 0, 0, diff --git a/xpfe/components/alerts/src/nsAlertsService.cpp b/xpfe/components/alerts/src/nsAlertsService.cpp index 8981d61be55..88c08077d9d 100644 --- a/xpfe/components/alerts/src/nsAlertsService.cpp +++ b/xpfe/components/alerts/src/nsAlertsService.cpp @@ -66,7 +66,7 @@ NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const char * aImageUrl, con const PRUnichar * aAlertCookie, nsIAlertListener * aAlertListener) { - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr newWindow; nsresult rv; diff --git a/xpfe/components/bookmarks/src/nsBookmarksService.cpp b/xpfe/components/bookmarks/src/nsBookmarksService.cpp index 67a8f152319..a6fc8d0e032 100644 --- a/xpfe/components/bookmarks/src/nsBookmarksService.cpp +++ b/xpfe/components/bookmarks/src/nsBookmarksService.cpp @@ -2438,7 +2438,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt, interfaces->GetInterface(NS_GET_IID(nsIPrompt), getter_AddRefs(prompter)); if (!prompter) { - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); if (wwatch) wwatch->GetNewPrompter(0, getter_AddRefs(prompter)); } @@ -2511,7 +2511,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt, { if (NS_SUCCEEDED(rv)) { - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); if (wwatch) { nsCOMPtr newWindow; diff --git a/xpfe/components/directory/nsDirectoryViewer.cpp b/xpfe/components/directory/nsDirectoryViewer.cpp index 5de3a4edc0b..bb3d37088c9 100644 --- a/xpfe/components/directory/nsDirectoryViewer.cpp +++ b/xpfe/components/directory/nsDirectoryViewer.cpp @@ -139,7 +139,7 @@ nsHTTPIndex::GetInterface(const nsIID &anIID, void **aResult ) if (!aDOMWindow) return NS_ERROR_NO_INTERFACE; - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); return wwatch->GetNewPrompter(aDOMWindow, (nsIPrompt**)aResult); } @@ -153,7 +153,7 @@ nsHTTPIndex::GetInterface(const nsIID &anIID, void **aResult ) if (!aDOMWindow) return NS_ERROR_NO_INTERFACE; - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); return wwatch->GetNewAuthPrompter(aDOMWindow, (nsIAuthPrompt**)aResult); } diff --git a/xpfe/components/download-manager/src/nsDownloadManager.cpp b/xpfe/components/download-manager/src/nsDownloadManager.cpp index a3a981f7926..8241a827214 100644 --- a/xpfe/components/download-manager/src/nsDownloadManager.cpp +++ b/xpfe/components/download-manager/src/nsDownloadManager.cpp @@ -723,7 +723,7 @@ nsDownloadManager::Open(nsIDOMWindow* aParent, nsIDownload* aDownload) // if we ever have the capability to display the UI of third party dl managers, // we'll open their UI here instead. - nsCOMPtr ww = do_GetService("@mozilla.org/embedcomp/window-watcher;1", &rv); + nsCOMPtr ww = do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; // pass the datasource to the window diff --git a/xpfe/components/intl/nsFontPackageHandler.cpp b/xpfe/components/intl/nsFontPackageHandler.cpp index 5d92a2e7b5f..4e60814c433 100644 --- a/xpfe/components/intl/nsFontPackageHandler.cpp +++ b/xpfe/components/intl/nsFontPackageHandler.cpp @@ -127,7 +127,7 @@ NS_IMETHODIMP nsFontPackageHandler::NeedFontPackage(const char *aFontPackID) if (NS_FAILED(rv)) return rv; - nsCOMPtr windowWatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr windowWatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); NS_ENSURE_TRUE(windowWatch, NS_ERROR_FAILURE); nsCOMPtr dialog; diff --git a/xpfe/components/startup/src/nsCommandLineServiceMac.cpp b/xpfe/components/startup/src/nsCommandLineServiceMac.cpp index acabe1deee4..d084dc4e6c1 100644 --- a/xpfe/components/startup/src/nsCommandLineServiceMac.cpp +++ b/xpfe/components/startup/src/nsCommandLineServiceMac.cpp @@ -321,7 +321,7 @@ OSErr nsMacCommandLine::HandlePrintOneDoc(const FSSpec& inFileSpec, OSType fileT nsresult nsMacCommandLine::OpenWindow(const char *chrome, const PRUnichar *url) //---------------------------------------------------------------------------------------- { - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr urlWrapper(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); if (!wwatch || !urlWrapper) return NS_ERROR_FAILURE; diff --git a/xpfe/components/xremote/src/XRemoteService.cpp b/xpfe/components/xremote/src/XRemoteService.cpp index 841357f0ccc..d9868284557 100644 --- a/xpfe/components/xremote/src/XRemoteService.cpp +++ b/xpfe/components/xremote/src/XRemoteService.cpp @@ -538,7 +538,7 @@ XRemoteService::OpenChromeWindow(nsIDOMWindow *aParent, nsIDOMWindow **_retval) { nsCOMPtr watcher; - watcher = do_GetService("@mozilla.org/embedcomp/window-watcher;1"); + watcher = do_GetService(NS_WINDOWWATCHER_CONTRACTID); if (!watcher) return NS_ERROR_FAILURE; diff --git a/xpinstall/src/nsXPInstallManager.cpp b/xpinstall/src/nsXPInstallManager.cpp index 4534df208d3..a99c8f5d941 100644 --- a/xpinstall/src/nsXPInstallManager.cpp +++ b/xpinstall/src/nsXPInstallManager.cpp @@ -369,7 +369,7 @@ nsXPInstallManager::OpenProgressDialog(const PRUnichar **aPackageList, PRUint32 params->AppendElement(callbackwrap); // --- open the window - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1", &rv)); + nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv)); if (wwatch) { nsCOMPtr newWindow; rv = wwatch->OpenWindow(0,