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" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 std::unique_ptr<base::DictionaryValue> manifest) { | 67 std::unique_ptr<base::DictionaryValue> manifest) { |
68 // Read the public key from the manifest and set the command line. | 68 // Read the public key from the manifest and set the command line. |
69 std::string override_public_key; | 69 std::string override_public_key; |
70 if (manifest->GetString("origin-trials.public-key", &override_public_key)) { | 70 if (manifest->GetString("origin-trials.public-key", &override_public_key)) { |
71 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 71 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
72 command_line->AppendSwitchASCII(switches::kOriginTrialPublicKey, | 72 command_line->AppendSwitchASCII(switches::kOriginTrialPublicKey, |
73 override_public_key); | 73 override_public_key); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 base::FilePath OriginTrialsComponentInstallerTraits::GetBaseDirectory() const { | 77 base::FilePath OriginTrialsComponentInstallerTraits::GetRelativeInstallDir() |
78 base::FilePath result; | 78 const { |
79 PathService::Get(DIR_ORIGIN_TRIAL_KEYS, &result); | 79 return base::FilePath(FILE_PATH_LITERAL("OriginTrials")); |
80 return result; | |
81 } | 80 } |
82 | 81 |
83 void OriginTrialsComponentInstallerTraits::GetHash( | 82 void OriginTrialsComponentInstallerTraits::GetHash( |
84 std::vector<uint8_t>* hash) const { | 83 std::vector<uint8_t>* hash) const { |
85 if (!hash) | 84 if (!hash) |
86 return; | 85 return; |
87 hash->assign(kSha256Hash, kSha256Hash + arraysize(kSha256Hash)); | 86 hash->assign(kSha256Hash, kSha256Hash + arraysize(kSha256Hash)); |
88 } | 87 } |
89 | 88 |
90 std::string OriginTrialsComponentInstallerTraits::GetName() const { | 89 std::string OriginTrialsComponentInstallerTraits::GetName() const { |
91 return "Origin Trials"; | 90 return "Origin Trials"; |
92 } | 91 } |
93 | 92 |
94 std::string OriginTrialsComponentInstallerTraits::GetAp() const { | 93 std::string OriginTrialsComponentInstallerTraits::GetAp() const { |
95 return std::string(); | 94 return std::string(); |
96 } | 95 } |
97 | 96 |
98 void RegisterOriginTrialsComponent(ComponentUpdateService* cus, | 97 void RegisterOriginTrialsComponent(ComponentUpdateService* cus, |
99 const base::FilePath& user_data_dir) { | 98 const base::FilePath& user_data_dir) { |
100 std::unique_ptr<ComponentInstallerTraits> traits( | 99 std::unique_ptr<ComponentInstallerTraits> traits( |
101 new OriginTrialsComponentInstallerTraits()); | 100 new OriginTrialsComponentInstallerTraits()); |
102 // |cus| will take ownership of |installer| during installer->Register(cus). | 101 // |cus| will take ownership of |installer| during installer->Register(cus). |
103 DefaultComponentInstaller* installer = | 102 DefaultComponentInstaller* installer = |
104 new DefaultComponentInstaller(std::move(traits)); | 103 new DefaultComponentInstaller(std::move(traits)); |
105 installer->Register(cus, base::Closure()); | 104 installer->Register(cus, base::Closure()); |
106 } | 105 } |
107 | 106 |
108 } // namespace component_updater | 107 } // namespace component_updater |
OLD | NEW |