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..c293df514cfda60bf7d0c2afe61ff8df3ce58980 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 |
| @@ -6,27 +6,35 @@ package org.chromium.chrome.browser.physicalweb; |
| import android.content.Context; |
| import android.os.AsyncTask; |
| +import android.text.TextUtils; |
| import org.chromium.base.CommandLine; |
| import org.chromium.chrome.browser.ChromeApplication; |
| import org.chromium.chrome.browser.ChromeSwitches; |
| import org.chromium.chrome.browser.ChromeVersionInfo; |
| +import org.chromium.components.variations.VariationsAssociatedData; |
| /** |
| * 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. |
|
Alexei Svitkine (slow)
2015/12/16 20:11:30
"Finch" is an internal codename. Don't use it in c
|
| boolean allowedChannel = |
| ChromeVersionInfo.isLocalBuild() || ChromeVersionInfo.isDevBuild(); |
| boolean switchEnabled = |
| CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_PHYSICAL_WEB); |
|
Alexei Svitkine (slow)
2015/12/16 20:11:30
You should also have a disable switch, so that if
|
| - return allowedChannel && switchEnabled; |
| + // Check chrome://flag, command line flag, and finch, in that order |
| + return (allowedChannel && switchEnabled) || getBooleanParam(ENABLED_PARAM, false); |
|
Alexei Svitkine (slow)
2015/12/16 20:11:30
The current logic won't integrate well with go/var
|
| } |
| /** |
| @@ -70,4 +78,24 @@ 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. |
|
nyquist
2015/12/17 02:02:23
Couldn't you force the trial through a command lin
|
| + * @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) { |
| + if (CommandLine.getInstance().hasSwitch(paramName)) { |
| + return true; |
| + } |
| + String paramValue = |
| + VariationsAssociatedData.getVariationParamValue(FIELD_TRIAL_NAME, paramName); |
| + if (TextUtils.isEmpty(paramValue)) { |
| + return defaultValue; |
| + } |
| + return TextUtils.equals(ENABLED_VALUE, paramValue); |
| + } |
| } |