Commit 1f0b7c2a authored by gogerald's avatar gogerald Committed by Commit Bot

[StartSurface] Disable start surface for low end device

This CL also fixes the new tab button is missing on start
tab switcher surface.

Screenshots:
https://drive.google.com/a/google.com/file/d/1R4_oyeIz6_VuwMellLzPI7zQ2ef04AWX/view?usp=sharing
https://drive.google.com/a/google.com/file/d/1R0ASrrY8v50Z9E2bbGI-al_kKrjlI16p/view?usp=sharing

Bug: 1042006
Change-Id: Ie9663daf6cc0cb32c63975d65adfce9bb990ef4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003289Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Ganggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732482}
parent 27b3a2a2
...@@ -412,7 +412,8 @@ public class FeatureUtilities { ...@@ -412,7 +412,8 @@ public class FeatureUtilities {
* @return Whether the Start Surface is enabled. * @return Whether the Start Surface is enabled.
*/ */
public static boolean isStartSurfaceEnabled() { public static boolean isStartSurfaceEnabled() {
return isFlagEnabled(ChromePreferenceKeys.FLAGS_CACHED_START_SURFACE_ENABLED, false); return isFlagEnabled(ChromePreferenceKeys.FLAGS_CACHED_START_SURFACE_ENABLED, false)
&& !SysUtils.isLowEndDevice();
} }
private static void cachePaintPreviewTestEnabled() { private static void cachePaintPreviewTestEnabled() {
......
...@@ -21,6 +21,7 @@ import org.chromium.chrome.browser.ntp.NewTabPage; ...@@ -21,6 +21,7 @@ import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.partnercustomizations.HomepageManager; import org.chromium.chrome.browser.partnercustomizations.HomepageManager;
import org.chromium.chrome.browser.tab.TabLaunchType; import org.chromium.chrome.browser.tab.TabLaunchType;
import org.chromium.chrome.browser.tabmodel.TabModel; import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.util.AccessibilityUtil;
import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.ui.base.PageTransition; import org.chromium.ui.base.PageTransition;
...@@ -180,10 +181,11 @@ public final class ReturnToChromeExperimentsUtil { ...@@ -180,10 +181,11 @@ public final class ReturnToChromeExperimentsUtil {
* @return Whether Start Surface should be shown as the home page, otherwise false. * @return Whether Start Surface should be shown as the home page, otherwise false.
*/ */
public static boolean shouldShowStartSurfaceAsTheHomePage() { public static boolean shouldShowStartSurfaceAsTheHomePage() {
// Note that we should only show StartSurface as the HomePage if Single Pane is enabled and // Note that we should only show StartSurface as the HomePage if Single Pane is enabled,
// HomePage is not customized. // HomePage is not customized and accessibility is not enabled.
String homePageUrl = HomepageManager.getHomepageUri(); String homePageUrl = HomepageManager.getHomepageUri();
return FeatureUtilities.isStartSurfaceSinglePaneEnabled() return FeatureUtilities.isStartSurfaceSinglePaneEnabled()
&& (TextUtils.isEmpty(homePageUrl) || NewTabPage.isNTPUrl(homePageUrl)); && (TextUtils.isEmpty(homePageUrl) || NewTabPage.isNTPUrl(homePageUrl))
&& !AccessibilityUtil.isAccessibilityEnabled();
} }
} }
...@@ -28,6 +28,7 @@ import org.chromium.chrome.browser.tabmodel.TabModelSelector; ...@@ -28,6 +28,7 @@ import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver; import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
import org.chromium.chrome.browser.toolbar.IncognitoStateProvider; import org.chromium.chrome.browser.toolbar.IncognitoStateProvider;
import org.chromium.chrome.browser.ui.appmenu.AppMenuButtonHelper; import org.chromium.chrome.browser.ui.appmenu.AppMenuButtonHelper;
import org.chromium.chrome.browser.util.AccessibilityUtil;
import org.chromium.components.search_engines.TemplateUrlService.TemplateUrlServiceObserver; import org.chromium.components.search_engines.TemplateUrlService.TemplateUrlServiceObserver;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
...@@ -55,15 +56,13 @@ class StartSurfaceToolbarMediator { ...@@ -55,15 +56,13 @@ class StartSurfaceToolbarMediator {
mTemplateUrlObserver = new TemplateUrlServiceObserver() { mTemplateUrlObserver = new TemplateUrlServiceObserver() {
@Override @Override
public void onTemplateURLServiceChanged() { public void onTemplateURLServiceChanged() {
updateLogoVisibility(mOverviewModeState, updateLogoVisibility(TemplateUrlServiceFactory.get().isDefaultSearchEngineGoogle());
TemplateUrlServiceFactory.get().isDefaultSearchEngineGoogle());
} }
}; };
TemplateUrlServiceFactory.get().addObserver(mTemplateUrlObserver); TemplateUrlServiceFactory.get().addObserver(mTemplateUrlObserver);
mIsGoogleSearchEngine = TemplateUrlServiceFactory.get().isDefaultSearchEngineGoogle(); mIsGoogleSearchEngine = TemplateUrlServiceFactory.get().isDefaultSearchEngineGoogle();
updateLogoVisibility( updateLogoVisibility(TemplateUrlServiceFactory.get().isDefaultSearchEngineGoogle());
mOverviewModeState, TemplateUrlServiceFactory.get().isDefaultSearchEngineGoogle());
} }
void destroy() { void destroy() {
...@@ -115,6 +114,7 @@ class StartSurfaceToolbarMediator { ...@@ -115,6 +114,7 @@ class StartSurfaceToolbarMediator {
void onAccessibilityStatusChanged(boolean enabled) { void onAccessibilityStatusChanged(boolean enabled) {
mPropertyModel.set(ACCESSIBILITY_ENABLED, enabled); mPropertyModel.set(ACCESSIBILITY_ENABLED, enabled);
updateNewTabButtonVisibility();
} }
void onBottomToolbarVisibilityChanged(boolean isVisible) {} void onBottomToolbarVisibilityChanged(boolean isVisible) {}
...@@ -128,10 +128,9 @@ class StartSurfaceToolbarMediator { ...@@ -128,10 +128,9 @@ class StartSurfaceToolbarMediator {
@Override @Override
public void onOverviewModeStateChanged( public void onOverviewModeStateChanged(
@OverviewModeState int overviewModeState, boolean showTabSwitcherToolbar) { @OverviewModeState int overviewModeState, boolean showTabSwitcherToolbar) {
boolean isShownTabswitcherState = mOverviewModeState = overviewModeState;
overviewModeState == OverviewModeState.SHOWN_TABSWITCHER; updateNewTabButtonVisibility();
mPropertyModel.set(NEW_TAB_BUTTON_IS_VISIBLE, isShownTabswitcherState); updateLogoVisibility(mIsGoogleSearchEngine);
updateLogoVisibility(overviewModeState, mIsGoogleSearchEngine);
} }
@Override @Override
public void onOverviewModeFinishedShowing() { public void onOverviewModeFinishedShowing() {
...@@ -148,9 +147,7 @@ class StartSurfaceToolbarMediator { ...@@ -148,9 +147,7 @@ class StartSurfaceToolbarMediator {
mOverviewModeBehavior.addOverviewModeObserver(mOverviewModeObserver); mOverviewModeBehavior.addOverviewModeObserver(mOverviewModeObserver);
} }
private void updateLogoVisibility( private void updateLogoVisibility(boolean isGoogleSearchEngine) {
@OverviewModeState int overviewModeState, boolean isGoogleSearchEngine) {
mOverviewModeState = overviewModeState;
mIsGoogleSearchEngine = isGoogleSearchEngine; mIsGoogleSearchEngine = isGoogleSearchEngine;
boolean shouldShowLogo = boolean shouldShowLogo =
(mOverviewModeState == OverviewModeState.SHOWN_HOMEPAGE (mOverviewModeState == OverviewModeState.SHOWN_HOMEPAGE
...@@ -158,4 +155,13 @@ class StartSurfaceToolbarMediator { ...@@ -158,4 +155,13 @@ class StartSurfaceToolbarMediator {
&& mIsGoogleSearchEngine; && mIsGoogleSearchEngine;
mPropertyModel.set(LOGO_IS_VISIBLE, shouldShowLogo); mPropertyModel.set(LOGO_IS_VISIBLE, shouldShowLogo);
} }
private void updateNewTabButtonVisibility() {
// This toolbar is only shown for tab switcher when accessibility is enabled. Note that
// OverviewListLayout will be shown as the tab switcher instead of the star surface.
boolean isShownTabswitcherState = mOverviewModeState == OverviewModeState.SHOWN_TABSWITCHER
|| mOverviewModeState == OverviewModeState.SHOWN_TABSWITCHER_TASKS_ONLY
|| AccessibilityUtil.isAccessibilityEnabled();
mPropertyModel.set(NEW_TAB_BUTTON_IS_VISIBLE, isShownTabswitcherState);
}
} }
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