Chromium Code Reviews| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 */ | 147 */ |
| 148 public static void setIsInMultiWindowMode(boolean isInMultiWindowMode) { | 148 public static void setIsInMultiWindowMode(boolean isInMultiWindowMode) { |
| 149 nativeSetIsInMultiWindowMode(isInMultiWindowMode); | 149 nativeSetIsInMultiWindowMode(isInMultiWindowMode); |
| 150 } | 150 } |
| 151 | 151 |
| 152 private static boolean isHerbDisallowed(Context context) { | 152 private static boolean isHerbDisallowed(Context context) { |
| 153 return isDocumentMode(context); | 153 return isDocumentMode(context); |
| 154 } | 154 } |
| 155 | 155 |
| 156 /** | 156 /** |
| 157 * @return Which flavor of Herb is being tested. See {@link ChromeSwitches# HERB_FLAVOR_ANISE} | 157 * @return Which flavor of Herb is being tested. |
| 158 * and its related switches. | 158 * See {@link ChromeSwitches#HERB_FLAVOR_ELDERBERRY} and its related switches. |
| 159 */ | 159 */ |
| 160 public static String getHerbFlavor() { | 160 public static String getHerbFlavor() { |
| 161 Context context = ContextUtils.getApplicationContext(); | 161 Context context = ContextUtils.getApplicationContext(); |
| 162 if (isHerbDisallowed(context)) return ChromeSwitches.HERB_FLAVOR_DISABLE D; | 162 if (isHerbDisallowed(context)) return ChromeSwitches.HERB_FLAVOR_DISABLE D; |
| 163 | 163 |
| 164 if (!sIsHerbFlavorCached) { | 164 if (!sIsHerbFlavorCached) { |
| 165 sCachedHerbFlavor = null; | 165 sCachedHerbFlavor = null; |
| 166 | 166 |
| 167 // Allowing disk access for preferences while prototyping. | 167 // Allowing disk access for preferences while prototyping. |
| 168 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads( ); | 168 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads( ); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 198 if (isHerbDisallowed(context)) return; | 198 if (isHerbDisallowed(context)) return; |
| 199 | 199 |
| 200 String oldFlavor = getHerbFlavor(); | 200 String oldFlavor = getHerbFlavor(); |
| 201 | 201 |
| 202 // Check the experiment value before the command line to put the user in the correct group. | 202 // Check the experiment value before the command line to put the user in the correct group. |
| 203 // The first clause does the null checks so so we can freely use the sta rtsWith() function. | 203 // The first clause does the null checks so so we can freely use the sta rtsWith() function. |
| 204 String newFlavor = FieldTrialList.findFullName(HERB_EXPERIMENT_NAME); | 204 String newFlavor = FieldTrialList.findFullName(HERB_EXPERIMENT_NAME); |
| 205 Log.d(TAG, "Experiment flavor: " + newFlavor); | 205 Log.d(TAG, "Experiment flavor: " + newFlavor); |
| 206 if (TextUtils.isEmpty(newFlavor) | 206 if (TextUtils.isEmpty(newFlavor) |
| 207 || newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_CONTROL) | 207 || newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_CONTROL) |
| 208 || newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_DEFAULT)) { | 208 || newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_DEFAULT)) { |
|
gone
2016/09/28 16:45:46
Should this just be the "else" clause to catch all
Ted C
2016/09/28 23:21:38
Done, although I don't "think" this is necessary (
| |
| 209 newFlavor = ChromeSwitches.HERB_FLAVOR_DISABLED; | 209 newFlavor = ChromeSwitches.HERB_FLAVOR_DISABLED; |
| 210 } else if (newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_ANISE)) { | |
| 211 newFlavor = ChromeSwitches.HERB_FLAVOR_ANISE; | |
| 212 } else if (newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_BASIL)) { | |
| 213 newFlavor = ChromeSwitches.HERB_FLAVOR_BASIL; | |
| 214 } else if (newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_CHIVE)) { | |
| 215 newFlavor = ChromeSwitches.HERB_FLAVOR_CHIVE; | |
| 216 } else if (newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_DILL)) { | |
| 217 newFlavor = ChromeSwitches.HERB_FLAVOR_DILL; | |
| 218 } else if (newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_ELDERBERRY)) { | 210 } else if (newFlavor.startsWith(ChromeSwitches.HERB_FLAVOR_ELDERBERRY)) { |
| 219 newFlavor = ChromeSwitches.HERB_FLAVOR_ELDERBERRY; | 211 newFlavor = ChromeSwitches.HERB_FLAVOR_ELDERBERRY; |
| 220 } | 212 } |
| 221 | 213 |
| 222 CommandLine instance = CommandLine.getInstance(); | 214 CommandLine instance = CommandLine.getInstance(); |
| 223 if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_DISABLED_SWITCH)) { | 215 if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_DISABLED_SWITCH)) { |
| 224 newFlavor = ChromeSwitches.HERB_FLAVOR_DISABLED; | 216 newFlavor = ChromeSwitches.HERB_FLAVOR_DISABLED; |
| 225 } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_ANISE_SWITCH)) { | |
| 226 newFlavor = ChromeSwitches.HERB_FLAVOR_ANISE; | |
| 227 } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_BASIL_SWITCH)) { | |
| 228 newFlavor = ChromeSwitches.HERB_FLAVOR_BASIL; | |
| 229 } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_CHIVE_SWITCH)) { | |
| 230 newFlavor = ChromeSwitches.HERB_FLAVOR_CHIVE; | |
| 231 } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_DILL_SWITCH)) { | |
| 232 newFlavor = ChromeSwitches.HERB_FLAVOR_DILL; | |
| 233 } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_ELDERBERRY_SWIT CH)) { | 217 } else if (instance.hasSwitch(ChromeSwitches.HERB_FLAVOR_ELDERBERRY_SWIT CH)) { |
| 234 newFlavor = ChromeSwitches.HERB_FLAVOR_ELDERBERRY; | 218 newFlavor = ChromeSwitches.HERB_FLAVOR_ELDERBERRY; |
| 235 } | 219 } |
| 236 | 220 |
| 237 Log.d(TAG, "Caching flavor: " + newFlavor); | 221 Log.d(TAG, "Caching flavor: " + newFlavor); |
| 238 sCachedHerbFlavor = newFlavor; | 222 sCachedHerbFlavor = newFlavor; |
| 239 | 223 |
| 240 if (!TextUtils.equals(oldFlavor, newFlavor)) { | 224 if (!TextUtils.equals(oldFlavor, newFlavor)) { |
| 241 ChromePreferenceManager.getInstance(context).setCachedHerbFlavor(new Flavor); | 225 ChromePreferenceManager.getInstance(context).setCachedHerbFlavor(new Flavor); |
| 242 } | 226 } |
| 243 } | 227 } |
| 244 | 228 |
| 245 /** | 229 /** |
| 246 * @return True if tab model merging for Android N+ is enabled. | 230 * @return True if tab model merging for Android N+ is enabled. |
| 247 */ | 231 */ |
| 248 public static boolean isTabModelMergingEnabled() { | 232 public static boolean isTabModelMergingEnabled() { |
| 249 return Build.VERSION.SDK_INT > Build.VERSION_CODES.M; | 233 return Build.VERSION.SDK_INT > Build.VERSION_CODES.M; |
| 250 } | 234 } |
| 251 | 235 |
| 252 private static native void nativeSetCustomTabVisible(boolean visible); | 236 private static native void nativeSetCustomTabVisible(boolean visible); |
| 253 private static native void nativeSetIsInMultiWindowMode(boolean isInMultiWin dowMode); | 237 private static native void nativeSetIsInMultiWindowMode(boolean isInMultiWin dowMode); |
| 254 } | 238 } |
| OLD | NEW |