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

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: Const correctness; clear disabled features 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::set<std::string> new_disabled_features;
48 const std::vector<std::string> features =
49 base::SplitString(disabled_feature_list, "|", base::TRIM_WHITESPACE,
50 base::SPLIT_WANT_NONEMPTY);
51 for (const std::string& feature : features)
52 new_disabled_features.insert(feature);
53 disabled_features_.swap(new_disabled_features);
54 return true;
55 }
56
57 bool OriginTrialKeyManager::IsFeatureDisabled(base::StringPiece feature) const {
58 return disabled_features_.count(feature.as_string()) > 0;
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698