mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Bug 1487542 - Change LoadRequest.isUserTriggered to isRedirect. r=snorp,smaug
Differential Revision: https://phabricator.services.mozilla.com/D12370 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
cbf2ec1e66
commit
b059d469bb
@ -214,6 +214,11 @@ interface nsIWebNavigation : nsISupports
|
||||
*/
|
||||
const unsigned long LOAD_FLAGS_FORCE_ALLOW_DATA_URI = 0x400000;
|
||||
|
||||
/**
|
||||
* This load is the result of an HTTP redirect.
|
||||
*/
|
||||
const unsigned long LOAD_FLAGS_IS_REDIRECT = 0x800000;
|
||||
|
||||
/**
|
||||
* Loads a given URI. This will give priority to loading the requested URI
|
||||
* in the object implementing this interface. If it can't be loaded here
|
||||
|
@ -374,22 +374,19 @@ package org.mozilla.geckoview {
|
||||
method public org.mozilla.geckoview.GeckoResult<org.mozilla.geckoview.AllowOrDeny> onLoadRequest(org.mozilla.geckoview.GeckoSession, org.mozilla.geckoview.GeckoSession.NavigationDelegate.LoadRequest);
|
||||
method public void onLocationChange(org.mozilla.geckoview.GeckoSession, java.lang.String);
|
||||
method public org.mozilla.geckoview.GeckoResult<org.mozilla.geckoview.GeckoSession> onNewSession(org.mozilla.geckoview.GeckoSession, java.lang.String);
|
||||
field public static final int LOAD_REQUEST_IS_USER_TRIGGERED = 4096;
|
||||
field public static final int LOAD_REQUEST_IS_REDIRECT = 8388608;
|
||||
field public static final int TARGET_WINDOW_CURRENT = 1;
|
||||
field public static final int TARGET_WINDOW_NEW = 2;
|
||||
field public static final int TARGET_WINDOW_NONE = 0;
|
||||
}
|
||||
|
||||
public static class GeckoSession.NavigationDelegate.LoadRequest {
|
||||
field public final boolean isUserTriggered;
|
||||
field public final boolean isRedirect;
|
||||
field public final int target;
|
||||
field public final java.lang.String triggerUri;
|
||||
field public final java.lang.String uri;
|
||||
}
|
||||
|
||||
public static interface GeckoSession.NavigationDelegate.LoadRequestFlags implements java.lang.annotation.Annotation {
|
||||
}
|
||||
|
||||
public static interface GeckoSession.NavigationDelegate.TargetWindow implements java.lang.annotation.Annotation {
|
||||
}
|
||||
|
||||
|
@ -234,6 +234,8 @@ class NavigationDelegateTest : BaseSessionTest() {
|
||||
assertThat("Target should not be null", request.target, notNullValue())
|
||||
assertThat("Target should match", request.target,
|
||||
equalTo(GeckoSession.NavigationDelegate.TARGET_WINDOW_CURRENT))
|
||||
assertThat("Redirect flag is set", request.isRedirect,
|
||||
equalTo(forEachCall(false, true)))
|
||||
return null
|
||||
}
|
||||
})
|
||||
@ -503,6 +505,7 @@ class NavigationDelegateTest : BaseSessionTest() {
|
||||
assertThat("Target should not be null", request.target, notNullValue())
|
||||
assertThat("Target should match", request.target,
|
||||
equalTo(GeckoSession.NavigationDelegate.TARGET_WINDOW_CURRENT))
|
||||
assertThat("Redirect flag is not set", request.isRedirect, equalTo(false))
|
||||
return null
|
||||
}
|
||||
|
||||
|
@ -411,11 +411,6 @@ public class GeckoSession implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
// 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,
|
||||
@ -2812,15 +2807,11 @@ public class GeckoSession implements Parcelable {
|
||||
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})
|
||||
/* package */ @interface LoadRequestFlags {}
|
||||
|
||||
// Match with nsIDocShell.idl.
|
||||
// Match with nsIWebNavigation.idl.
|
||||
/**
|
||||
* The load request was triggered by user input.
|
||||
* The load request was triggered by an HTTP redirect.
|
||||
*/
|
||||
public static final int LOAD_REQUEST_IS_USER_TRIGGERED = 0x1000;
|
||||
static final int LOAD_REQUEST_IS_REDIRECT = 0x800000;
|
||||
|
||||
/**
|
||||
* Load request details.
|
||||
@ -2833,9 +2824,7 @@ public class GeckoSession implements Parcelable {
|
||||
this.uri = uri;
|
||||
this.triggerUri = triggerUri;
|
||||
this.target = convertGeckoTarget(geckoTarget);
|
||||
|
||||
// Match with nsIDocShell.idl.
|
||||
this.isUserTriggered = (flags & 0x1000) != 0;
|
||||
this.isRedirect = (flags & LOAD_REQUEST_IS_REDIRECT) != 0;
|
||||
}
|
||||
|
||||
// This needs to match nsIBrowserDOMWindow.idl
|
||||
@ -2869,7 +2858,7 @@ public class GeckoSession implements Parcelable {
|
||||
/**
|
||||
* True if and only if the request was triggered by user interaction.
|
||||
*/
|
||||
public final boolean isUserTriggered;
|
||||
public final boolean isRedirect;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -675,7 +675,7 @@ public class GeckoViewActivity extends AppCompatActivity {
|
||||
Log.d(LOGTAG, "onLoadRequest=" + request.uri +
|
||||
" triggerUri=" + request.triggerUri +
|
||||
" where=" + request.target +
|
||||
" isUserTriggered=" + request.isUserTriggered);
|
||||
" isRedirect=" + request.isRedirect);
|
||||
|
||||
return GeckoResult.fromValue(AllowOrDeny.ALLOW);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIWebProgressListener2.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
@ -1446,7 +1447,8 @@ NS_IMETHODIMP nsDocLoader::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
|
||||
if (newURI) {
|
||||
const int where = nsIBrowserDOMWindow::OPEN_CURRENTWINDOW;
|
||||
bool loadURIHandled = false;
|
||||
nsresult rv = delegate->LoadURI(newURI, where, /* flags */ 0,
|
||||
nsresult rv = delegate->LoadURI(newURI, where,
|
||||
nsIWebNavigation::LOAD_FLAGS_IS_REDIRECT,
|
||||
/* triggering principal */ nullptr,
|
||||
&loadURIHandled);
|
||||
if (NS_SUCCEEDED(rv) && loadURIHandled) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user