Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWeb.java

Issue 1512113002: Read feature param for Physical Web experiment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698