| Index: chrome/common/origin_trials/chrome_origin_trial_policy.cc
|
| diff --git a/chrome/common/origin_trials/chrome_origin_trial_policy.cc b/chrome/common/origin_trials/chrome_origin_trial_policy.cc
|
| index a4dbcc3a57015432aac543081342a8532aa4cbc4..d23c0fe958baaba36e3824a50a390db6b38e6ba0 100644
|
| --- a/chrome/common/origin_trials/chrome_origin_trial_policy.cc
|
| +++ b/chrome/common/origin_trials/chrome_origin_trial_policy.cc
|
| @@ -6,8 +6,11 @@
|
|
|
| #include <stdint.h>
|
|
|
| +#include <vector>
|
| +
|
| #include "base/base64.h"
|
| #include "base/command_line.h"
|
| +#include "base/strings/string_split.h"
|
| #include "chrome/common/chrome_switches.h"
|
|
|
| // This is the default public key used for validating signatures.
|
| @@ -22,15 +25,20 @@ static const uint8_t kDefaultPublicKey[] = {
|
| ChromeOriginTrialPolicy::ChromeOriginTrialPolicy()
|
| : public_key_(std::string(reinterpret_cast<const char*>(kDefaultPublicKey),
|
| arraysize(kDefaultPublicKey))) {
|
| - // Set the public key for the origin trial key manager, based on the command
|
| - // line flags which were passed to this process. If the flag is not present,
|
| - // or is incorrectly formatted, the default key will remain active.
|
| + // Set the public key and disabled feature list for the origin trial key
|
| + // manager, based on the command line flags which were passed to this process.
|
| + // If the flags are not present, or are incorrectly formatted, the defaults
|
| + // will remain active.
|
| if (base::CommandLine::InitializedForCurrentProcess()) {
|
| base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
| if (command_line->HasSwitch(switches::kOriginTrialPublicKey)) {
|
| SetPublicKeyFromASCIIString(
|
| command_line->GetSwitchValueASCII(switches::kOriginTrialPublicKey));
|
| }
|
| + if (command_line->HasSwitch(switches::kOriginTrialDisabledFeatures)) {
|
| + SetDisabledFeatures(command_line->GetSwitchValueASCII(
|
| + switches::kOriginTrialDisabledFeatures));
|
| + }
|
| }
|
| }
|
|
|
| @@ -40,6 +48,11 @@ base::StringPiece ChromeOriginTrialPolicy::GetPublicKey() const {
|
| return base::StringPiece(public_key_);
|
| }
|
|
|
| +bool ChromeOriginTrialPolicy::IsFeatureDisabled(
|
| + base::StringPiece feature) const {
|
| + return disabled_features_.count(feature.as_string()) > 0;
|
| +}
|
| +
|
| bool ChromeOriginTrialPolicy::SetPublicKeyFromASCIIString(
|
| const std::string& ascii_public_key) {
|
| // Base64-decode the incoming string. Set the key if it is correctly formatted
|
| @@ -51,3 +64,15 @@ bool ChromeOriginTrialPolicy::SetPublicKeyFromASCIIString(
|
| public_key_.swap(new_public_key);
|
| return true;
|
| }
|
| +
|
| +bool ChromeOriginTrialPolicy::SetDisabledFeatures(
|
| + const std::string& disabled_feature_list) {
|
| + std::set<std::string> new_disabled_features;
|
| + const std::vector<std::string> features =
|
| + base::SplitString(disabled_feature_list, "|", base::TRIM_WHITESPACE,
|
| + base::SPLIT_WANT_NONEMPTY);
|
| + for (const std::string& feature : features)
|
| + new_disabled_features.insert(feature);
|
| + disabled_features_.swap(new_disabled_features);
|
| + return true;
|
| +}
|
|
|