From 0f6b776ba162a896ab6b8b60b3556f44e401c1bb Mon Sep 17 00:00:00 2001 From: "Randall E. Barker" Date: Tue, 9 Jul 2019 17:27:05 +0000 Subject: [PATCH] Bug 1556540 - Fix GeckoSession.loadData() so that it can load data URLs r=geckoview-reviewers,agi,esawin,snorp Differential Revision: https://phabricator.services.mozilla.com/D37343 --HG-- extra : moz-landing-system : lando --- mobile/android/geckoview/api.txt | 1 + .../main/java/org/mozilla/geckoview/GeckoSession.java | 10 ++++++++-- .../java/org/mozilla/geckoview/doc-files/CHANGELOG.md | 4 +++- .../android/modules/geckoview/GeckoViewNavigation.jsm | 4 ++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mobile/android/geckoview/api.txt b/mobile/android/geckoview/api.txt index 3269cd999518..32a0c734c7a1 100644 --- a/mobile/android/geckoview/api.txt +++ b/mobile/android/geckoview/api.txt @@ -459,6 +459,7 @@ package org.mozilla.geckoview { field public static final int LOAD_FLAGS_BYPASS_CLASSIFIER = 16; field public static final int LOAD_FLAGS_BYPASS_PROXY = 2; field public static final int LOAD_FLAGS_EXTERNAL = 4; + field public static final int LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 32; field public static final int LOAD_FLAGS_NONE = 0; field @Nullable protected GeckoSession.Window mWindow; } diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java index 1e7427ad0e65..7c6dcb3d9d24 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java @@ -1480,7 +1480,7 @@ public class GeckoSession implements Parcelable { @Retention(RetentionPolicy.SOURCE) @IntDef(flag = true, value = { LOAD_FLAGS_NONE, LOAD_FLAGS_BYPASS_CACHE, LOAD_FLAGS_BYPASS_PROXY, - LOAD_FLAGS_EXTERNAL, LOAD_FLAGS_ALLOW_POPUPS }) + LOAD_FLAGS_EXTERNAL, LOAD_FLAGS_ALLOW_POPUPS, LOAD_FLAGS_FORCE_ALLOW_DATA_URI }) /* package */ @interface LoadFlags {} // These flags follow similarly named ones in Gecko's nsIWebNavigation.idl @@ -1519,6 +1519,12 @@ public class GeckoSession implements Parcelable { */ public static final int LOAD_FLAGS_BYPASS_CLASSIFIER = 1 << 4; + /** + * Allows a top-level data: navigation to occur. E.g. view-image + * is an explicit user action which should be allowed. + */ + public static final int LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 1 << 5; + /** * Load the given URI. * @param uri The URI of the resource to load. @@ -1620,7 +1626,7 @@ public class GeckoSession implements Parcelable { throw new IllegalArgumentException("data cannot be null"); } - loadUri(createDataUri(bytes, mimeType), null, LOAD_FLAGS_NONE); + loadUri(createDataUri(bytes, mimeType), null, LOAD_FLAGS_FORCE_ALLOW_DATA_URI); } /** diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md index 5cbdfea897c6..a1f39aac4f0e 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md @@ -12,6 +12,8 @@ exclude: true - Modified behavior of ['setAutomaticFontSizeAdjustment'][69.1] so that it no longer has any effect on ['setFontInflationEnabled'][69.2] +- Add GeckoSession.LOAD_FLAGS_FORCE_ALLOW_DATA_URI + [69.1]: ./GeckoRuntimeSettings.html#setAutomaticFontSizeAdjustment-boolean- [69.2]: ./GeckoRuntimeSettings.html#setFontInflationEnabled-boolean- @@ -340,4 +342,4 @@ exclude: true [65.24]: ../CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String- [65.25]: ../GeckoResult.html -[api-version]: 5728f5c65b2be03fcf31d7da12050bf26d07e30f +[api-version]: 95d443eb3946aeb5b278a258ab5a527d3281edda diff --git a/mobile/android/modules/geckoview/GeckoViewNavigation.jsm b/mobile/android/modules/geckoview/GeckoViewNavigation.jsm index dbfa0e5c94dc..8ddeef6e2598 100644 --- a/mobile/android/modules/geckoview/GeckoViewNavigation.jsm +++ b/mobile/android/modules/geckoview/GeckoViewNavigation.jsm @@ -111,6 +111,10 @@ class GeckoViewNavigation extends GeckoViewModule { navFlags |= Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CLASSIFIER; } + if (flags & (1 << 5)) { + navFlags |= Ci.nsIWebNavigation.LOAD_FLAGS_FORCE_ALLOW_DATA_URI; + } + if (this.settings.useMultiprocess) { this.moduleManager.updateRemoteTypeForURI(uri); }