Commit 46029fc6 authored by ckitagawa's avatar ckitagawa Committed by Commit Bot

[Paint Preview] Prevent showing after a native page

If a native page is shown as the first thing after startup it is
possible a preview will be shown. This CL avoids that scenario.

Bug: 1142856
Change-Id: Id309d58a810b0f58649dc4b11dba8398fcb8e1ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2502391Reviewed-by: default avatarMehran Mahmoudi <mahmoudi@chromium.org>
Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821392}
parent ef24657e
...@@ -84,6 +84,12 @@ public class PaintPreviewHelper { ...@@ -84,6 +84,12 @@ public class PaintPreviewHelper {
tabModelSelector.addObserver(new EmptyTabModelSelectorObserver() { tabModelSelector.addObserver(new EmptyTabModelSelectorObserver() {
@Override @Override
public void onTabStateInitialized() { public void onTabStateInitialized() {
// If the first tab shown is not a normal tab, then prevent showing previews in the
// future.
if (preventShowOnRestore(tabModelSelector.getCurrentTab())) {
sShouldShowOnRestore = false;
}
// Avoid running the audit in multi-window mode as otherwise we will delete // Avoid running the audit in multi-window mode as otherwise we will delete
// data that is possibly in use by the other Activity's TabModelSelector. // data that is possibly in use by the other Activity's TabModelSelector.
PaintPreviewTabServiceFactory.getServiceInstance().onRestoreCompleted( PaintPreviewTabServiceFactory.getServiceInstance().onRestoreCompleted(
...@@ -92,6 +98,16 @@ public class PaintPreviewHelper { ...@@ -92,6 +98,16 @@ public class PaintPreviewHelper {
/*captureOnSwitch=*/false); /*captureOnSwitch=*/false);
tabModelSelector.removeObserver(this); tabModelSelector.removeObserver(this);
} }
private boolean preventShowOnRestore(Tab tab) {
if (tab == null || tab.isShowingErrorPage() || tab.isNativePage()) {
return true;
}
String scheme = tab.getUrl().getScheme();
boolean httpOrHttps = scheme.equals("http") || scheme.equals("https");
return !httpOrHttps;
}
}); });
} }
......
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