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

Unified Diff: chrome/browser/origin_trials/origin_trial_controller.cc

Issue 1737693002: Allow command-line arguments to override EF public key (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments from PS#1 Created 4 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/origin_trials/origin_trial_controller.cc
diff --git a/chrome/browser/origin_trials/origin_trial_controller.cc b/chrome/browser/origin_trials/origin_trial_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fe39de758f15f243284b3d1b8a27519c3f0d1402
--- /dev/null
+++ b/chrome/browser/origin_trials/origin_trial_controller.cc
@@ -0,0 +1,31 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/origin_trials/origin_trial_controller.h"
+
+#include <string>
+
+#include "base/command_line.h"
+#include "chrome/common/chrome_switches.h"
+#include "components/variations/variations_associated_data.h"
+
+const char OriginTrialController::kFieldTrialName[] = "OriginTrials";
+const char OriginTrialController::kPublicKeyFieldName[] = "PublicKey";
+
+// static
+void OriginTrialController::UpdateCommandLineFromFieldTrials(
+ base::CommandLine* command_line) {
+ DCHECK(command_line);
Alexei Svitkine (slow) 2016/02/26 16:29:08 Nit: Not needed.
iclelland 2016/02/26 19:55:04 Removed.
+
+ std::map<std::string, std::string> field_params;
+ if (!variations::GetVariationParams(kFieldTrialName, &field_params)) {
Alexei Svitkine (slow) 2016/02/26 16:29:08 Nit: No {}'s
iclelland 2016/02/26 19:55:04 Thanks; these were all leftovers from my in-develo
+ return;
+ }
+
+ std::string override_public_key = field_params[kPublicKeyFieldName];
+ if (override_public_key.size()) {
Alexei Svitkine (slow) 2016/02/26 16:29:08 Nit: !.empty()
iclelland 2016/02/26 19:55:04 Done.
+ command_line->AppendSwitchASCII(switches::kOriginTrialPublicKey,
+ override_public_key);
Alexei Svitkine (slow) 2016/02/26 16:29:08 I'm not a big fan of plumbing this through the com
iclelland 2016/02/26 16:49:14 I wrote the command-line handling code first, as a
Alexei Svitkine (slow) 2016/02/26 17:32:20 Ah, you're right - I missed that you're checking i
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698