Skip to content

Commit

Permalink
Bug 1487542 - Change LoadRequest.isUserTriggered to isRedirect. r=sno…
Browse files Browse the repository at this point in the history
…rp,smaug

Differential Revision: https://phabricator.services.mozilla.com/D12370
  • Loading branch information
mbrubeck committed Nov 21, 2018
1 parent b59b145 commit 5893f36
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
5 changes: 5 additions & 0 deletions docshell/base/nsIWebNavigation.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
Expand Down Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,6 @@ private int convertGeckoTarget(int geckoTarget) {
}
}

// 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,
Expand Down Expand Up @@ -2812,15 +2807,11 @@ public interface NavigationDelegate {
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.
Expand All @@ -2833,9 +2824,7 @@ public static class LoadRequest {
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
Expand Down Expand Up @@ -2869,7 +2858,7 @@ public static class LoadRequest {
/**
* True if and only if the request was triggered by user interaction.
*/
public final boolean isUserTriggered;
public final boolean isRedirect;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public GeckoResult<AllowOrDeny> onLoadRequest(final GeckoSession session,
Log.d(LOGTAG, "onLoadRequest=" + request.uri +
" triggerUri=" + request.triggerUri +
" where=" + request.target +
" isUserTriggered=" + request.isUserTriggered);
" isRedirect=" + request.isRedirect);

return GeckoResult.fromValue(AllowOrDeny.ALLOW);
}
Expand Down
4 changes: 3 additions & 1 deletion uriloader/base/nsDocLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "nsCURILoader.h"
#include "nsNetUtil.h"
#include "nsIHttpChannel.h"
#include "nsIWebNavigation.h"
#include "nsIWebProgressListener2.h"

#include "nsIServiceManager.h"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 5893f36

Please sign in to comment.