Bug 1271570 - Prompting storage permission for file:// uris; r?sebastian draft bug1271570
authorShan <11812r@gmail.com>
Tue, 20 Dec 2016 11:19:58 +0530
branchbug1271570
changeset 451377 2413b307e0ba0a073c0331fb901aa1ee4ee3faad
parent 451376 bf710bc39aee16d67affdb44e512947d27b60f0e
child 724631 1aaef5bf552d85f4b0a06549b187f2a71a0f7aef
push id39142
push userbmo:11812r@gmail.com
push dateTue, 20 Dec 2016 05:51:52 +0000
reviewerssebastian
bugs1271570
milestone53.0a1
Bug 1271570 - Prompting storage permission for file:// uris; r?sebastian MozReview-Commit-ID: 4fhcFaE2GRe
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3860,16 +3860,28 @@ Tab.prototype = {
           errorType = "blocked";
         }
         else if (docURI.startsWith("about:neterror")) {
           let error = docURI.search(/e\=/);
           let duffUrl = docURI.search(/\&u\=/);
           let errorExtra = decodeURIComponent(docURI.slice(error + 2, duffUrl));
           // Here is a list of errorExtra types (et_*)
           // http://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/netError.xhtml#287
+
+          if (errorExtra == "fileAccessDenied") {
+            RuntimePermissions.waitForPermissions([RuntimePermissions.WRITE_EXTERNAL_STORAGE])
+              .then((permissionGranted) => {
+                // Reload the URI if the user allowed permission
+                dump("Permission status: " + permissionGranted);
+                if(permissionGranted) {
+                  this.browser.reload();
+                }
+            });
+          }
+          
           UITelemetry.addEvent("neterror.1", "content", null, errorExtra);
           errorType = "neterror";
         }
 
         // Attach a listener to watch for "click" events bubbling up from error
         // pages and other similar page. This lets us fix bugs like 401575 which
         // require error page UI to do privileged things, without letting error
         // pages have any privilege themselves.