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

Side by Side Diff: chrome/browser/component_updater/origin_trials_component_installer.cc

Issue 2733023002: [Origin Trials] Support updates of disabled token list (Closed)
Patch Set: Address comments Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 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/browser/component_updater/origin_trials_component_installer.h" 5 #include "chrome/browser/component_updater/origin_trials_component_installer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "components/component_updater/component_updater_paths.h" 17 #include "components/component_updater/component_updater_paths.h"
18 #include "components/prefs/pref_service.h" 18 #include "components/prefs/pref_service.h"
19 #include "components/prefs/scoped_user_pref_update.h" 19 #include "components/prefs/scoped_user_pref_update.h"
20 20
21 // The client-side configuration for the origin trial framework can be 21 // The client-side configuration for the origin trial framework can be
22 // overridden by an installed component named 'OriginTrials' (extension id 22 // overridden by an installed component named 'OriginTrials' (extension id
23 // kfoklmclfodeliojeaekpoflbkkhojea. This component currently consists of just a 23 // llkgjffcdpffmhiakmfcdcblohccpfmo. This component currently consists of just a
24 // manifest.json file, which can contain a custom key named 'origin-trials'. The 24 // manifest.json file, which can contain a custom key named 'origin-trials'. The
25 // value of this key is a dictionary: 25 // value of this key is a dictionary:
26 // 26 //
27 // { 27 // {
28 // "public-key": "<base64-encoding of replacement public key>", 28 // "public-key": "<base64-encoding of replacement public key>",
29 // "disabled-features": [<list of features to disable>], 29 // "disabled-features": [<list of features to disable>],
30 // "revoked-tokens": "<base64-encoded data>" 30 // "disabled-tokens":
31 // {
32 // "signatures": [<list of token signatures to disable, base64-encoded>]
33 // }
31 // } 34 // }
32 // 35 //
33 // TODO(iclelland): Implement support for revoked tokens.
34 //
35 // If the component is not present in the user data directory, the default 36 // If the component is not present in the user data directory, the default
36 // configuration will be used. 37 // configuration will be used.
37 38
38 namespace component_updater { 39 namespace component_updater {
39 40
40 namespace { 41 namespace {
41 42
42 static const char kManifestOriginTrialsKey[] = "origin-trials"; 43 static const char kManifestOriginTrialsKey[] = "origin-trials";
43 static const char kManifestPublicKeyPath[] = "origin-trials.public-key"; 44 static const char kManifestPublicKeyPath[] = "origin-trials.public-key";
44 static const char kManifestDisabledFeaturesPath[] = 45 static const char kManifestDisabledFeaturesPath[] =
45 "origin-trials.disabled-features"; 46 "origin-trials.disabled-features";
47 static const char kManifestDisabledTokenSignaturesPath[] =
48 "origin-trials.disabled-tokens.signatures";
46 49
47 // Extension id is llkgjffcdpffmhiakmfcdcblohccpfmo 50 // Extension id is llkgjffcdpffmhiakmfcdcblohccpfmo
48 const uint8_t kSha256Hash[] = {0xbb, 0xa6, 0x95, 0x52, 0x3f, 0x55, 0xc7, 0x80, 51 const uint8_t kSha256Hash[] = {0xbb, 0xa6, 0x95, 0x52, 0x3f, 0x55, 0xc7, 0x80,
49 0xac, 0x52, 0x32, 0x1b, 0xe7, 0x22, 0xf5, 0xce, 52 0xac, 0x52, 0x32, 0x1b, 0xe7, 0x22, 0xf5, 0xce,
50 0x6a, 0xfd, 0x9c, 0x9e, 0xa9, 0x2a, 0x0b, 0x50, 53 0x6a, 0xfd, 0x9c, 0x9e, 0xa9, 0x2a, 0x0b, 0x50,
51 0x60, 0x2b, 0x7f, 0x6c, 0x64, 0x80, 0x09, 0x04}; 54 0x60, 0x2b, 0x7f, 0x6c, 0x64, 0x80, 0x09, 0x04};
52 55
53 } // namespace 56 } // namespace
54 57
55 bool OriginTrialsComponentInstallerTraits::VerifyInstallation( 58 bool OriginTrialsComponentInstallerTraits::VerifyInstallation(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 base::ListValue* override_disabled_feature_list = nullptr; 97 base::ListValue* override_disabled_feature_list = nullptr;
95 const bool manifest_has_disabled_features = manifest->GetList( 98 const bool manifest_has_disabled_features = manifest->GetList(
96 kManifestDisabledFeaturesPath, &override_disabled_feature_list); 99 kManifestDisabledFeaturesPath, &override_disabled_feature_list);
97 if (manifest_has_disabled_features && 100 if (manifest_has_disabled_features &&
98 !override_disabled_feature_list->empty()) { 101 !override_disabled_feature_list->empty()) {
99 ListPrefUpdate update(local_state, prefs::kOriginTrialDisabledFeatures); 102 ListPrefUpdate update(local_state, prefs::kOriginTrialDisabledFeatures);
100 update->Swap(override_disabled_feature_list); 103 update->Swap(override_disabled_feature_list);
101 } else { 104 } else {
102 local_state->ClearPref(prefs::kOriginTrialDisabledFeatures); 105 local_state->ClearPref(prefs::kOriginTrialDisabledFeatures);
103 } 106 }
107 base::ListValue* disabled_tokens_list = nullptr;
108 const bool manifest_has_disabled_tokens = manifest->GetList(
109 kManifestDisabledTokenSignaturesPath, &disabled_tokens_list);
110 if (manifest_has_disabled_tokens && !disabled_tokens_list->empty()) {
111 ListPrefUpdate update(local_state, prefs::kOriginTrialDisabledTokens);
112 update->Swap(disabled_tokens_list);
113 } else {
114 local_state->ClearPref(prefs::kOriginTrialDisabledTokens);
115 }
104 } 116 }
105 117
106 base::FilePath OriginTrialsComponentInstallerTraits::GetRelativeInstallDir() 118 base::FilePath OriginTrialsComponentInstallerTraits::GetRelativeInstallDir()
107 const { 119 const {
108 return base::FilePath(FILE_PATH_LITERAL("OriginTrials")); 120 return base::FilePath(FILE_PATH_LITERAL("OriginTrials"));
109 } 121 }
110 122
111 void OriginTrialsComponentInstallerTraits::GetHash( 123 void OriginTrialsComponentInstallerTraits::GetHash(
112 std::vector<uint8_t>* hash) const { 124 std::vector<uint8_t>* hash) const {
113 if (!hash) 125 if (!hash)
(...skipping 19 matching lines...) Expand all
133 const base::FilePath& user_data_dir) { 145 const base::FilePath& user_data_dir) {
134 std::unique_ptr<ComponentInstallerTraits> traits( 146 std::unique_ptr<ComponentInstallerTraits> traits(
135 new OriginTrialsComponentInstallerTraits()); 147 new OriginTrialsComponentInstallerTraits());
136 // |cus| will take ownership of |installer| during installer->Register(cus). 148 // |cus| will take ownership of |installer| during installer->Register(cus).
137 DefaultComponentInstaller* installer = 149 DefaultComponentInstaller* installer =
138 new DefaultComponentInstaller(std::move(traits)); 150 new DefaultComponentInstaller(std::move(traits));
139 installer->Register(cus, base::Closure()); 151 installer->Register(cus, base::Closure());
140 } 152 }
141 153
142 } // namespace component_updater 154 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698