Commit bb7c1ff2 authored by Ryan Landay's avatar Ryan Landay Committed by Commit Bot

Fix screenshot-blocking logic in Android horizontal tab switcher

We don't allow taking screenshots in the current overlapping Android tab
switcher when incognito tabs are open, even if the normal mode stack is active,
because we show the edge of the incognito tabs visible on-screen. For the new
horizontal tab switcher, we don't do this, so we can allow taking screenshots in
this case.

Bug: 853805
Change-Id: Ic7054524735b888c39b9a3373684971c962a6030
Reviewed-on: https://chromium-review.googlesource.com/1105392
Commit-Queue: Ryan Landay <rlanday@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568538}
parent 55d59d8c
......@@ -8,6 +8,7 @@ import android.view.Window;
import android.view.WindowManager;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChrome;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior.OverviewModeObserver;
import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver;
......@@ -91,8 +92,13 @@ public class IncognitoTabSnapshotController
@VisibleForTesting
boolean isShowingIncognito() {
boolean isInIncognitoModel = mTabModelSelector.getCurrentModel().isIncognito();
// Chrome Home is in overview mode when creating new tabs.
return isInIncognitoModel || (mInOverviewMode && getIncognitoTabCount() > 0);
// If we're using the overlapping tab switcher, we show the edge of the open incognito tabs
// even if the tab switcher is showing the normal stack. But if the horizontal tab switcher
// is enabled, incognito tabs are not visible while we're showing the normal tabs.
return isInIncognitoModel
|| (!ChromeFeatureList.isEnabled(ChromeFeatureList.HORIZONTAL_TAB_SWITCHER_ANDROID)
&& mInOverviewMode && getIncognitoTabCount() > 0);
}
// Set in overview mode for testing.
......
......@@ -22,10 +22,13 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChrome;
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import java.util.HashMap;
/**
* Unit tests for IncognitoTabSnapshotController.java.
*/
......@@ -122,6 +125,10 @@ public class IncognitoTabSnapshotControllerTest {
@Test
public void testInOverviewModeWithIncognitoTab() {
HashMap<String, Boolean> features = new HashMap<String, Boolean>();
features.put(ChromeFeatureList.HORIZONTAL_TAB_SWITCHER_ANDROID, false);
ChromeFeatureList.setTestFeatures(features);
mController = new IncognitoTabSnapshotController(mWindow, mLayoutManager, mSelector);
mController.setInOverViewMode(true);
......@@ -136,6 +143,10 @@ public class IncognitoTabSnapshotControllerTest {
@Test
public void testInOverviewModeWithNoIncognitoTab() {
HashMap<String, Boolean> features = new HashMap<String, Boolean>();
features.put(ChromeFeatureList.HORIZONTAL_TAB_SWITCHER_ANDROID, false);
ChromeFeatureList.setTestFeatures(features);
mController = new IncognitoTabSnapshotController(mWindow, mLayoutManager, mSelector);
mController.setInOverViewMode(true);
......@@ -161,4 +172,4 @@ public class IncognitoTabSnapshotControllerTest {
return mIsShowingIncognito;
}
}
}
\ No newline at end of file
}
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