Skip to content

Commit

Permalink
Update Java IsExternalProtocol state when navigation redirects
Browse files Browse the repository at this point in the history
When a page redirects to an external protocol we forgot to update the
Java-side state to mark the current URL as an external protocol.

Bug: 1323163
Change-Id: I42e5ed79b890cc1e2453124cc3ee427aac75cd98
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3759612
Reviewed-by: Nate Fischer <ntfschr@chromium.org>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Reviewed-by: Lijin Shen <lazzzis@google.com>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1024479}
  • Loading branch information
Michael Thiessen authored and Chromium LUCI CQ committed Jul 14, 2022
1 parent 29ae8d9 commit a81a10d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private void simulateNavigation(GURL gurl, boolean isInPrimaryMainFrame, boolean

navigation.didFinish(gurl, isErrorPage, true /* hasCommitted */, isFragmentNavigation,
false /* isDownload */, false /* isValidSearchFormUrl */, transition,
0 /* errorCode*/, 200 /* httpStatusCode*/);
0 /* errorCode*/, 200 /* httpStatusCode*/, false /* isExternalProtocol */);
mWebContentsObserver.didFinishNavigation(navigation);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ private void navigateToUrl(GURL url, int httpStatusCode, @NetError int errorCode
false /* isReload */);
navigation.didFinish(url, false /* isErrorPage */, true /* hasCommitted */,
false /* isFragmentNavigation */, false /* isDownload */,
false /* isValidSearchFormUrl */, 0 /* pageTransition */, errorCode,
httpStatusCode);
false /* isValidSearchFormUrl */, 0 /* pageTransition */, errorCode, httpStatusCode,
false /* isExternalProtocol */);
for (CustomTabTabObserver tabObserver : mTabObserverCaptor.getAllValues()) {
tabObserver.onDidFinishNavigation(mTab, navigation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private void navigateToUrl(String url) {
navigation.didFinish(gurl, false /* isErrorPage */, true /* hasCommitted */,
false /* isFragmentNavigation */, false /* isDownload */,
false /* isValidSearchFormUrl */, 0 /* pageTransition */, 0 /* errorCode*/,
200 /* httpStatusCode*/);
200 /* httpStatusCode*/, false /* isExternalProtocol */);
for (CustomTabTabObserver tabObserver : mTabObserverCaptor.getAllValues()) {
tabObserver.onDidFinishNavigation(mTab, navigation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void simulateNavigation(String url, boolean isSameDocument) {
navigation.didFinish(gurl, false /* isErrorPage */, true /* hasCommitted */,
false /* isFragmentNavigation */, false /* isDownload */,
false /* isValidSearchFormUrl */, 0 /* pageTransition */, 0 /* errorCode */,
200 /* httpStatusCode */);
200 /* httpStatusCode */, false /* isExternalProtocol */);
mMediaSessionTabHelper.mMediaSessionHelper.mWebContentsObserver.didFinishNavigation(
navigation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private NavigationHandle createNavigationHandleWithUrl(boolean isMainFrame,
boolean isSameDocument, boolean isReload, boolean didCommit, GURL url) {
NavigationHandle handle = new NavigationHandle(0, url, null, null, isMainFrame,
isSameDocument, true, null, 0, false, false, false, false, -1, false, isReload);
handle.didFinish(url, false, didCommit, false, false, false, 0, 0, 0);
handle.didFinish(url, false, didCommit, false, false, false, 0, 0, 0, false);
return handle;
}
}
6 changes: 4 additions & 2 deletions content/browser/android/navigation_handle_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ void NavigationHandleProxy::DidRedirect() {
JNIEnv* env = AttachCurrentThread();
Java_NavigationHandle_didRedirect(
env, java_navigation_handle_,
url::GURLAndroid::FromNativeGURL(env, cpp_navigation_handle_->GetURL()));
url::GURLAndroid::FromNativeGURL(env, cpp_navigation_handle_->GetURL()),
cpp_navigation_handle_->IsExternalProtocol());
}

void NavigationHandleProxy::DidFinish() {
Expand Down Expand Up @@ -94,7 +95,8 @@ void NavigationHandleProxy::DidFinish() {
// crbug/690041.
cpp_navigation_handle_->GetResponseHeaders()
? cpp_navigation_handle_->GetResponseHeaders()->response_code()
: 200);
: 200,
cpp_navigation_handle_->IsExternalProtocol());
}

NavigationHandleProxy::~NavigationHandleProxy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class NavigationHandle {
private final boolean mIsPost;
private boolean mHasUserGesture;
private boolean mIsRedirect;
private final boolean mIsExternalProtocol;
private boolean mIsExternalProtocol;
private final long mNavigationId;
private final boolean mIsPageActivation;
private final boolean mIsReload;
Expand Down Expand Up @@ -73,9 +73,10 @@ public NavigationHandle(long nativeNavigationHandleProxy, @NonNull GURL url,
* @param url The new URL.
*/
@CalledByNative
private void didRedirect(GURL url) {
private void didRedirect(GURL url, boolean isExternalProtocol) {
mUrl = url;
mIsRedirect = true;
mIsExternalProtocol = isExternalProtocol;
}

/**
Expand All @@ -85,7 +86,7 @@ private void didRedirect(GURL url) {
public void didFinish(@NonNull GURL url, boolean isErrorPage, boolean hasCommitted,
boolean isPrimaryMainFrameFragmentNavigation, boolean isDownload,
boolean isValidSearchFormUrl, @PageTransition int transition, @NetError int errorCode,
int httpStatuscode) {
int httpStatuscode, boolean isExternalProtocol) {
mUrl = url;
mIsErrorPage = isErrorPage;
mHasCommitted = hasCommitted;
Expand All @@ -95,6 +96,7 @@ public void didFinish(@NonNull GURL url, boolean isErrorPage, boolean hasCommitt
mPageTransition = transition;
mErrorCode = errorCode;
mHttpStatusCode = httpStatuscode;
mIsExternalProtocol = isExternalProtocol;
}

/**
Expand Down

0 comments on commit a81a10d

Please sign in to comment.