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

Side by Side Diff: chrome/common/origin_trials/origin_trial_key_manager.cc

Issue 1741783002: Add disabled origin trial feature list (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ef-finch
Patch Set: Separate the introduction of preference-persistence into a different CL Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/origin_trials/origin_trial_key_manager.h" 5 #include "chrome/common/origin_trials/origin_trial_key_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <vector>
10
9 #include "base/base64.h" 11 #include "base/base64.h"
12 #include "base/strings/string_split.h"
10 13
11 // This is the default public key used for validating signatures. 14 // This is the default public key used for validating signatures.
12 // TODO(iclelland): Provide a mechanism to allow for multiple signing keys. 15 // TODO(iclelland): Provide a mechanism to allow for multiple signing keys.
13 // https://crbug.com/584737 16 // https://crbug.com/584737
14 static const uint8_t kDefaultPublicKey[] = { 17 static const uint8_t kDefaultPublicKey[] = {
15 0x7c, 0xc4, 0xb8, 0x9a, 0x93, 0xba, 0x6e, 0xe2, 0xd0, 0xfd, 0x03, 18 0x7c, 0xc4, 0xb8, 0x9a, 0x93, 0xba, 0x6e, 0xe2, 0xd0, 0xfd, 0x03,
16 0x1d, 0xfb, 0x32, 0x66, 0xc7, 0x3b, 0x72, 0xfd, 0x54, 0x3a, 0x07, 19 0x1d, 0xfb, 0x32, 0x66, 0xc7, 0x3b, 0x72, 0xfd, 0x54, 0x3a, 0x07,
17 0x51, 0x14, 0x66, 0xaa, 0x02, 0x53, 0x4e, 0x33, 0xa1, 0x15, 20 0x51, 0x14, 0x66, 0xaa, 0x02, 0x53, 0x4e, 0x33, 0xa1, 0x15,
18 }; 21 };
19 22
(...skipping 11 matching lines...) Expand all
31 return false; 34 return false;
32 if (new_public_key.size() != 32) 35 if (new_public_key.size() != 32)
33 return false; 36 return false;
34 public_key_.swap(new_public_key); 37 public_key_.swap(new_public_key);
35 return true; 38 return true;
36 } 39 }
37 40
38 base::StringPiece OriginTrialKeyManager::GetPublicKey() const { 41 base::StringPiece OriginTrialKeyManager::GetPublicKey() const {
39 return base::StringPiece(public_key_); 42 return base::StringPiece(public_key_);
40 } 43 }
44
45 bool OriginTrialKeyManager::SetDisabledFeatures(
46 const std::string& disabled_feature_list) {
47 std::vector<std::string> features =
Sorin Jianu 2016/06/07 17:20:24 can be const.
iclelland 2016/06/08 13:37:56 Done.
48 base::SplitString(disabled_feature_list, "|", base::TRIM_WHITESPACE,
49 base::SPLIT_WANT_NONEMPTY);
50 for (std::string feature : features)
Sorin Jianu 2016/06/07 17:20:24 maybe use ref to const or const auto& for the rang
iclelland 2016/06/08 13:37:56 Done.
51 disabled_features_.insert(feature);
chasej 2016/06/07 15:51:31 Is this intended to append to the existing set of
iclelland 2016/06/08 13:37:56 That's a good point. It should probably clear the
52 return true;
53 }
54
55 bool OriginTrialKeyManager::IsFeatureDisabled(base::StringPiece feature) {
56 return disabled_features_.count(feature.as_string()) > 0;
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698