| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/pnacl_component_installer.h" | 5 #include "chrome/browser/component_updater/pnacl_component_installer.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/atomicops.h" | 11 #include "base/atomicops.h" |
| 12 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" |
| 14 #include "base/callback.h" | 15 #include "base/callback.h" |
| 15 #include "base/files/file_enumerator.h" | 16 #include "base/files/file_enumerator.h" |
| 16 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 17 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
| 18 #include "base/json/json_file_value_serializer.h" | 19 #include "base/json/json_file_value_serializer.h" |
| 19 #include "base/logging.h" | 20 #include "base/logging.h" |
| 20 #include "base/macros.h" | 21 #include "base/macros.h" |
| 21 #include "base/path_service.h" | 22 #include "base/path_service.h" |
| 22 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 23 #include "base/values.h" | 24 #include "base/values.h" |
| 24 #include "base/version.h" | 25 #include "base/version.h" |
| 25 #include "base/win/windows_version.h" | 26 #include "base/win/windows_version.h" |
| 26 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 27 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 28 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
| 29 #include "components/component_updater/component_updater_service.h" | 30 #include "components/component_updater/component_updater_service.h" |
| 30 #include "components/nacl/common/nacl_switches.h" | 31 #include "components/nacl/common/nacl_switches.h" |
| 31 #include "components/update_client/update_query_params.h" | 32 #include "components/update_client/update_query_params.h" |
| 33 #include "components/update_client/utils.h" |
| 32 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 33 | 35 |
| 34 using content::BrowserThread; | 36 using content::BrowserThread; |
| 35 using update_client::CrxComponent; | 37 using update_client::CrxComponent; |
| 36 using update_client::UpdateQueryParams; | 38 using update_client::UpdateQueryParams; |
| 37 | 39 |
| 38 namespace component_updater { | 40 namespace component_updater { |
| 39 | 41 |
| 40 namespace { | 42 namespace { |
| 41 | 43 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // Pnacl components have the version encoded in the path itself: | 220 // Pnacl components have the version encoded in the path itself: |
| 219 // <profile>\AppData\Local\Google\Chrome\User Data\pnacl\0.1.2.3\. | 221 // <profile>\AppData\Local\Google\Chrome\User Data\pnacl\0.1.2.3\. |
| 220 // and the base directory will be: | 222 // and the base directory will be: |
| 221 // <profile>\AppData\Local\Google\Chrome\User Data\pnacl\. | 223 // <profile>\AppData\Local\Google\Chrome\User Data\pnacl\. |
| 222 base::FilePath PnaclComponentInstaller::GetPnaclBaseDirectory() { | 224 base::FilePath PnaclComponentInstaller::GetPnaclBaseDirectory() { |
| 223 base::FilePath result; | 225 base::FilePath result; |
| 224 CHECK(PathService::Get(chrome::DIR_PNACL_BASE, &result)); | 226 CHECK(PathService::Get(chrome::DIR_PNACL_BASE, &result)); |
| 225 return result; | 227 return result; |
| 226 } | 228 } |
| 227 | 229 |
| 228 bool PnaclComponentInstaller::Install(const base::DictionaryValue& manifest, | 230 update_client::CrxInstaller::Result PnaclComponentInstaller::Install( |
| 229 const base::FilePath& unpack_path) { | 231 const base::DictionaryValue& manifest, |
| 232 const base::FilePath& unpack_path) { |
| 233 return update_client::InstallFunctionWrapper( |
| 234 base::Bind(&PnaclComponentInstaller::DoInstall, base::Unretained(this), |
| 235 base::ConstRef(manifest), base::ConstRef(unpack_path))); |
| 236 } |
| 237 |
| 238 bool PnaclComponentInstaller::DoInstall(const base::DictionaryValue& manifest, |
| 239 const base::FilePath& unpack_path) { |
| 230 std::unique_ptr<base::DictionaryValue> pnacl_manifest( | 240 std::unique_ptr<base::DictionaryValue> pnacl_manifest( |
| 231 ReadPnaclManifest(unpack_path)); | 241 ReadPnaclManifest(unpack_path)); |
| 232 if (pnacl_manifest == NULL) { | 242 if (pnacl_manifest == NULL) { |
| 233 LOG(WARNING) << "Failed to read pnacl manifest."; | 243 LOG(WARNING) << "Failed to read pnacl manifest."; |
| 234 return false; | 244 return false; |
| 235 } | 245 } |
| 236 | 246 |
| 237 base::Version version; | 247 base::Version version; |
| 238 if (!CheckPnaclComponentManifest(manifest, *pnacl_manifest, &version)) { | 248 if (!CheckPnaclComponentManifest(manifest, *pnacl_manifest, &version)) { |
| 239 LOG(WARNING) << "CheckPnaclComponentManifest failed, not installing."; | 249 LOG(WARNING) << "CheckPnaclComponentManifest failed, not installing."; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 } // namespace component_updater | 390 } // namespace component_updater |
| 381 | 391 |
| 382 namespace pnacl { | 392 namespace pnacl { |
| 383 | 393 |
| 384 bool NeedsOnDemandUpdate() { | 394 bool NeedsOnDemandUpdate() { |
| 385 return base::subtle::NoBarrier_Load( | 395 return base::subtle::NoBarrier_Load( |
| 386 &component_updater::needs_on_demand_update) != 0; | 396 &component_updater::needs_on_demand_update) != 0; |
| 387 } | 397 } |
| 388 | 398 |
| 389 } // namespace pnacl | 399 } // namespace pnacl |
| OLD | NEW |