Commit 9718736d authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Avoid recomputing shouldCloseTab in InterceptNavigationDelegateImpl.java

This is just a readability improvement, no functional changes. It was
confusing that shouldCloseTab appeared to only be used in some cases
like actions that result in OVERRIDE_WITH_ASYNC_ACTION, when we were
actually just recomputing shouldCloseTab under the assumption that it
wouldn't change.

Change-Id: I52b16cef1483c328bc595bc329f4a9098b3fc5ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2101311Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750575}
parent a6b8930c
...@@ -186,14 +186,16 @@ public class InterceptNavigationDelegateImpl implements InterceptNavigationDeleg ...@@ -186,14 +186,16 @@ public class InterceptNavigationDelegateImpl implements InterceptNavigationDeleg
switch (result) { switch (result) {
case OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT: case OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT:
assert mExternalNavHandler.canExternalAppHandleUrl(url); assert mExternalNavHandler.canExternalAppHandleUrl(url);
if (navigationParams.isMainFrame) onOverrideUrlLoadingAndLaunchIntent(); if (navigationParams.isMainFrame) {
onOverrideUrlLoadingAndLaunchIntent(shouldCloseTab);
}
return true; return true;
case OverrideUrlLoadingResult.OVERRIDE_WITH_CLOBBERING_TAB: case OverrideUrlLoadingResult.OVERRIDE_WITH_CLOBBERING_TAB:
mShouldClearRedirectHistoryForTabClobbering = true; mShouldClearRedirectHistoryForTabClobbering = true;
return true; return true;
case OverrideUrlLoadingResult.OVERRIDE_WITH_ASYNC_ACTION: case OverrideUrlLoadingResult.OVERRIDE_WITH_ASYNC_ACTION:
if (!shouldCloseTab && navigationParams.isMainFrame) { if (!shouldCloseTab && navigationParams.isMainFrame) {
onOverrideUrlLoadingAndLaunchIntent(); onOverrideUrlLoadingAndLaunchIntent(shouldCloseTab);
} }
return true; return true;
case OverrideUrlLoadingResult.NO_OVERRIDE: case OverrideUrlLoadingResult.NO_OVERRIDE:
...@@ -287,15 +289,16 @@ public class InterceptNavigationDelegateImpl implements InterceptNavigationDeleg ...@@ -287,15 +289,16 @@ public class InterceptNavigationDelegateImpl implements InterceptNavigationDeleg
/** /**
* Called when Chrome decides to override URL loading and launch an intent or an asynchronous * Called when Chrome decides to override URL loading and launch an intent or an asynchronous
* action. * action.
* @param shouldCloseTab
*/ */
private void onOverrideUrlLoadingAndLaunchIntent() { private void onOverrideUrlLoadingAndLaunchIntent(boolean shouldCloseTab) {
if (mTab.getWebContents() == null) return; if (mTab.getWebContents() == null) return;
// Before leaving Chrome, close the empty child tab. // Before leaving Chrome, close the empty child tab.
// If a new tab is created through JavaScript open to load this // If a new tab is created through JavaScript open to load this
// url, we would like to close it as we will load this url in a // url, we would like to close it as we will load this url in a
// different Activity. // different Activity.
if (shouldCloseContentsOnOverrideUrlLoadingAndLaunchIntent()) { if (shouldCloseTab) {
if (mTab.getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP) { if (mTab.getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP) {
// Moving task back before closing the tab allows back button to function better // Moving task back before closing the tab allows back button to function better
// when Chrome was an intermediate link redirector between two apps. // when Chrome was an intermediate link redirector between two apps.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment