Bug 1258328 - HelperAppDialog: Replace deprecated toast API with Snackbars.jsm. r=grisha
authorSebastian Kaspari <s.kaspari@gmail.com>
Tue, 29 Mar 2016 13:18:12 +0200
changeset 290788 31071bd61e48933cd2b142701e5324d1830463f3
parent 290787 84008247ec173492c40caa6122ca121b4defe4e4
child 290789 b4941d71b4df56c6f49c6f176cd65bf8af4b0e32
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgrisha
bugs1258328
milestone48.0a1
Bug 1258328 - HelperAppDialog: Replace deprecated toast API with Snackbars.jsm. r=grisha MozReview-Commit-ID: 2WPNo9iGHu4
mobile/android/components/HelperAppDialog.js
--- a/mobile/android/components/HelperAppDialog.js
+++ b/mobile/android/components/HelperAppDialog.js
@@ -22,23 +22,22 @@ Cu.import("resource://gre/modules/FileUt
 Cu.import("resource://gre/modules/HelperApps.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/NetUtil.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "RuntimePermissions", "resource://gre/modules/RuntimePermissions.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Messaging", "resource://gre/modules/Messaging.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm");
 
 // -----------------------------------------------------------------------
 // HelperApp Launcher Dialog
 // -----------------------------------------------------------------------
 
-XPCOMUtils.defineLazyModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm");
-
 XPCOMUtils.defineLazyGetter(this, "ContentAreaUtils", function() {
   let ContentAreaUtils = {};
   Services.scriptloader.loadSubScript("chrome://global/content/contentAreaUtils.js", ContentAreaUtils);
   return ContentAreaUtils;
 });
 
 function HelperAppLauncherDialog() { }
 
@@ -219,27 +218,22 @@ HelperAppLauncherDialog.prototype = {
         this._setPreferredApp(aLauncher, apps[data.icongrid0]);
       }
     });
   },
 
   _refuseDownload: function(aLauncher) {
     aLauncher.cancel(Cr.NS_BINDING_ABORTED);
 
-    let win = this.getNativeWindow();
-    if (!win) {
-      // Oops.
-      Services.console.logStringMessage("Refusing download, but can't show a toast.");
-      return;
-    }
+    Services.console.logStringMessage("Refusing download of non-downloadable file.");
 
-    Services.console.logStringMessage("Refusing download of non-downloadable file.");
     let bundle = Services.strings.createBundle("chrome://browser/locale/handling.properties");
     let failedText = bundle.GetStringFromName("download.blocked");
-    win.toast.show(failedText, "long");
+
+    Snackbars.show(failedText, Snackbars.LENGTH_LONG);
   },
 
   _downloadWithAndroidDownloadManager(aLauncher) {
     let mimeType = aLauncher.MIMEInfo.MIMEType;
     if (!mimeType) {
       mimeType = ContentAreaUtils.getMIMETypeForURI(aLauncher.source) || "";
     }