Bug 1809269 - Add bypass load URI delegate in load flags. r=jonalmeida,amejiamarmol

Differential Revision: https://phabricator.services.mozilla.com/D169865
This commit is contained in:
Roger Yang 2023-02-22 21:10:53 +00:00
Родитель 771bdc853e
Коммит 6f6189d4d0
5 изменённых файлов: 38 добавлений и 5 удалений

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

@ -961,6 +961,7 @@ package org.mozilla.geckoview {
field public static final int LOAD_FLAGS_ALLOW_POPUPS = 8;
field public static final int LOAD_FLAGS_BYPASS_CACHE = 1;
field public static final int LOAD_FLAGS_BYPASS_CLASSIFIER = 16;
field public static final int LOAD_FLAGS_BYPASS_LOAD_URI_DELEGATE = 128;
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;

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

@ -3076,4 +3076,25 @@ class NavigationDelegateTest : BaseSessionTest() {
}, sessionRule.env.defaultTimeoutMillis)
mainSession.evaluateJS("if (!imageLoaded) throw imageLoaded")
}
@Test
fun bypassLoadUriDelegate() {
val testUri = "https://www.mozilla.org"
mainSession.load(
Loader()
.uri(testUri)
.flags(GeckoSession.LOAD_FLAGS_BYPASS_LOAD_URI_DELEGATE)
)
mainSession.waitForPageStop()
sessionRule.forCallbacksDuringWait(
object : NavigationDelegate {
@AssertCalled(false)
override fun onLoadRequest(session: GeckoSession, request: LoadRequest): GeckoResult<AllowOrDeny>? {
return null
}
}
)
}
}

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

@ -1712,7 +1712,8 @@ public class GeckoSession {
LOAD_FLAGS_EXTERNAL,
LOAD_FLAGS_ALLOW_POPUPS,
LOAD_FLAGS_FORCE_ALLOW_DATA_URI,
LOAD_FLAGS_REPLACE_HISTORY
LOAD_FLAGS_REPLACE_HISTORY,
LOAD_FLAGS_BYPASS_LOAD_URI_DELEGATE,
})
public @interface LoadFlags {}
@ -1749,6 +1750,9 @@ public class GeckoSession {
/** This flag specifies that any existing history entry should be replaced. */
public static final int LOAD_FLAGS_REPLACE_HISTORY = 1 << 6;
/** This load should bypass the NavigationDelegate.onLoadRequest. */
public static final int LOAD_FLAGS_BYPASS_LOAD_URI_DELEGATE = 1 << 7;
/**
* Filter headers according to the CORS safelisted rules.
*
@ -2045,7 +2049,7 @@ public class GeckoSession {
false, /* hasUserGesture */
true /* isDirectNavigation */);
shouldLoadUri(loadRequest)
shouldLoadUri(loadRequest, loadFlags)
.getOrAccept(
allowOrDeny -> {
if (allowOrDeny == AllowOrDeny.DENY) {
@ -2103,9 +2107,10 @@ public class GeckoSession {
load(new Loader().uri(uri));
}
private GeckoResult<AllowOrDeny> shouldLoadUri(final NavigationDelegate.LoadRequest request) {
private GeckoResult<AllowOrDeny> shouldLoadUri(
final NavigationDelegate.LoadRequest request, final int loadFlags) {
final NavigationDelegate delegate = mNavigationHandler.getDelegate();
if (delegate == null) {
if (delegate == null || (loadFlags & LOAD_FLAGS_BYPASS_LOAD_URI_DELEGATE) != 0) {
return GeckoResult.allow();
}

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

@ -13,6 +13,9 @@ exclude: true
⚠️ breaking change and deprecation notices
## v112
- Added `GeckoSession.LOAD_FLAGS_BYPASS_LOAD_URI_DELEGATE`, see ([bug 1809269]({{bugzilla}}1809269)).
## v111
- Removed deprecated [`SelectionActionDelegate.Selection.clientRect`][111.10], [`BasicSelectionActionDelegate.mTempMatrix`][111.11] and [`BasicSelectionActionDelegate.mTempRect`][111.12], ([bug 1801615]({{bugzilla}}1801615))
@ -1318,4 +1321,4 @@ to allow adding gecko profiler markers.
[65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport(android.content.Context,android.os.Bundle,java.lang.String)
[65.25]: {{javadoc_uri}}/GeckoResult.html
[api-version]: 5c6f2bfdee45037ef4de5b47ecf3c775b738a9ed
[api-version]: e6608eb2026e3779678c2ae2b72b4abf403f73ca

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

@ -83,6 +83,9 @@ function convertFlags(aFlags) {
if (aFlags & (1 << 6)) {
navFlags |= Ci.nsIWebNavigation.LOAD_FLAGS_REPLACE_HISTORY;
}
if (aFlags & (1 << 7)) {
navFlags |= Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_LOAD_URI_DELEGATE;
}
return navFlags;
}