Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java |
| index 5923cfea421d2c57cb47ba2de2e224d4a1cc1516..f89a20d25f0721a8bac1d71c5e0213b3912ddc3d 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java |
| @@ -16,17 +16,23 @@ import org.chromium.chrome.browser.ChromeVersionInfo; |
| * This class provides the basic interface to the Physical Web feature. |
| */ |
| public class PhysicalWeb { |
| + private static final String FIELD_TRIAL_NAME = "PhysicalWeb"; |
| + private static final String ENABLED_PARAM = "enabled"; |
| + private static final String ENABLED_VALUE = "true"; |
| + |
| /** |
| * Evaluate whether the environment is one in which the Physical Web should |
| * be enabled. |
| * @return true if the PhysicalWeb should be enabled |
| */ |
| public static boolean featureIsEnabled() { |
| + // TODO(cco3): Remove chrome://flag after Finch is experiment is more in place. |
|
mmocny
2015/12/10 15:07:04
I thought we still want to make the chrome://flag
cco3
2015/12/11 21:32:19
That's what I thought too, but this seriously comp
|
| boolean allowedChannel = |
| ChromeVersionInfo.isLocalBuild() || ChromeVersionInfo.isDevBuild(); |
| boolean switchEnabled = |
| CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_PHYSICAL_WEB); |
| - return allowedChannel && switchEnabled; |
| + // Check chrome://flag, command line flag, and finch, in that order |
| + return (allowedChannel && switchEnabled) || getBooleanParam(ENABLED_PARAM); |
| } |
| /** |
| @@ -70,4 +76,20 @@ public class PhysicalWeb { |
| }; |
| AsyncTask.THREAD_POOL_EXECUTOR.execute(task); |
| } |
| + |
| + /** |
| + * Gets a boolean Finch parameter, assuming the <paramName>="true" format. Also checks for a |
| + * command-line switch with the same name, for easy local testing. |
| + * @param paramName The name of the Finch parameter (or command-line switch) to get a value for. |
| + * @param defaultValue The default value to return when there's no param or switch. |
| + * @return Whether the Finch param is defined with a value "true", if there's a command-line |
| + * flag present with any value. |
| + */ |
| + private static boolean getBooleanParam(String paramName, boolean defaultValue) { |
|
nyquist
2015/12/10 00:04:06
defaultValue doesn't seem to be used? In the call
cco3
2015/12/10 01:22:54
Done.
|
| + if (CommandLine.getInstance().hasSwitch(paramName)) { |
| + return true; |
| + } |
| + return TextUtils.equals(ENABLED_VALUE, |
| + VariationsAssociatedData.getVariationParamValue(FIELD_TRIAL_NAME, paramName)); |
| + } |
| } |