OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.util; | 5 package org.chromium.chrome.browser.util; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.Intent; | 10 import android.content.Intent; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 * mode is turned off). | 124 * mode is turned off). |
125 * | 125 * |
126 * This function can't be changed to return false (even if document mode is
deleted) because we | 126 * This function can't be changed to return false (even if document mode is
deleted) because we |
127 * need to know whether a user needs to be migrated away. | 127 * need to know whether a user needs to be migrated away. |
128 * | 128 * |
129 * @param context The context to use for checking configuration. | 129 * @param context The context to use for checking configuration. |
130 * @return Whether the device could possibly run in Document mode. | 130 * @return Whether the device could possibly run in Document mode. |
131 */ | 131 */ |
132 public static boolean isDocumentModeEligible(Context context) { | 132 public static boolean isDocumentModeEligible(Context context) { |
133 return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP | 133 return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP |
134 && !DeviceFormFactor.isTablet(context); | 134 && !DeviceFormFactor.isTablet(); |
135 } | 135 } |
136 | 136 |
137 /** | 137 /** |
138 * Records the current custom tab visibility state with native-side feature
utilities. | 138 * Records the current custom tab visibility state with native-side feature
utilities. |
139 * @param visible Whether a custom tab is visible. | 139 * @param visible Whether a custom tab is visible. |
140 */ | 140 */ |
141 public static void setCustomTabVisible(boolean visible) { | 141 public static void setCustomTabVisible(boolean visible) { |
142 nativeSetCustomTabVisible(visible); | 142 nativeSetCustomTabVisible(visible); |
143 } | 143 } |
144 | 144 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_TAB_MERGI
NG_FOR_TESTING)) { | 232 if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_TAB_MERGI
NG_FOR_TESTING)) { |
233 return false; | 233 return false; |
234 } | 234 } |
235 return Build.VERSION.SDK_INT > Build.VERSION_CODES.M; | 235 return Build.VERSION.SDK_INT > Build.VERSION_CODES.M; |
236 } | 236 } |
237 | 237 |
238 /** | 238 /** |
239 * Cache whether or not Chrome Home is enabled. | 239 * Cache whether or not Chrome Home is enabled. |
240 */ | 240 */ |
241 public static void cacheChromeHomeEnabled() { | 241 public static void cacheChromeHomeEnabled() { |
242 Context context = ContextUtils.getApplicationContext(); | |
243 | |
244 // Chrome Home doesn't work with tablets. | 242 // Chrome Home doesn't work with tablets. |
245 if (DeviceFormFactor.isTablet(context)) return; | 243 if (DeviceFormFactor.isTablet()) return; |
246 | 244 |
247 boolean isChromeHomeEnabled = ChromeFeatureList.isEnabled(ChromeFeatureL
ist.CHROME_HOME); | 245 boolean isChromeHomeEnabled = ChromeFeatureList.isEnabled(ChromeFeatureL
ist.CHROME_HOME); |
248 ChromePreferenceManager manager = ChromePreferenceManager.getInstance(); | 246 ChromePreferenceManager manager = ChromePreferenceManager.getInstance(); |
249 boolean valueChanged = isChromeHomeEnabled != manager.isChromeHomeEnable
d(); | 247 boolean valueChanged = isChromeHomeEnabled != manager.isChromeHomeEnable
d(); |
250 manager.setChromeHomeEnabled(isChromeHomeEnabled); | 248 manager.setChromeHomeEnabled(isChromeHomeEnabled); |
251 sChromeHomeEnabled = isChromeHomeEnabled; | 249 sChromeHomeEnabled = isChromeHomeEnabled; |
252 | 250 |
253 // If the cached value changed, restart chrome. | 251 // If the cached value changed, restart chrome. |
254 if (valueChanged) ApplicationLifetime.terminate(true); | 252 if (valueChanged) ApplicationLifetime.terminate(true); |
255 } | 253 } |
(...skipping 12 matching lines...) Expand all Loading... |
268 /** | 266 /** |
269 * @return Whether or not the expand button for Chrome Home is enabled. | 267 * @return Whether or not the expand button for Chrome Home is enabled. |
270 */ | 268 */ |
271 public static boolean isChromeHomeExpandButtonEnabled() { | 269 public static boolean isChromeHomeExpandButtonEnabled() { |
272 return ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_EXPAND_
BUTTON); | 270 return ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_EXPAND_
BUTTON); |
273 } | 271 } |
274 | 272 |
275 private static native void nativeSetCustomTabVisible(boolean visible); | 273 private static native void nativeSetCustomTabVisible(boolean visible); |
276 private static native void nativeSetIsInMultiWindowMode(boolean isInMultiWin
dowMode); | 274 private static native void nativeSetIsInMultiWindowMode(boolean isInMultiWin
dowMode); |
277 } | 275 } |
OLD | NEW |