Bug 1258328 - HelperAppDialog: Replace deprecated toast API with Snackbars.jsm. r=grisha a=lizzard
authorSebastian Kaspari <s.kaspari@gmail.com>
Tue, 29 Mar 2016 13:18:12 +0200
changeset 325726 8e4ae231d7970818abbee30bab01d44fd8c2fae4
parent 325725 8b4d6477fd3e18d3995878f0d9dff41efa264cd4
child 325727 2d497450e21a59ad2071e5e287567d8c4cadf1cd
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgrisha, lizzard
bugs1258328
milestone47.0a2
Bug 1258328 - HelperAppDialog: Replace deprecated toast API with Snackbars.jsm. r=grisha a=lizzard MozReview-Commit-ID: 2WPNo9iGHu4
mobile/android/components/HelperAppDialog.js
--- a/mobile/android/components/HelperAppDialog.js
+++ b/mobile/android/components/HelperAppDialog.js
@@ -21,23 +21,22 @@ Cu.import("resource://gre/modules/Downlo
 Cu.import("resource://gre/modules/FileUtils.jsm");
 Cu.import("resource://gre/modules/HelperApps.jsm");
 Cu.import("resource://gre/modules/Services.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() { }
 
@@ -220,27 +219,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) || "";
     }