Backed out changeset 327f0142e1a7 (bug 1219078)
authorSebastian Kaspari <s.kaspari@gmail.com>
Fri, 22 Jan 2016 14:31:37 +0100
changeset 281357 dc7520a50e855c974f74689493af99b937493d20
parent 281356 4d92c4a644138ae9d0194e8f269cde19e6e89434
child 281358 8efa2e6a0407d2b1dbeb6e2e37424c606612315e
push id29935
push userphilringnalda@gmail.com
push dateSun, 24 Jan 2016 02:12:02 +0000
treeherdermozilla-central@a2e81822194a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1219078
milestone46.0a1
backs out327f0142e1a78bef241999e9679a357e75ff9698
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 327f0142e1a7 (bug 1219078)
mobile/android/components/HelperAppDialog.js
--- a/mobile/android/components/HelperAppDialog.js
+++ b/mobile/android/components/HelperAppDialog.js
@@ -3,17 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*globals ContentAreaUtils */
 
 const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 
 const APK_MIME_TYPE = "application/vnd.android.package-archive";
-const OMA_DOWNLOAD_DESCRIPTOR_MIME_TYPE = "application/vnd.oma.dd+xml";
 const PREF_BD_USEDOWNLOADDIR = "browser.download.useDownloadDir";
 const URI_GENERIC_ICON_DOWNLOAD = "drawable://alert_download";
 
 Cu.import("resource://gre/modules/Downloads.jsm");
 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");
@@ -81,64 +80,58 @@ HelperAppLauncherDialog.prototype = {
   /**
    * Returns true if `launcher` represents a download for which we wish
    * to prompt.
    */
   _shouldPrompt: function (launcher) {
     let mimeType = this._getMimeTypeFromLauncher(launcher);
 
     // Straight equality: nsIMIMEInfo normalizes.
-    return APK_MIME_TYPE == mimeType || OMA_DOWNLOAD_DESCRIPTOR_MIME_TYPE == mimeType;
-  },
-
-  /**
-   * Returns true if `launcher` represents a download for which we wish to
-   * offer a "Save to disk" option.
-   */
-  _shouldAddSaveToDiskIntent: function(launcher) {
-      let mimeType = this._getMimeTypeFromLauncher(launcher);
-
-      // We can't handle OMA downloads. So don't even try. (Bug 1219078)
-      return mimeType != OMA_DOWNLOAD_DESCRIPTOR_MIME_TYPE;
+    return APK_MIME_TYPE == mimeType;
   },
 
   show: function hald_show(aLauncher, aContext, aReason) {
     if (!this._canDownload(aLauncher.source)) {
-      this._refuseDownload(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.");
+      let bundle = Services.strings.createBundle("chrome://browser/locale/handling.properties");
+      let failedText = bundle.GetStringFromName("download.blocked");
+      win.toast.show(failedText, "long");
+
       return;
     }
 
     let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
 
     let defaultHandler = new Object();
     let apps = HelperApps.getAppsForUri(aLauncher.source, {
       mimeType: aLauncher.MIMEInfo.MIMEType,
     });
 
-    if (this._shouldAddSaveToDiskIntent(aLauncher)) {
-      // Add a fake intent for save to disk at the top of the list.
-      apps.unshift({
-        name: bundle.GetStringFromName("helperapps.saveToDisk"),
-        packageName: "org.mozilla.gecko.Download",
-        iconUri: "drawable://icon",
-        selected: true, // Default to download for files
-        launch: function() {
-          // Reset the preferredAction here.
-          aLauncher.MIMEInfo.preferredAction = Ci.nsIMIMEInfo.saveToDisk;
-          aLauncher.saveToDisk(null, false);
-          return true;
-        }
-      });
-    }
-
-    // We do not handle this download and there are no apps that want to do it
-    if (apps.length === 0) {
-      this._refuseDownload(aLauncher);
-      return;
-    }
+    // Add a fake intent for save to disk at the top of the list.
+    apps.unshift({
+      name: bundle.GetStringFromName("helperapps.saveToDisk"),
+      packageName: "org.mozilla.gecko.Download",
+      iconUri: "drawable://icon",
+      selected: true, // Default to download for files
+      launch: function() {
+        // Reset the preferredAction here.
+        aLauncher.MIMEInfo.preferredAction = Ci.nsIMIMEInfo.saveToDisk;
+        aLauncher.saveToDisk(null, false);
+        return true;
+      }
+    });
 
     let callback = function(app) {
       aLauncher.MIMEInfo.preferredAction = Ci.nsIMIMEInfo.useHelperApp;
       if (!app.launch(aLauncher.source)) {
         // Once the app is done we need to get rid of the temp file. This shouldn't
         // get run in the saveToDisk case.
         aLauncher.cancel(Cr.NS_BINDING_ABORTED);
       }
@@ -180,26 +173,16 @@ HelperAppLauncherDialog.prototype = {
       callback(apps[data.icongrid0]);
 
       if (data.button === 0) {
         this._setPreferredApp(aLauncher, apps[data.icongrid0]);
       }
     });
   },
 
-  _refuseDownload: function(aLauncher) {
-    aLauncher.cancel(Cr.NS_BINDING_ABORTED);
-
-    Services.console.logStringMessage("Refusing download of non-downloadable file.");
-
-    let bundle = Services.strings.createBundle("chrome://browser/locale/handling.properties");
-
-    Snackbars.show(bundle.GetStringFromName("download.blocked"), Snackbars.LENGTH_LONG);
-  },
-
   _getPrefName: function getPrefName(mimetype) {
     return "browser.download.preferred." + mimetype.replace("\\", ".");
   },
 
   _getMimeTypeFromLauncher: function (launcher) {
     let mime = launcher.MIMEInfo.MIMEType;
     if (!mime)
       mime = ContentAreaUtils.getMIMETypeForURI(launcher.source) || "";