author | Eugen Sawin <esawin@mozilla.com> |
Thu, 26 Apr 2018 16:38:43 +0200 | |
changeset 416047 | a26881251c96ad32e546468be55643bf834855cb |
parent 416046 | e03927d418ba7b3535eff25063a31704c417510e |
child 416048 | 653f16ce003a533e822053a042e41c1adcc55763 |
push id | 102710 |
push user | esawin@mozilla.com |
push date | Fri, 27 Apr 2018 19:30:39 +0000 |
treeherder | mozilla-inbound@653f16ce003a [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | snorp, droeh |
bugs | 1439013 |
milestone | 61.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
|
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java +++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java @@ -595,18 +595,19 @@ public class CustomTabsActivity extends @Override public void onCanGoForward(GeckoSession session, boolean canGoForward) { mCanGoForward = canGoForward; updateMenuItemForward(); } @Override public void onLoadRequest(final GeckoSession session, final String urlStr, - final int target, - final GeckoResponse<Boolean> response) { + final int target, + final int flags, + final GeckoResponse<Boolean> response) { if (target != GeckoSession.NavigationDelegate.TARGET_WINDOW_NEW) { response.respond(false); return; } final Uri uri = Uri.parse(urlStr); if (uri == null) { // We can't handle this, so deny it.
--- a/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java +++ b/mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java @@ -373,16 +373,17 @@ public class WebAppActivity extends AppC @Override // GeckoSession.ContentDelegate public void onFullScreen(GeckoSession session, boolean fullScreen) { updateFullScreenContent(fullScreen); } @Override public void onLoadRequest(final GeckoSession session, final String urlStr, final int target, + final int flags, final GeckoResponse<Boolean> response) { final Uri uri = Uri.parse(urlStr); if (uri == null) { // We can't really handle this, so deny it? Log.w(LOGTAG, "Failed to parse URL for navigation: " + urlStr); response.respond(true); return; }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java @@ -158,16 +158,21 @@ public class GeckoSession extends LayerS case 0: // OPEN_DEFAULTWINDOW case 1: // OPEN_CURRENTWINDOW return NavigationDelegate.TARGET_WINDOW_CURRENT; default: // OPEN_NEWWINDOW, OPEN_NEWTAB, OPEN_SWITCHTAB return NavigationDelegate.TARGET_WINDOW_NEW; } } + // The flags are already matched with nsIDocShell.idl. + private int filterFlags(int flags) { + return flags & NavigationDelegate.LOAD_REQUEST_IS_USER_TRIGGERED; + } + @Override public void handleMessage(final NavigationDelegate delegate, final String event, final GeckoBundle message, final EventCallback callback) { if ("GeckoView:LocationChange".equals(event)) { if (message.getBoolean("isTopLevel")) { delegate.onLocationChange(GeckoSession.this, @@ -175,17 +180,19 @@ public class GeckoSession extends LayerS } delegate.onCanGoBack(GeckoSession.this, message.getBoolean("canGoBack")); delegate.onCanGoForward(GeckoSession.this, message.getBoolean("canGoForward")); } else if ("GeckoView:OnLoadRequest".equals(event)) { final String uri = message.getString("uri"); final int where = convertGeckoTarget(message.getInt("where")); - delegate.onLoadRequest(GeckoSession.this, uri, where, + final int flags = filterFlags(message.getInt("flags")); + + delegate.onLoadRequest(GeckoSession.this, uri, where, flags, new GeckoResponse<Boolean>() { @Override public void respond(Boolean handled) { callback.sendSuccess(handled); } }); } else if ("GeckoView:OnNewSession".equals(event)) { final String uri = message.getString("uri"); @@ -2071,33 +2078,46 @@ public class GeckoSession extends LayerS void onCanGoForward(GeckoSession session, boolean canGoForward); @IntDef({TARGET_WINDOW_NONE, TARGET_WINDOW_CURRENT, TARGET_WINDOW_NEW}) public @interface TargetWindow {} public static final int TARGET_WINDOW_NONE = 0; public static final int TARGET_WINDOW_CURRENT = 1; public static final int TARGET_WINDOW_NEW = 2; + @IntDef(flag = true, + value = {LOAD_REQUEST_IS_USER_TRIGGERED}) + public @interface LoadRequestFlags {} + // Match with nsIDocShell.idl. + /** + * The load request was triggered by user input. + */ + public static final int LOAD_REQUEST_IS_USER_TRIGGERED = 0x1000; + /** * A request to open an URI. This is called before each page load to * allow custom behavior implementation. * For example, this can be used to override the behavior of * TAGET_WINDOW_NEW requests, which defaults to requesting a new * GeckoSession via onNewSession. * * @param session The GeckoSession that initiated the callback. * @param uri The URI to be loaded. - * @param target The target where the window has requested to open. One of - * TARGET_WINDOW_*. + * @param target The target where the window has requested to open. + * One of {@link #TARGET_WINDOW_NONE TARGET_WINDOW_*}. + * @param flags The load request flags. + * One or more of {@link #LOAD_REQUEST_IS_USER_TRIGGERED + * LOAD_REQUEST_*}. * @param response A response which will state whether or not the load * was handled. If unhandled, Gecko will continue the * load as normal. */ void onLoadRequest(GeckoSession session, String uri, @TargetWindow int target, + @LoadRequestFlags int flags, GeckoResponse<Boolean> response); /** * A request has been made to open a new session. The URI is provided only for * informational purposes. Do not call GeckoSession.loadUri() here. Additionally, the * returned GeckoSession must be a newly-created one. * * @param session The GeckoSession that initiated the callback.
--- a/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java +++ b/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java @@ -355,18 +355,20 @@ public class GeckoViewActivity extends A } @Override public void onCanGoForward(GeckoSession session, boolean value) { } @Override public void onLoadRequest(final GeckoSession session, final String uri, - final int target, GeckoResponse<Boolean> response) { - Log.d(LOGTAG, "onLoadRequest=" + uri + " where=" + target); + final int target, final int flags, + GeckoResponse<Boolean> response) { + Log.d(LOGTAG, "onLoadRequest=" + uri + " where=" + target + + " flags=" + flags); response.respond(false); } @Override public void onNewSession(final GeckoSession session, final String uri, GeckoResponse<GeckoSession> response) { response.respond(null); } }