diff --git a/toolkit/components/alerts/src/mac/nsAlertsService.mm b/toolkit/components/alerts/src/mac/nsAlertsService.mm index 72b46c3c0e1f..21f106bebc94 100644 --- a/toolkit/components/alerts/src/mac/nsAlertsService.mm +++ b/toolkit/components/alerts/src/mac/nsAlertsService.mm @@ -149,13 +149,26 @@ nsAlertsService::Init() if ([GrowlApplicationBridge isGrowlInstalled] == NO) return NS_ERROR_SERVICE_NOT_AVAILABLE; + NS_ASSERTION([GrowlApplicationBridge growlDelegate] == nil, + "We already registered with Growl!"); + nsresult rv; nsCOMPtr os = do_GetService("@mozilla.org/observer-service;1", &rv); NS_ENSURE_SUCCESS(rv, rv); - rv = os->AddObserver(this, "final-ui-startup", PR_FALSE); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr notifications = new nsNotificationsList(); + + if (notifications) + (void)os->NotifyObservers(notifications, "before-growl-registration", nsnull); + + mDelegate = new GrowlDelegateWrapper(); + + if (notifications) + notifications->informController(mDelegate->delegate); + + // registers with Growl + [GrowlApplicationBridge setGrowlDelegate: mDelegate->delegate]; (void)os->AddObserver(this, DOM_WINDOW_DESTROYED_TOPIC, PR_FALSE); (void)os->AddObserver(this, "profile-before-change", PR_FALSE); @@ -227,32 +240,15 @@ nsAlertsService::Observe(nsISupports* aSubject, const char* aTopic, { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; - if (strcmp(aTopic, "final-ui-startup") == 0) { - NS_ASSERTION([GrowlApplicationBridge growlDelegate] == nil, - "We already registered with Growl!"); + if (!mDelegate) + return NS_OK; - nsRefPtr notifications = new nsNotificationsList(); - - if (notifications) { - nsCOMPtr os = - do_GetService("@mozilla.org/observer-service;1"); - (void)os->NotifyObservers(notifications, "before-growl-registration", nsnull); - } - - mDelegate = new GrowlDelegateWrapper(); - - if (notifications) - notifications->informController(mDelegate->delegate); - - // registers with Growl - [GrowlApplicationBridge setGrowlDelegate: mDelegate->delegate]; - } - else if (strcmp(aTopic, DOM_WINDOW_DESTROYED_TOPIC) == 0 && mDelegate) { + if (strcmp(aTopic, DOM_WINDOW_DESTROYED_TOPIC) == 0) { nsCOMPtr window(do_QueryInterface(aSubject)); if (window) [mDelegate->delegate forgetObserversForWindow:window]; } - else if (strcmp(aTopic, "profile-before-change") == 0 && mDelegate) { + else if (strcmp(aTopic, "profile-before-change") == 0) { [mDelegate->delegate forgetObservers]; } diff --git a/toolkit/components/alerts/src/mac/nsAlertsServiceModule.cpp b/toolkit/components/alerts/src/mac/nsAlertsServiceModule.cpp index f5db7ba2e807..277658215cc8 100644 --- a/toolkit/components/alerts/src/mac/nsAlertsServiceModule.cpp +++ b/toolkit/components/alerts/src/mac/nsAlertsServiceModule.cpp @@ -45,56 +45,12 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAlertsService, Init) -static -NS_METHOD -nsAlertsServiceRegister(nsIComponentManager* aCompMgr, - nsIFile* aPath, - const char* registryLocation, - const char* componentType, - const nsModuleComponentInfo* info) -{ - nsresult rv; - - nsCOMPtr catman = - do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - char* prev = nsnull; - rv = catman->AddCategoryEntry("app-startup", "nsAlertsService", - "service," NS_ALERTSERVICE_CONTRACTID, PR_TRUE, - PR_TRUE, &prev); - if (prev) - nsMemory::Free(prev); - - return rv; -} - -static -NS_METHOD -nsAlertsServiceUnregister(nsIComponentManager* aCompMgr, - nsIFile* aPath, - const char* registryLocation, - const nsModuleComponentInfo* info) -{ - nsresult rv; - - nsCOMPtr catman = - do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - rv = catman->DeleteCategoryEntry("app-startup", "nsAlertsService", PR_TRUE); - - return rv; -} - static const nsModuleComponentInfo components[] = { { "Alerts Service", NS_ALERTSSERVICE_CID, NS_ALERTSERVICE_CONTRACTID, - nsAlertsServiceConstructor, - nsAlertsServiceRegister, - nsAlertsServiceUnregister }, + nsAlertsServiceConstructor }, }; NS_IMPL_NSGETMODULE(nsAlertsServiceModule, components)