Commit b26f53a8 authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Commit Bot

[Android] Remove no longer needed punting of webapp interstitials to browser

Currently if a webapp shows a safe-browsing interstitial, the webapp is
closed and the page is launched in browser mode. The purpose of this
logic was to work around bug where Chrome could not display multiple
interstitials (e.g. interstitial in webapp and interstitial in Chrome
browser). crbug.com/293717 Based on testing, the underlying bug is fixed
and the workaround is no longer needed.

BUG=1073748

Change-Id: If1aedb38d7c6c5eed08e3de2c61ed72818ce1244
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2161453Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#761956}
parent 049bddd0
...@@ -70,14 +70,6 @@ public class SplashController ...@@ -70,14 +70,6 @@ public class SplashController
} }
}; };
@IntDef({SplashHidesReason.OTHER, SplashHidesReason.LOAD_FAILED, SplashHidesReason.CRASH})
@Retention(RetentionPolicy.SOURCE)
public @interface SplashHidesReason {
int OTHER = 0;
int LOAD_FAILED = 1;
int CRASH = 2;
}
@IntDef({TranslucencyRemoval.NONE, TranslucencyRemoval.ON_SPLASH_SHOWN, @IntDef({TranslucencyRemoval.NONE, TranslucencyRemoval.ON_SPLASH_SHOWN,
TranslucencyRemoval.ON_SPLASH_HIDDEN}) TranslucencyRemoval.ON_SPLASH_HIDDEN})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
...@@ -199,27 +191,34 @@ public class SplashController ...@@ -199,27 +191,34 @@ public class SplashController
@Override @Override
public void didFirstVisuallyNonEmptyPaint(Tab tab) { public void didFirstVisuallyNonEmptyPaint(Tab tab) {
if (canHideSplashScreen()) { if (canHideSplashScreen()) {
hideSplash(tab, SplashHidesReason.OTHER); hideSplash(tab, false /* loadFailed */);
}
}
@Override
public void onDidAttachInterstitialPage(Tab tab) {
if (canHideSplashScreen()) {
hideSplash(tab, true /* loadFailed */);
} }
} }
@Override @Override
public void onPageLoadFinished(Tab tab, String url) { public void onPageLoadFinished(Tab tab, String url) {
if (canHideSplashScreen()) { if (canHideSplashScreen()) {
hideSplash(tab, SplashHidesReason.OTHER); hideSplash(tab, false /* loadFailed */);
} }
} }
@Override @Override
public void onPageLoadFailed(Tab tab, int errorCode) { public void onPageLoadFailed(Tab tab, int errorCode) {
if (canHideSplashScreen()) { if (canHideSplashScreen()) {
hideSplash(tab, SplashHidesReason.LOAD_FAILED); hideSplash(tab, true /* loadFailed */);
} }
} }
@Override @Override
public void onCrash(Tab tab) { public void onCrash(Tab tab) {
hideSplash(tab, SplashHidesReason.CRASH); hideSplash(tab, true /* loadFailed */);
} }
private void showSplash() { private void showSplash() {
...@@ -281,7 +280,7 @@ public class SplashController ...@@ -281,7 +280,7 @@ public class SplashController
} }
/** Hides the splash screen. */ /** Hides the splash screen. */
private void hideSplash(final Tab tab, final @SplashHidesReason int reason) { private void hideSplash(final Tab tab, boolean loadFailed) {
if (mTranslucencyRemovalStrategy == TranslucencyRemoval.ON_SPLASH_HIDDEN if (mTranslucencyRemovalStrategy == TranslucencyRemoval.ON_SPLASH_HIDDEN
&& !mRemovedTranslucency) { && !mRemovedTranslucency) {
removeTranslucency(); removeTranslucency();
...@@ -297,7 +296,7 @@ public class SplashController ...@@ -297,7 +296,7 @@ public class SplashController
mParentView.invalidate(); mParentView.invalidate();
} }
if (reason == SplashHidesReason.LOAD_FAILED || reason == SplashHidesReason.CRASH) { if (loadFailed) {
animateHideSplash(tab); animateHideSplash(tab);
return; return;
} }
......
...@@ -17,7 +17,6 @@ import android.view.ViewGroup; ...@@ -17,7 +17,6 @@ import android.view.ViewGroup;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import org.chromium.base.ActivityState;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ApplicationStatus; import org.chromium.base.ApplicationStatus;
import org.chromium.base.IntentUtils; import org.chromium.base.IntentUtils;
...@@ -398,35 +397,6 @@ public class WebappActivity extends BaseCustomTabActivity<WebappActivityComponen ...@@ -398,35 +397,6 @@ public class WebappActivity extends BaseCustomTabActivity<WebappActivityComponen
tab, TabBrowserControlsConstraintsHelper.getConstraints(tab), true); tab, TabBrowserControlsConstraintsHelper.getConstraints(tab), true);
} }
} }
@Override
public void onDidAttachInterstitialPage(Tab tab) {
int state = ApplicationStatus.getStateForActivity(WebappActivity.this);
if (state == ActivityState.PAUSED || state == ActivityState.STOPPED
|| state == ActivityState.DESTROYED) {
return;
}
// Kick the interstitial navigation to Chrome.
Intent intent =
new Intent(Intent.ACTION_VIEW, Uri.parse(getActivityTab().getUrlString()));
intent.setPackage(getPackageName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
IntentHandler.startChromeLauncherActivityForTrustedIntent(intent);
// Pretend like the navigation never happened. We delay so that this happens while
// the Activity is in the background.
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (getActivityTab().canGoBack()) {
getActivityTab().goBack();
} else {
handleFinishAndClose();
}
}
}, MS_BEFORE_NAVIGATING_BACK_FROM_INTERSTITIAL);
}
}; };
} }
......
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