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
This commit is contained in:
Randall E. Barker 2019-07-09 17:27:05 +00:00
Родитель ddaf2014c9
Коммит 0f6b776ba1
4 изменённых файлов: 16 добавлений и 3 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);
}
/**

Просмотреть файл

@ -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

Просмотреть файл

@ -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);
}