Commit 95fbeff5 authored by Mei Liang's avatar Mei Liang Committed by Commit Bot

Cache TabGroupsAndroid feature flag

The CL only caches the TabGroupAndroid feature flag for devices that
are eligible for tab group.

Bug: 934557
Change-Id: I200bd417e60897c39675eb80b37abbe610e957df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1501912
Commit-Queue: Mei Liang <meiliang@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638347}
parent 1daccaee
...@@ -284,6 +284,12 @@ public class ChromePreferenceManager { ...@@ -284,6 +284,12 @@ public class ChromePreferenceManager {
public static final String TWA_DIALOG_NUMBER_OF_DIMSISSALS_ON_CLEAR_DATA = public static final String TWA_DIALOG_NUMBER_OF_DIMSISSALS_ON_CLEAR_DATA =
"twa_dialog_number_of_dismissals_on_clear_data"; "twa_dialog_number_of_dismissals_on_clear_data";
/**
* Whether or not the tab group is enabled.
* Default value is false.
*/
public static final String TAB_GROUPS_ANDROID_ENABLED_KEY = "tab_group_android_enabled";
/** /**
* Deprecated keys for Chrome Home. * Deprecated keys for Chrome Home.
*/ */
......
...@@ -79,6 +79,7 @@ public class FeatureUtilities { ...@@ -79,6 +79,7 @@ public class FeatureUtilities {
private static Boolean sShouldInflateToolbarOnBackgroundThread; private static Boolean sShouldInflateToolbarOnBackgroundThread;
private static Boolean sIsNightModeAvailable; private static Boolean sIsNightModeAvailable;
private static Boolean sShouldPrioritizeBootstrapTasks; private static Boolean sShouldPrioritizeBootstrapTasks;
private static Boolean sIsTabGroupsAndroidEnabled;
private static Boolean sDownloadAutoResumptionEnabledInNative; private static Boolean sDownloadAutoResumptionEnabledInNative;
...@@ -198,6 +199,8 @@ public class FeatureUtilities { ...@@ -198,6 +199,8 @@ public class FeatureUtilities {
cacheDownloadAutoResumptionEnabledInNative(); cacheDownloadAutoResumptionEnabledInNative();
cachePrioritizeBootstrapTasks(); cachePrioritizeBootstrapTasks();
if (isDeviceEligibleForTabGroups()) cacheTabGroupsAndroidEnabled();
// Propagate DONT_PREFETCH_LIBRARIES and REACHED_CODE_PROFILER feature values to // Propagate DONT_PREFETCH_LIBRARIES and REACHED_CODE_PROFILER feature values to
// LibraryLoader. This can't be done in LibraryLoader itself because it lives in //base and // LibraryLoader. This can't be done in LibraryLoader itself because it lives in //base and
// can't depend on ChromeFeatureList. // can't depend on ChromeFeatureList.
...@@ -495,14 +498,33 @@ public class FeatureUtilities { ...@@ -495,14 +498,33 @@ public class FeatureUtilities {
&& ChromeFeatureList.isEnabled(ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID); && ChromeFeatureList.isEnabled(ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID);
} }
private static void cacheTabGroupsAndroidEnabled() {
ChromePreferenceManager.getInstance().writeBoolean(
ChromePreferenceManager.TAB_GROUPS_ANDROID_ENABLED_KEY,
ChromeFeatureList.isEnabled(ChromeFeatureList.TAB_GROUPS_ANDROID));
}
/** /**
* @param activityContext The context for the containing {@link android.app.Activity}.
* @return Whether the tab group feature is enabled and available for use. * @return Whether the tab group feature is enabled and available for use.
*/ */
public static boolean isTabGroupsEnabled(Context activityContext) { public static boolean isTabGroupsAndroidEnabled() {
return !DeviceFormFactor.isNonMultiDisplayContextOnTablet(activityContext) if (!isDeviceEligibleForTabGroups()) return false;
&& !SysUtils.isLowEndDevice() && !DeviceClassManager.enableAccessibilityLayout()
&& ChromeFeatureList.isEnabled(ChromeFeatureList.TAB_GROUPS_ANDROID); if (sIsTabGroupsAndroidEnabled == null) {
ChromePreferenceManager preferenceManager = ChromePreferenceManager.getInstance();
sIsTabGroupsAndroidEnabled = preferenceManager.readBoolean(
ChromePreferenceManager.TAB_GROUPS_ANDROID_ENABLED_KEY, false);
}
return sIsTabGroupsAndroidEnabled;
}
private static boolean isDeviceEligibleForTabGroups() {
return !SysUtils.isLowEndDevice()
&& !DeviceFormFactor.isNonMultiDisplayContextOnTablet(
ContextUtils.getApplicationContext())
&& !DeviceClassManager.enableAccessibilityLayout();
} }
/** /**
......
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