| 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/pnacl_component_installer.h" | 5 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" |
| 6 | 6 |
| 7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
| 8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/files/file_enumerator.h" | 14 #include "base/files/file_enumerator.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/json/json_file_value_serializer.h" | 16 #include "base/json/json_file_value_serializer.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/values.h" | 20 #include "base/values.h" |
| 21 #include "base/version.h" | 21 #include "base/version.h" |
| 22 #include "base/win/windows_version.h" | 22 #include "base/win/windows_version.h" |
| 23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 25 #include "chrome/browser/component_updater/component_updater_service.h" | 25 #include "chrome/browser/component_updater/component_updater_service.h" |
| 26 #include "chrome/browser/omaha_query_params/omaha_query_params.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/browser/profiles/profile_manager.h" | 28 #include "chrome/browser/profiles/profile_manager.h" |
| 28 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
| 29 #include "chrome/common/omaha_query_params/omaha_query_params.h" | |
| 30 #include "components/nacl/common/nacl_switches.h" | 30 #include "components/nacl/common/nacl_switches.h" |
| 31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
| 32 | 32 |
| 33 using chrome::OmahaQueryParams; | 33 using chrome::OmahaQueryParams; |
| 34 using content::BrowserThread; | 34 using content::BrowserThread; |
| 35 | 35 |
| 36 namespace component_updater { | 36 namespace component_updater { |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 void CheckVersionCompatiblity(const base::Version& current_version) { | 73 void CheckVersionCompatiblity(const base::Version& current_version) { |
| 74 // Using NoBarrier, since needs_on_demand_update is standalone and does | 74 // Using NoBarrier, since needs_on_demand_update is standalone and does |
| 75 // not have other associated data. | 75 // not have other associated data. |
| 76 base::subtle::NoBarrier_Store(&needs_on_demand_update, | 76 base::subtle::NoBarrier_Store(&needs_on_demand_update, |
| 77 current_version.IsOlderThan(kMinPnaclVersion)); | 77 current_version.IsOlderThan(kMinPnaclVersion)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // PNaCl is packaged as a multi-CRX. This returns the platform-specific | 80 // PNaCl is packaged as a multi-CRX. This returns the platform-specific |
| 81 // subdirectory that is part of that multi-CRX. | 81 // subdirectory that is part of that multi-CRX. |
| 82 base::FilePath GetPlatformDir(const base::FilePath& base_path) { | 82 base::FilePath GetPlatformDir(const base::FilePath& base_path) { |
| 83 std::string arch = SanitizeForPath(OmahaQueryParams::getNaclArch()); | 83 std::string arch = SanitizeForPath(OmahaQueryParams::GetNaclArch()); |
| 84 return base_path.AppendASCII("_platform_specific").AppendASCII(arch); | 84 return base_path.AppendASCII("_platform_specific").AppendASCII(arch); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Tell the rest of the world where to find the platform-specific PNaCl files. | 87 // Tell the rest of the world where to find the platform-specific PNaCl files. |
| 88 void OverrideDirPnaclComponent(const base::FilePath& base_path) { | 88 void OverrideDirPnaclComponent(const base::FilePath& base_path) { |
| 89 PathService::Override(chrome::DIR_PNACL_COMPONENT, | 89 PathService::Override(chrome::DIR_PNACL_COMPONENT, |
| 90 GetPlatformDir(base_path)); | 90 GetPlatformDir(base_path)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool GetLatestPnaclDirectory(PnaclComponentInstaller* pci, | 93 bool GetLatestPnaclDirectory(PnaclComponentInstaller* pci, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 << version.GetString(); | 185 << version.GetString(); |
| 186 return false; | 186 return false; |
| 187 } | 187 } |
| 188 | 188 |
| 189 // Now check the |pnacl_manifest|. | 189 // Now check the |pnacl_manifest|. |
| 190 std::string arch; | 190 std::string arch; |
| 191 if (!pnacl_manifest.GetStringASCII("pnacl-arch", &arch)) { | 191 if (!pnacl_manifest.GetStringASCII("pnacl-arch", &arch)) { |
| 192 LOG(WARNING) << "'pnacl-arch' field is missing from pnacl-manifest!"; | 192 LOG(WARNING) << "'pnacl-arch' field is missing from pnacl-manifest!"; |
| 193 return false; | 193 return false; |
| 194 } | 194 } |
| 195 if (arch.compare(OmahaQueryParams::getNaclArch()) != 0) { | 195 if (arch.compare(OmahaQueryParams::GetNaclArch()) != 0) { |
| 196 LOG(WARNING) << "'pnacl-arch' field in manifest is invalid (" | 196 LOG(WARNING) << "'pnacl-arch' field in manifest is invalid (" << arch |
| 197 << arch << " vs " << OmahaQueryParams::getNaclArch() << ")"; | 197 << " vs " << OmahaQueryParams::GetNaclArch() << ")"; |
| 198 return false; | 198 return false; |
| 199 } | 199 } |
| 200 | 200 |
| 201 *version_out = version; | 201 *version_out = version; |
| 202 return true; | 202 return true; |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace | 205 } // namespace |
| 206 | 206 |
| 207 PnaclComponentInstaller::PnaclComponentInstaller() | 207 PnaclComponentInstaller::PnaclComponentInstaller() |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 } // namespace component_updater | 460 } // namespace component_updater |
| 461 | 461 |
| 462 namespace pnacl { | 462 namespace pnacl { |
| 463 | 463 |
| 464 bool NeedsOnDemandUpdate() { | 464 bool NeedsOnDemandUpdate() { |
| 465 return base::subtle::NoBarrier_Load( | 465 return base::subtle::NoBarrier_Load( |
| 466 &component_updater::needs_on_demand_update) != 0; | 466 &component_updater::needs_on_demand_update) != 0; |
| 467 } | 467 } |
| 468 | 468 |
| 469 } // namespace pnacl | 469 } // namespace pnacl |
| OLD | NEW |