mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
b=506470, Mac alerts service should not initialize Growl on app startup; r=sdwilsh
This commit is contained in:
parent
58486359e8
commit
a57b68f667
@ -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<nsIObserverService> 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<nsNotificationsList> 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<nsNotificationsList> notifications = new nsNotificationsList();
|
||||
|
||||
if (notifications) {
|
||||
nsCOMPtr<nsIObserverService> 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<nsIDOMWindow> 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];
|
||||
}
|
||||
|
||||
|
@ -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<nsICategoryManager> 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<nsICategoryManager> 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)
|
||||
|
Loading…
Reference in New Issue
Block a user