Bug 619518 - If a notification has no callback, use a toaster popup
authorFabrice Desré <fabrice@mozilla.com>
Thu, 27 Jan 2011 10:54:36 -0800
changeset 67316 0b28026cb1a911364889879cdc803ef569b43664
parent 67315 343f213b87e33a319399cba3cca9ef2710f5b150
child 67317 b3d86430b71227b9ca3f1fef75cbca7ca8905583
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs619518
Bug 619518 - If a notification has no callback, use a toaster popup
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.js
mobile/components/HelperAppDialog.js
mobile/components/Makefile.in
mobile/components/MobileComponents.manifest
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -1168,16 +1168,16 @@ var BrowserUI = {
         Browser.zoom(Util.isPortrait() ? 1 : -1);
         break;
       case "cmd_lockscreen":
       {
         let locked = Services.prefs.getBoolPref("toolkit.screen.lock");
         Services.prefs.setBoolPref("toolkit.screen.lock", !locked);
 
         let strings = Strings.browser;
-        let alerts = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
+        let alerts = Cc["@mozilla.org/toaster-alerts-service;1"].getService(Ci.nsIAlertsService);
         alerts.showAlertNotification(null, strings.GetStringFromName("alertLockScreen"),
                                      strings.GetStringFromName("alertLockScreen." + (!locked ? "locked" : "unlocked")), false, "", null);
         break;
       }
     }
   }
 };
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -382,17 +382,17 @@ var Browser = {
 
     // If some add-ons were disabled during during an application update, alert user
     if (Services.prefs.prefHasUserValue("extensions.disabledAddons")) {
       let addons = Services.prefs.getCharPref("extensions.disabledAddons").split(",");
       if (addons.length > 0) {
         let disabledStrings = Strings.browser.GetStringFromName("alertAddonsDisabled");
         let label = PluralForm.get(addons.length, disabledStrings).replace("#1", addons.length);
 
-        let alerts = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
+        let alerts = Cc["@mozilla.org/toaster-alerts-service;1"].getService(Ci.nsIAlertsService);
         alerts.showAlertNotification(URI_GENERIC_ICON_XPINSTALL, Strings.browser.GetStringFromName("alertAddons"),
                                      label, false, "", null);
       }
       Services.prefs.clearUserPref("extensions.disabledAddons");
     }
 
     messageManager.addMessageListener("Browser:ViewportMetadata", this);
     messageManager.addMessageListener("Browser:FormSubmit", this);
--- a/mobile/components/HelperAppDialog.js
+++ b/mobile/components/HelperAppDialog.js
@@ -236,17 +236,17 @@ HelperAppLauncherDialog.prototype = {
 
   isUsableDirectory: function hald_isUsableDirectory(aDirectory) {
     return aDirectory.exists() && aDirectory.isDirectory() && aDirectory.isWritable();
   },
 
   _notify: function hald_notify(aLauncher, aCallback) {
     let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
 
-    let notifier = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
+    let notifier = Cc[aCallback ? "@mozilla.org/alerts-service;1" : "@mozilla.org/toaster-alerts-service;1"].getService(Ci.nsIAlertsService);
     notifier.showAlertNotification(URI_GENERIC_ICON_DOWNLOAD,
                                    bundle.GetStringFromName("alertDownloads"),
                                    bundle.GetStringFromName("alertCantOpenDownload"),
                                    true, "", aCallback, "downloadopen-fail");
   }
 };
 
 const NSGetFactory = XPCOMUtils.generateNSGetFactory([HelperAppLauncherDialog]);
--- a/mobile/components/Makefile.in
+++ b/mobile/components/Makefile.in
@@ -75,18 +75,16 @@ EXTRA_COMPONENTS = \
         LoginManagerPrompter.js \
         BlocklistPrompt.js \
         $(NULL)
 
 ifdef MOZ_UPDATER
 EXTRA_COMPONENTS += UpdatePrompt.js
 endif
 
-ifndef ANDROID
 EXTRA_COMPONENTS += AlertsService.js
-endif
 
 ifneq (Android,$(OS_TARGET))
 DIRS =  phone \
         $(NULL)
 endif
 
 include $(topsrcdir)/config/rules.mk
--- a/mobile/components/MobileComponents.manifest
+++ b/mobile/components/MobileComponents.manifest
@@ -38,19 +38,23 @@ category app-startup BrowserStartup serv
 category agent-style-sheets browser-content-stylesheet chrome://browser/content/content.css
 category agent-style-sheets browser-cursor-stylesheet chrome://browser/content/cursor.css
 
 # ContentPermissionPrompt.js
 component {C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5} ContentPermissionPrompt.js
 contract @mozilla.org/content-permission/prompt;1 {C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5}
 
 # AlertsService.js
+component {fe33c107-82a4-41d6-8c64-5353267e04c9} AlertsService.js
+#ifndef ANDROID
+contract @mozilla.org/system-alerts-service;1 {fe33c107-82a4-41d6-8c64-5353267e04c9}
+#endif
 
-component {fe33c107-82a4-41d6-8c64-5353267e04c9} AlertsService.js
-contract @mozilla.org/system-alerts-service;1 {fe33c107-82a4-41d6-8c64-5353267e04c9}
+# ToasterAlertsService : alias to AlertsService
+contract @mozilla.org/toaster-alerts-service;1 {fe33c107-82a4-41d6-8c64-5353267e04c9}
 
 # XPIDialogService.js
 component {c1242012-27d8-477e-a0f1-0b098ffc329b} XPIDialogService.js
 contract @mozilla.org/addons/web-install-prompt;1 {c1242012-27d8-477e-a0f1-0b098ffc329b}
 
 # DownloadManagerUI.js
 component {93db15b1-b408-453e-9a2b-6619e168324a} DownloadManagerUI.js
 contract @mozilla.org/download-manager-ui;1 {93db15b1-b408-453e-9a2b-6619e168324a}