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

Unified Diff: chrome/browser/chrome_browser_main.cc

Issue 153913009: Make some field trials unforceable via command-line in the official build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months 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
Index: chrome/browser/chrome_browser_main.cc
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index d8608c9aca69b5f95a749f87c222f169251249ac..128f2e6b84315fbae21795d17a556690561e6994 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -483,6 +483,24 @@ void LaunchDevToolsHandlerIfNeeded(const CommandLine& command_line) {
}
}
+// Returns true if the field trial described by |name| is allowed to be forced
+// via --force-fieldtrials.
+bool IsForceableFieldTrial(const std::string& name) {
+#if defined(OFFICIAL_BUILD)
+ // A list of field trials which cannot be forced to a different value in the
+ // official build.
+ static const char* KUnforceableFieldTrials[] = {
Alexei Svitkine (slow) 2014/02/11 22:44:02 Nit: Lowercase k. Also, I don't think this needs t
gab 2014/02/11 22:53:55 Done. Yes it needs to be static; it's a compound
+ "SettingsEnforcement",
+ };
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(KUnforceableFieldTrials); ++i) {
+ if (name == KUnforceableFieldTrials[i])
+ return false;
+ }
+#endif // defined(OFFICIAL_BUILD)
+
+ return true;
+}
+
// Heap allocated class that listens for first page load, kicks off stat
// recording and then deletes itself.
class LoadCompleteListener : public content::NotificationObserver {
@@ -518,6 +536,7 @@ void InitializeAllPrefHashStores() {
chrome_prefs::InitializePrefHashStoreIfRequired(profile_path);
}
}
+
} // namespace
namespace chrome_browser {
@@ -606,7 +625,8 @@ void ChromeBrowserMainParts::SetupMetricsAndFieldTrials() {
// consistent manner with field trials created from the server.
bool result = base::FieldTrialList::CreateTrialsFromString(
command_line->GetSwitchValueASCII(switches::kForceFieldTrials),
- base::FieldTrialList::DONT_ACTIVATE_TRIALS);
+ base::FieldTrialList::DONT_ACTIVATE_TRIALS,
+ base::Bind(&IsForceableFieldTrial));
CHECK(result) << "Invalid --" << switches::kForceFieldTrials
<< " list specified.";
}

Powered by Google App Engine
This is Rietveld 408576698