Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/values.h" | |
| 12 #include "chrome/browser/browser_process.h" | |
| 11 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 12 #include "components/component_updater/component_updater_paths.h" | 14 #include "components/component_updater/component_updater_paths.h" |
| 15 #include "components/prefs/pref_service.h" | |
| 13 | 16 |
| 14 // The client-side configuration for the origin trial framework can be | 17 // The client-side configuration for the origin trial framework can be |
| 15 // overridden by an installed component named 'OriginTrials' (extension id | 18 // overridden by an installed component named 'OriginTrials' (extension id |
| 16 // kfoklmclfodeliojeaekpoflbkkhojea. This component currently consists of just a | 19 // kfoklmclfodeliojeaekpoflbkkhojea. This component currently consists of just a |
| 17 // manifest.json file, which can contain a custom key named 'origin-trials'. The | 20 // manifest.json file, which can contain a custom key named 'origin-trials'. The |
| 18 // value of this key is a dictionary: | 21 // value of this key is a dictionary: |
| 19 // | 22 // |
| 20 // { | 23 // { |
| 21 // "public-key": "<base64-encoding of replacement public key>", | 24 // "public-key": "<base64-encoding of replacement public key>", |
| 22 // "disabled-features": [<list of features to disable>], | 25 // "disabled-features": [<list of features to disable>], |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 bool OriginTrialsComponentInstallerTraits::OnCustomInstall( | 61 bool OriginTrialsComponentInstallerTraits::OnCustomInstall( |
| 59 const base::DictionaryValue& manifest, | 62 const base::DictionaryValue& manifest, |
| 60 const base::FilePath& install_dir) { | 63 const base::FilePath& install_dir) { |
| 61 return true; | 64 return true; |
| 62 } | 65 } |
| 63 | 66 |
| 64 void OriginTrialsComponentInstallerTraits::ComponentReady( | 67 void OriginTrialsComponentInstallerTraits::ComponentReady( |
| 65 const base::Version& version, | 68 const base::Version& version, |
| 66 const base::FilePath& install_dir, | 69 const base::FilePath& install_dir, |
| 67 std::unique_ptr<base::DictionaryValue> manifest) { | 70 std::unique_ptr<base::DictionaryValue> manifest) { |
| 68 // Read the public key from the manifest and set the command line. | 71 // Read the public key from the manifest and set values in browser |
| 72 // local_state. These will be used on the next browser restart. | |
| 73 PrefService* local_state = g_browser_process->local_state(); | |
| 69 std::string override_public_key; | 74 std::string override_public_key; |
| 70 if (manifest->GetString("origin-trials.public-key", &override_public_key)) { | 75 if (manifest->GetString("origin-trials.public-key", &override_public_key)) { |
| 71 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 76 local_state->Set("origin-trials.public-key", |
|
chasej
2016/06/07 15:09:40
Can this use the prefs::kOriginTrialPublicKey cons
iclelland
2016/06/08 02:48:22
It absolutely can, and should. Thanks. Done.
| |
| 72 command_line->AppendSwitchASCII(switches::kOriginTrialPublicKey, | 77 base::StringValue(override_public_key)); |
| 73 override_public_key); | |
| 74 } | 78 } |
| 75 } | 79 } |
| 76 | 80 |
| 77 base::FilePath OriginTrialsComponentInstallerTraits::GetRelativeInstallDir() | 81 base::FilePath OriginTrialsComponentInstallerTraits::GetRelativeInstallDir() |
| 78 const { | 82 const { |
| 79 return base::FilePath(FILE_PATH_LITERAL("OriginTrials")); | 83 return base::FilePath(FILE_PATH_LITERAL("OriginTrials")); |
| 80 } | 84 } |
| 81 | 85 |
| 82 void OriginTrialsComponentInstallerTraits::GetHash( | 86 void OriginTrialsComponentInstallerTraits::GetHash( |
| 83 std::vector<uint8_t>* hash) const { | 87 std::vector<uint8_t>* hash) const { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 98 const base::FilePath& user_data_dir) { | 102 const base::FilePath& user_data_dir) { |
| 99 std::unique_ptr<ComponentInstallerTraits> traits( | 103 std::unique_ptr<ComponentInstallerTraits> traits( |
| 100 new OriginTrialsComponentInstallerTraits()); | 104 new OriginTrialsComponentInstallerTraits()); |
| 101 // |cus| will take ownership of |installer| during installer->Register(cus). | 105 // |cus| will take ownership of |installer| during installer->Register(cus). |
| 102 DefaultComponentInstaller* installer = | 106 DefaultComponentInstaller* installer = |
| 103 new DefaultComponentInstaller(std::move(traits)); | 107 new DefaultComponentInstaller(std::move(traits)); |
| 104 installer->Register(cus, base::Closure()); | 108 installer->Register(cus, base::Closure()); |
| 105 } | 109 } |
| 106 | 110 |
| 107 } // namespace component_updater | 111 } // namespace component_updater |
| OLD | NEW |