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

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

Issue 2882133003: component_updater: add '_env_version' attribute for cros_component_installer (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « chrome/browser/component_updater/cros_component_installer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/cros_component_installer.h" 5 #include "chrome/browser/component_updater/cros_component_installer.h"
6 #include "base/task_scheduler/post_task.h" 6 #include "base/task_scheduler/post_task.h"
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/component_updater/component_installer_errors.h" 8 #include "chrome/browser/component_updater/component_installer_errors.h"
9 #include "components/component_updater/component_updater_paths.h" 9 #include "components/component_updater/component_updater_paths.h"
10 #include "components/crx_file/id_util.h" 10 #include "components/crx_file/id_util.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 if (loader) { 45 if (loader) {
46 loader->RegisterComponent(name, version, install_dir.value(), 46 loader->RegisterComponent(name, version, install_dir.value(),
47 base::Bind(&LogRegistrationResult, name)); 47 base::Bind(&LogRegistrationResult, name));
48 } else { 48 } else {
49 DVLOG(1) << "Failed to get ImageLoaderClient object."; 49 DVLOG(1) << "Failed to get ImageLoaderClient object.";
50 } 50 }
51 } 51 }
52 52
53 ComponentConfig::ComponentConfig(const std::string& name, 53 ComponentConfig::ComponentConfig(const std::string& name,
54 const std::string& dir, 54 const std::string& env_version,
55 const std::string& sha2hashstr) 55 const std::string& sha2hashstr)
56 : name(name), dir(dir), sha2hashstr(sha2hashstr) {} 56 : name(name), env_version(env_version), sha2hashstr(sha2hashstr) {}
57 ComponentConfig::~ComponentConfig() {} 57 ComponentConfig::~ComponentConfig() {}
58 58
59 CrOSComponentInstallerTraits::CrOSComponentInstallerTraits( 59 CrOSComponentInstallerTraits::CrOSComponentInstallerTraits(
60 const ComponentConfig& config) 60 const ComponentConfig& config)
61 : dir_name(config.dir), name(config.name) { 61 : name(config.name), env_version(config.env_version) {
62 if (config.sha2hashstr.length() != 64) 62 if (config.sha2hashstr.length() != 64)
63 return; 63 return;
64 auto strstream = config.sha2hashstr; 64 auto strstream = config.sha2hashstr;
65 for (auto& cell : kSha2Hash_) { 65 for (auto& cell : kSha2Hash_) {
66 cell = stoul(strstream.substr(0, 2), nullptr, 16); 66 cell = stoul(strstream.substr(0, 2), nullptr, 16);
67 strstream.erase(0, 2); 67 strstream.erase(0, 2);
68 } 68 }
69 } 69 }
70 70
71 bool CrOSComponentInstallerTraits::SupportsGroupPolicyEnabledComponentUpdates() 71 bool CrOSComponentInstallerTraits::SupportsGroupPolicyEnabledComponentUpdates()
(...skipping 25 matching lines...) Expand all
97 const base::FilePath& path, 97 const base::FilePath& path,
98 std::unique_ptr<base::DictionaryValue> manifest) {} 98 std::unique_ptr<base::DictionaryValue> manifest) {}
99 99
100 bool CrOSComponentInstallerTraits::VerifyInstallation( 100 bool CrOSComponentInstallerTraits::VerifyInstallation(
101 const base::DictionaryValue& manifest, 101 const base::DictionaryValue& manifest,
102 const base::FilePath& install_dir) const { 102 const base::FilePath& install_dir) const {
103 return true; 103 return true;
104 } 104 }
105 105
106 base::FilePath CrOSComponentInstallerTraits::GetRelativeInstallDir() const { 106 base::FilePath CrOSComponentInstallerTraits::GetRelativeInstallDir() const {
107 return base::FilePath(dir_name); 107 return base::FilePath(name);
108 } 108 }
109 109
110 void CrOSComponentInstallerTraits::GetHash(std::vector<uint8_t>* hash) const { 110 void CrOSComponentInstallerTraits::GetHash(std::vector<uint8_t>* hash) const {
111 hash->assign(kSha2Hash_, kSha2Hash_ + arraysize(kSha2Hash_)); 111 hash->assign(kSha2Hash_, kSha2Hash_ + arraysize(kSha2Hash_));
112 } 112 }
113 113
114 std::string CrOSComponentInstallerTraits::GetName() const { 114 std::string CrOSComponentInstallerTraits::GetName() const {
115 return name; 115 return name;
116 } 116 }
117 117
118 update_client::InstallerAttributes 118 update_client::InstallerAttributes
119 CrOSComponentInstallerTraits::GetInstallerAttributes() const { 119 CrOSComponentInstallerTraits::GetInstallerAttributes() const {
120 return update_client::InstallerAttributes(); 120 update_client::InstallerAttributes attrs;
121 attrs["_env_version"] = env_version;
122 return attrs;
121 } 123 }
122 124
123 std::vector<std::string> CrOSComponentInstallerTraits::GetMimeTypes() const { 125 std::vector<std::string> CrOSComponentInstallerTraits::GetMimeTypes() const {
124 std::vector<std::string> mime_types; 126 std::vector<std::string> mime_types;
125 return mime_types; 127 return mime_types;
126 } 128 }
127 129
128 void CrOSComponent::RegisterCrOSComponentInternal( 130 void CrOSComponent::RegisterCrOSComponentInternal(
129 ComponentUpdateService* cus, 131 ComponentUpdateService* cus,
130 const ComponentConfig& config, 132 const ComponentConfig& config,
(...skipping 12 matching lines...) Expand all
143 const std::string& id, 145 const std::string& id,
144 const update_client::Callback& install_callback) { 146 const update_client::Callback& install_callback) {
145 cus->GetOnDemandUpdater().OnDemandUpdate(id, install_callback); 147 cus->GetOnDemandUpdater().OnDemandUpdate(id, install_callback);
146 } 148 }
147 149
148 bool CrOSComponent::InstallCrOSComponent( 150 bool CrOSComponent::InstallCrOSComponent(
149 const std::string& name, 151 const std::string& name,
150 const update_client::Callback& install_callback) { 152 const update_client::Callback& install_callback) {
151 auto* const cus = g_browser_process->component_updater(); 153 auto* const cus = g_browser_process->component_updater();
152 const ConfigMap components = { 154 const ConfigMap components = {
153 {"escpr", 155 {"epson-inkjet-printer-escpr",
154 {{"dir", "epson-inkjet-printer-escpr"}, 156 {{"env_version", "0.0"},
155 {"sha2hashstr", 157 {"sha2hashstr",
156 "1913a5e0a6cad30b6f03e176177e0d7ed62c5d6700a9c66da556d7c3f5d6a47e"}}}}; 158 "1913a5e0a6cad30b6f03e176177e0d7ed62c5d6700a9c66da556d7c3f5d6a47e"}}}};
157 if (name.empty()) { 159 if (name.empty()) {
158 base::PostTask( 160 base::PostTask(
159 FROM_HERE, 161 FROM_HERE,
160 base::Bind(install_callback, update_client::Error::INVALID_ARGUMENT)); 162 base::Bind(install_callback, update_client::Error::INVALID_ARGUMENT));
161 return false; 163 return false;
162 } 164 }
163 const auto it = components.find(name); 165 const auto it = components.find(name);
164 if (it == components.end()) { 166 if (it == components.end()) {
165 DVLOG(1) << "[RegisterCrOSComponents] component " << name 167 DVLOG(1) << "[RegisterCrOSComponents] component " << name
166 << " is not in configuration."; 168 << " is not in configuration.";
167 base::PostTask( 169 base::PostTask(
168 FROM_HERE, 170 FROM_HERE,
169 base::Bind(install_callback, update_client::Error::INVALID_ARGUMENT)); 171 base::Bind(install_callback, update_client::Error::INVALID_ARGUMENT));
170 return false; 172 return false;
171 } 173 }
172 ComponentConfig config(it->first, it->second.find("dir")->second, 174 ComponentConfig config(it->first, it->second.find("env_version")->second,
173 it->second.find("sha2hashstr")->second); 175 it->second.find("sha2hashstr")->second);
174 RegisterCrOSComponentInternal( 176 RegisterCrOSComponentInternal(
175 cus, config, 177 cus, config,
176 base::Bind(InstallChromeOSComponent, cus, 178 base::Bind(InstallChromeOSComponent, cus,
177 crx_file::id_util::GenerateIdFromHex( 179 crx_file::id_util::GenerateIdFromHex(
178 it->second.find("sha2hashstr")->second) 180 it->second.find("sha2hashstr")->second)
179 .substr(0, 32), 181 .substr(0, 32),
180 install_callback)); 182 install_callback));
181 return true; 183 return true;
182 } 184 }
(...skipping 21 matching lines...) Expand all
204 chromeos::DBusThreadManager::Get()->GetImageLoaderClient(); 206 chromeos::DBusThreadManager::Get()->GetImageLoaderClient();
205 if (loader) { 207 if (loader) {
206 loader->LoadComponent(name, base::Bind(&MountResult, mount_callback)); 208 loader->LoadComponent(name, base::Bind(&MountResult, mount_callback));
207 } else { 209 } else {
208 DVLOG(1) << "Failed to get ImageLoaderClient object."; 210 DVLOG(1) << "Failed to get ImageLoaderClient object.";
209 } 211 }
210 } 212 }
211 #endif // defined(OS_CHROMEOS 213 #endif // defined(OS_CHROMEOS
212 214
213 } // namespace component_updater 215 } // namespace component_updater
OLDNEW
« no previous file with comments | « chrome/browser/component_updater/cros_component_installer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698