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

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: review:asvtikine 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
« no previous file with comments | « base/metrics/field_trial_unittest.cc ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..3b477a2a2efa8645515f32390b41a679995f0ec8 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[] = {
Ilya Sherman 2014/02/11 23:05:04 nit: "const char* const"
gab 2014/02/12 13:48:29 Done.
+ "SettingsEnforcement",
+ };
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(KUnforceableFieldTrials); ++i) {
Ilya Sherman 2014/02/11 23:05:04 nit: Are you sure you need the unsafe version here
gab 2014/02/12 13:48:29 Yes, arraysize() itself doesn't work for types def
+ 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.";
}
« no previous file with comments | « base/metrics/field_trial_unittest.cc ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698