| OLD | NEW |
| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 update_client::InstallerAttributes attrs; | 120 update_client::InstallerAttributes attrs; |
| 121 attrs["_env_version"] = env_version; | 121 attrs["_env_version"] = env_version; |
| 122 return attrs; | 122 return attrs; |
| 123 } | 123 } |
| 124 | 124 |
| 125 std::vector<std::string> CrOSComponentInstallerTraits::GetMimeTypes() const { | 125 std::vector<std::string> CrOSComponentInstallerTraits::GetMimeTypes() const { |
| 126 std::vector<std::string> mime_types; | 126 std::vector<std::string> mime_types; |
| 127 return mime_types; | 127 return mime_types; |
| 128 } | 128 } |
| 129 | 129 |
| 130 CrOSComponentInstaller::CrOSComponentInstaller( |
| 131 std::unique_ptr<ComponentInstallerTraits> installer_traits) |
| 132 : DefaultComponentInstaller(std::move(installer_traits)) {} |
| 133 |
| 134 CrOSComponentInstaller::~CrOSComponentInstaller() {} |
| 135 |
| 136 std::unique_ptr<base::DictionaryValue> |
| 137 CrOSComponentInstaller::GetCurrentManifest() { |
| 138 std::unique_ptr<base::DictionaryValue> manifest_copy( |
| 139 current_manifest_->DeepCopy()); |
| 140 return manifest_copy; |
| 141 } |
| 142 |
| 130 void CrOSComponent::RegisterCrOSComponentInternal( | 143 void CrOSComponent::RegisterCrOSComponentInternal( |
| 131 ComponentUpdateService* cus, | 144 ComponentUpdateService* cus, |
| 132 const ComponentConfig& config, | 145 const ComponentConfig& config, |
| 133 const base::Closure& installcallback) { | 146 const base::Closure& installcallback) { |
| 134 std::unique_ptr<ComponentInstallerTraits> traits( | 147 std::unique_ptr<ComponentInstallerTraits> traits( |
| 135 new CrOSComponentInstallerTraits(config)); | 148 new CrOSComponentInstallerTraits(config)); |
| 136 // |cus| will take ownership of |installer| during | 149 scoped_refptr<CrOSComponentInstaller> installer = |
| 137 // installer->Register(cus). | 150 g_browser_process->platform_part()->GetCrosComponentInstaller( |
| 138 DefaultComponentInstaller* installer = | 151 config.name, std::move(traits)); |
| 139 new DefaultComponentInstaller(std::move(traits)); | |
| 140 installer->Register(cus, installcallback); | 152 installer->Register(cus, installcallback); |
| 141 } | 153 } |
| 142 | 154 |
| 143 void CrOSComponent::InstallChromeOSComponent( | 155 void CrOSComponent::InstallChromeOSComponent( |
| 144 ComponentUpdateService* cus, | 156 ComponentUpdateService* cus, |
| 145 const std::string& id, | 157 const std::string& id, |
| 146 const update_client::Callback& install_callback) { | 158 const update_client::Callback& install_callback) { |
| 147 cus->GetOnDemandUpdater().OnDemandUpdate(id, install_callback); | 159 cus->GetOnDemandUpdater().OnDemandUpdate(id, install_callback); |
| 148 } | 160 } |
| 149 | 161 |
| 150 bool CrOSComponent::InstallCrOSComponent( | 162 bool CrOSComponent::InstallCrOSComponent( |
| 151 const std::string& name, | 163 const std::string& name, |
| 152 const update_client::Callback& install_callback) { | 164 const update_client::Callback& install_callback) { |
| 153 auto* const cus = g_browser_process->component_updater(); | 165 auto* const cus = g_browser_process->component_updater(); |
| 154 const ConfigMap components = { | 166 const ConfigMap components = { |
| 155 {"epson-inkjet-printer-escpr", | 167 {"epson-inkjet-printer-escpr", |
| 156 {{"env_version", "0.0"}, | 168 {{"env_version", "2.0"}, |
| 157 {"sha2hashstr", | 169 {"sha2hashstr", |
| 158 "1913a5e0a6cad30b6f03e176177e0d7ed62c5d6700a9c66da556d7c3f5d6a47e"}}}}; | 170 "1913a5e0a6cad30b6f03e176177e0d7ed62c5d6700a9c66da556d7c3f5d6a47e"}}}}; |
| 159 if (name.empty()) { | 171 if (name.empty()) { |
| 160 base::PostTask( | 172 base::PostTask( |
| 161 FROM_HERE, | 173 FROM_HERE, |
| 162 base::Bind(install_callback, update_client::Error::INVALID_ARGUMENT)); | 174 base::Bind(install_callback, update_client::Error::INVALID_ARGUMENT)); |
| 163 return false; | 175 return false; |
| 164 } | 176 } |
| 165 const auto it = components.find(name); | 177 const auto it = components.find(name); |
| 166 if (it == components.end()) { | 178 if (it == components.end()) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 chromeos::DBusThreadManager::Get()->GetImageLoaderClient(); | 218 chromeos::DBusThreadManager::Get()->GetImageLoaderClient(); |
| 207 if (loader) { | 219 if (loader) { |
| 208 loader->LoadComponent(name, base::Bind(&MountResult, mount_callback)); | 220 loader->LoadComponent(name, base::Bind(&MountResult, mount_callback)); |
| 209 } else { | 221 } else { |
| 210 DVLOG(1) << "Failed to get ImageLoaderClient object."; | 222 DVLOG(1) << "Failed to get ImageLoaderClient object."; |
| 211 } | 223 } |
| 212 } | 224 } |
| 213 #endif // defined(OS_CHROMEOS | 225 #endif // defined(OS_CHROMEOS |
| 214 | 226 |
| 215 } // namespace component_updater | 227 } // namespace component_updater |
| OLD | NEW |