Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.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/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/version.h" | 22 #include "base/version.h" |
| 23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 24 #include "chrome/browser/component_updater/flash_component_installer.h" | 24 #include "chrome/browser/component_updater/flash_component_installer.h" |
| 25 #include "chrome/browser/plugins/plugin_prefs.h" | 25 #include "chrome/browser/plugins/plugin_prefs.h" |
| 26 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
| 27 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/component_flash_hint_file_linux.h" | |
| 30 #include "chrome/common/pepper_flash.h" | 29 #include "chrome/common/pepper_flash.h" |
| 31 #include "chrome/common/ppapi_utils.h" | 30 #include "chrome/common/ppapi_utils.h" |
| 32 #include "components/component_updater/component_updater_service.h" | 31 #include "components/component_updater/component_updater_service.h" |
| 33 #include "components/update_client/update_client.h" | 32 #include "components/update_client/update_client.h" |
| 34 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 35 #include "content/public/browser/plugin_service.h" | 34 #include "content/public/browser/plugin_service.h" |
| 36 #include "content/public/common/content_constants.h" | 35 #include "content/public/common/content_constants.h" |
| 37 #include "content/public/common/pepper_plugin_info.h" | 36 #include "content/public/common/pepper_plugin_info.h" |
| 38 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT | 37 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. NOLINT |
| 39 #include "ppapi/shared_impl/ppapi_permissions.h" | 38 #include "ppapi/shared_impl/ppapi_permissions.h" |
| 40 | 39 |
| 40 #if defined(OS_LINUX) | |
| 41 #include "chrome/common/component_flash_hint_file_linux.h" | |
| 42 #endif // defined(OS_LINUX) | |
| 43 | |
| 41 using content::BrowserThread; | 44 using content::BrowserThread; |
| 42 using content::PluginService; | 45 using content::PluginService; |
| 43 | 46 |
| 44 namespace component_updater { | 47 namespace component_updater { |
| 45 | 48 |
| 46 namespace { | 49 namespace { |
| 47 | 50 |
| 48 #if defined(GOOGLE_CHROME_BUILD) | 51 #if defined(GOOGLE_CHROME_BUILD) |
| 49 // CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb. | 52 // CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb. |
| 50 const uint8_t kSha2Hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20, | 53 const uint8_t kSha2Hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 69 // Pepper Flash plugins have the version encoded in the path itself | 72 // Pepper Flash plugins have the version encoded in the path itself |
| 70 // so we need to enumerate the directories to find the full path. | 73 // so we need to enumerate the directories to find the full path. |
| 71 // On success, |latest_dir| returns something like: | 74 // On success, |latest_dir| returns something like: |
| 72 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\10.3.44.555\. | 75 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\10.3.44.555\. |
| 73 // |latest_version| returns the corresponding version number. |older_dirs| | 76 // |latest_version| returns the corresponding version number. |older_dirs| |
| 74 // returns directories of all older versions. | 77 // returns directories of all older versions. |
| 75 bool GetPepperFlashDirectory(base::FilePath* latest_dir, | 78 bool GetPepperFlashDirectory(base::FilePath* latest_dir, |
| 76 Version* latest_version, | 79 Version* latest_version, |
| 77 std::vector<base::FilePath>* older_dirs) { | 80 std::vector<base::FilePath>* older_dirs) { |
| 78 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 81 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 79 base::FilePath base_dir = GetPepperFlashBaseDirectory(); | 82 base::FilePath base_dir = GetPepperFlashBaseDirectory(); |
|
Lei Zhang
2015/08/17 21:18:30
(re: compiler failure) Oh, I didn't see this.
Greg K
2015/08/17 22:57:45
I fixed this by putting it into the GOOGLE_CHROME_
| |
| 80 bool found = false; | 83 bool found = false; |
| 81 base::FileEnumerator file_enumerator( | 84 base::FileEnumerator file_enumerator( |
| 82 base_dir, false, base::FileEnumerator::DIRECTORIES); | 85 base_dir, false, base::FileEnumerator::DIRECTORIES); |
| 83 for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); | 86 for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); |
| 84 path = file_enumerator.Next()) { | 87 path = file_enumerator.Next()) { |
| 85 Version version(path.BaseName().MaybeAsASCII()); | 88 Version version(path.BaseName().MaybeAsASCII()); |
| 86 if (!version.IsValid()) | 89 if (!version.IsValid()) |
| 87 continue; | 90 continue; |
| 88 if (found) { | 91 if (found) { |
| 89 if (version.CompareTo(*latest_version) > 0) { | 92 if (version.CompareTo(*latest_version) > 0) { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 Version version; | 224 Version version; |
| 222 if (!chrome::CheckPepperFlashManifest(manifest, &version)) | 225 if (!chrome::CheckPepperFlashManifest(manifest, &version)) |
| 223 return false; | 226 return false; |
| 224 if (current_version_.CompareTo(version) > 0) | 227 if (current_version_.CompareTo(version) > 0) |
| 225 return false; | 228 return false; |
| 226 const base::FilePath unpacked_plugin = | 229 const base::FilePath unpacked_plugin = |
| 227 unpack_path.Append(chrome::kPepperFlashPluginFilename); | 230 unpack_path.Append(chrome::kPepperFlashPluginFilename); |
| 228 if (!base::PathExists(unpacked_plugin)) | 231 if (!base::PathExists(unpacked_plugin)) |
| 229 return false; | 232 return false; |
| 230 // Passed the basic tests. Time to install it. | 233 // Passed the basic tests. Time to install it. |
| 231 base::FilePath path = | 234 base::FilePath path; |
| 232 GetPepperFlashBaseDirectory().AppendASCII(version.GetString()); | 235 if (!PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, |
| 236 &path)) { | |
| 237 return false; | |
| 238 } | |
| 239 path = path.AppendASCII(version.GetString()); | |
| 233 if (base::PathExists(path)) | 240 if (base::PathExists(path)) |
| 234 return false; | 241 return false; |
| 235 current_version_ = version; | 242 current_version_ = version; |
| 236 | 243 |
| 237 if (!base::Move(unpack_path, path)) | 244 if (!base::Move(unpack_path, path)) |
| 238 return false; | 245 return false; |
| 239 #if defined(OS_LINUX) | 246 #if defined(OS_LINUX) |
| 240 const base::FilePath flash_path = | 247 const base::FilePath flash_path = |
| 241 path.Append(chrome::kPepperFlashPluginFilename); | 248 path.Append(chrome::kPepperFlashPluginFilename); |
| 242 // Populate the component updated flash hint file so that the zygote can | 249 // Populate the component updated flash hint file so that the zygote can |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 351 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 345 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash)) | 352 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash)) |
| 346 return; | 353 return; |
| 347 BrowserThread::PostTask(BrowserThread::FILE, | 354 BrowserThread::PostTask(BrowserThread::FILE, |
| 348 FROM_HERE, | 355 FROM_HERE, |
| 349 base::Bind(&StartPepperFlashUpdateRegistration, cus)); | 356 base::Bind(&StartPepperFlashUpdateRegistration, cus)); |
| 350 #endif // defined(GOOGLE_CHROME_BUILD) | 357 #endif // defined(GOOGLE_CHROME_BUILD) |
| 351 } | 358 } |
| 352 | 359 |
| 353 } // namespace component_updater | 360 } // namespace component_updater |
| OLD | NEW |