Bug 1332562 - OMA Downloads should go to the system Download directory. r=snorp
authorMichael Kaply <mozilla@kaply.com>
Thu, 23 Feb 2017 12:27:43 -0600
changeset 344626 564e1f5f214523adc78b1f5ee5a94428c8696343
parent 344625 d5bc4f182ec309b2d9577b5d7a0414d9d4ed7c0b
child 344627 391047948db40495f68c43421bb7263d10680b97
push id31414
push usercbook@mozilla.com
push dateFri, 24 Feb 2017 10:47:41 +0000
treeherdermozilla-central@be661bae6cb9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1332562
milestone54.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 1332562 - OMA Downloads should go to the system Download directory. r=snorp MozReview-Commit-ID: 48fGzGYBoS6
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/components/HelperAppDialog.js
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -2065,18 +2065,18 @@ public class BrowserApp extends GeckoApp
                 final String uri = message.getString("uri");
                 final String filename = message.getString("filename");
                 final String mimeType = message.getString("mimeType");
 
                 final DownloadManager.Request request = new DownloadManager.Request(Uri.parse(uri));
                 request.setMimeType(mimeType);
 
                 try {
-                    request.setDestinationInExternalFilesDir(
-                            this, Environment.DIRECTORY_DOWNLOADS, filename);
+                    request.setDestinationInExternalPublicDir(
+                            Environment.DIRECTORY_DOWNLOADS, filename);
                 } catch (IllegalStateException e) {
                     Log.e(LOGTAG, "Cannot create download directory");
                     break;
                 }
 
                 request.allowScanningByMediaScanner();
                 request.setNotificationVisibility(
                         DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
--- a/mobile/android/components/HelperAppDialog.js
+++ b/mobile/android/components/HelperAppDialog.js
@@ -132,18 +132,26 @@ HelperAppLauncherDialog.prototype = {
 
   show: function hald_show(aLauncher, aContext, aReason) {
     if (!this._canDownload(aLauncher.source)) {
       this._refuseDownload(aLauncher);
       return;
     }
 
     if (this._shouldForwardToAndroidDownloadManager(aLauncher)) {
-      this._downloadWithAndroidDownloadManager(aLauncher);
-      aLauncher.cancel(Cr.NS_BINDING_ABORTED);
+      Task.spawn(function* () {
+        try {
+          let hasPermission = yield RuntimePermissions.waitForPermissions(RuntimePermissions.WRITE_EXTERNAL_STORAGE);
+          if (hasPermission) {
+            this._downloadWithAndroidDownloadManager(aLauncher);
+            aLauncher.cancel(Cr.NS_BINDING_ABORTED);
+          }
+        } finally {
+        }
+      }.bind(this)).catch(Cu.reportError);
       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,