Bug 1140815 - Don't leave .part files lying around after a preferred helper app is used to process a URL. r=paolo,mfinkle
authorKartikaya Gupta <kgupta@mozilla.com>
Sun, 08 Mar 2015 21:35:39 -0400
changeset 232500 e6839726fe1df0aa5d0ce7450d9972d08aea099c
parent 232499 c0aa91aff8e578d5fcf4f9cfe99fd3b9b770af99
child 232501 37409aced15c32b9ad23ee530ab17a99140e69ce
push id28385
push userkwierso@gmail.com
push dateTue, 10 Mar 2015 00:38:43 +0000
treeherdermozilla-central@d164b59f3b94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo, mfinkle
bugs1140815
milestone39.0a1
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
Bug 1140815 - Don't leave .part files lying around after a preferred helper app is used to process a URL. r=paolo,mfinkle
mobile/android/components/HelperAppDialog.js
--- a/mobile/android/components/HelperAppDialog.js
+++ b/mobile/android/components/HelperAppDialog.js
@@ -148,37 +148,39 @@ HelperAppLauncherDialog.prototype = {
       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);
+      }
+    }
+
     // See if the user already marked something as the default for this mimetype,
     // and if that app is still installed.
     let preferredApp = this._getPreferredApp(aLauncher);
     if (preferredApp) {
       let pref = apps.filter(function(app) {
         return app.packageName === preferredApp;
       });
 
       if (pref.length > 0) {
-        pref[0].launch(aLauncher.source);
+        callback(pref[0]);
         return;
       }
     }
 
-    let callback = function(app) {
-      aLauncher.MIMEInfo.preferredAction = Ci.nsIMIMEInfo.useHelperApp;
-      if (!app.launch(aLauncher.source)) {
-        aLauncher.cancel(Cr.NS_BINDING_ABORTED);
-      }
-    }
-
     // If there's only one choice, and we don't want to prompt, go right ahead
     // and choose that app automatically.
     if (!this._shouldPrompt(aLauncher) && (apps.length === 1)) {
       callback(apps[0]);
       return;
     }
 
     // Otherwise, let's go through the prompt.