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