Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: chrome/browser/component_updater/pepper_flash_component_installer.cc

Issue 1298013002: Address some additional cleanup work needed for the component flash updates on Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the build breakage and drop chrome namespace. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/common/chrome_content_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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,
51 0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11, 54 0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11,
52 0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70, 55 0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70,
53 0x54, 0xf9, 0x56, 0xd3, 0xe7, 0x88, 0xba, 0x8c}; 56 0x54, 0xf9, 0x56, 0xd3, 0xe7, 0x88, 0xba, 0x8c};
54 57
55 // If we don't have a Pepper Flash component, this is the version we claim. 58 // If we don't have a Pepper Flash component, this is the version we claim.
56 const char kNullVersion[] = "0.0.0.0"; 59 const char kNullVersion[] = "0.0.0.0";
57 60
58 #endif // defined(GOOGLE_CHROME_BUILD)
59
60 // The base directory on Windows looks like: 61 // The base directory on Windows looks like:
61 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\. 62 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\.
62 base::FilePath GetPepperFlashBaseDirectory() { 63 base::FilePath GetPepperFlashBaseDirectory() {
63 base::FilePath result; 64 base::FilePath result;
64 PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, &result); 65 PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN, &result);
65 return result; 66 return result;
66 } 67 }
67 68
68 #if defined(GOOGLE_CHROME_BUILD)
69 // Pepper Flash plugins have the version encoded in the path itself 69 // Pepper Flash plugins have the version encoded in the path itself
70 // so we need to enumerate the directories to find the full path. 70 // so we need to enumerate the directories to find the full path.
71 // On success, |latest_dir| returns something like: 71 // On success, |latest_dir| returns something like:
72 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\10.3.44.555\. 72 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\10.3.44.555\.
73 // |latest_version| returns the corresponding version number. |older_dirs| 73 // |latest_version| returns the corresponding version number. |older_dirs|
74 // returns directories of all older versions. 74 // returns directories of all older versions.
75 bool GetPepperFlashDirectory(base::FilePath* latest_dir, 75 bool GetPepperFlashDirectory(base::FilePath* latest_dir,
76 Version* latest_version, 76 Version* latest_version,
77 std::vector<base::FilePath>* older_dirs) { 77 std::vector<base::FilePath>* older_dirs) {
78 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 78 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
79 base::FilePath base_dir = GetPepperFlashBaseDirectory(); 79 base::FilePath base_dir = GetPepperFlashBaseDirectory();
Lei Zhang 2015/08/17 23:34:58 Don't we want to get the correct |base_dir| here?
Greg K 2015/08/18 18:01:16 Done.
80 bool found = false; 80 bool found = false;
81 base::FileEnumerator file_enumerator( 81 base::FileEnumerator file_enumerator(
82 base_dir, false, base::FileEnumerator::DIRECTORIES); 82 base_dir, false, base::FileEnumerator::DIRECTORIES);
83 for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); 83 for (base::FilePath path = file_enumerator.Next(); !path.value().empty();
84 path = file_enumerator.Next()) { 84 path = file_enumerator.Next()) {
85 Version version(path.BaseName().MaybeAsASCII()); 85 Version version(path.BaseName().MaybeAsASCII());
86 if (!version.IsValid()) 86 if (!version.IsValid())
87 continue; 87 continue;
88 if (found) { 88 if (found) {
89 if (version.CompareTo(*latest_version) > 0) { 89 if (version.CompareTo(*latest_version) > 0) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 Version version; 221 Version version;
222 if (!chrome::CheckPepperFlashManifest(manifest, &version)) 222 if (!chrome::CheckPepperFlashManifest(manifest, &version))
223 return false; 223 return false;
224 if (current_version_.CompareTo(version) > 0) 224 if (current_version_.CompareTo(version) > 0)
225 return false; 225 return false;
226 const base::FilePath unpacked_plugin = 226 const base::FilePath unpacked_plugin =
227 unpack_path.Append(chrome::kPepperFlashPluginFilename); 227 unpack_path.Append(chrome::kPepperFlashPluginFilename);
228 if (!base::PathExists(unpacked_plugin)) 228 if (!base::PathExists(unpacked_plugin))
229 return false; 229 return false;
230 // Passed the basic tests. Time to install it. 230 // Passed the basic tests. Time to install it.
231 base::FilePath path = 231 base::FilePath path;
232 GetPepperFlashBaseDirectory().AppendASCII(version.GetString()); 232 if (!PathService::Get(chrome::DIR_COMPONENT_UPDATED_PEPPER_FLASH_PLUGIN,
233 &path)) {
234 return false;
235 }
236 path = path.AppendASCII(version.GetString());
233 if (base::PathExists(path)) 237 if (base::PathExists(path))
234 return false; 238 return false;
235 current_version_ = version; 239 current_version_ = version;
236 240
237 if (!base::Move(unpack_path, path)) 241 if (!base::Move(unpack_path, path))
238 return false; 242 return false;
239 #if defined(OS_LINUX) 243 #if defined(OS_LINUX)
240 const base::FilePath flash_path = 244 const base::FilePath flash_path =
241 path.Append(chrome::kPepperFlashPluginFilename); 245 path.Append(chrome::kPepperFlashPluginFilename);
242 // Populate the component updated flash hint file so that the zygote can 246 // Populate the component updated flash hint file so that the zygote can
243 // locate and preload the latest version of flash. 247 // locate and preload the latest version of flash.
244 if (!chrome::component_flash_hint_file::RecordFlashUpdate( 248 if (!component_flash_hint_file::RecordFlashUpdate(flash_path, flash_path,
245 flash_path, flash_path, version.GetString())) { 249 version.GetString())) {
246 if (!base::DeleteFile(path, true)) 250 if (!base::DeleteFile(path, true))
247 LOG(ERROR) << "Hint file creation failed, but unable to delete " 251 LOG(ERROR) << "Hint file creation failed, but unable to delete "
248 "installed flash plugin."; 252 "installed flash plugin.";
249 return false; 253 return false;
250 } 254 }
251 #else 255 #else
252 // Installation is done. Now tell the rest of chrome. Both the path service 256 // Installation is done. Now tell the rest of chrome. Both the path service
253 // and to the plugin service. On Linux, a restart is required to use the new 257 // and to the plugin service. On Linux, a restart is required to use the new
254 // Flash version, so we do not do this. 258 // Flash version, so we do not do this.
255 PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path); 259 PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 348 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
345 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash)) 349 if (cmd_line->HasSwitch(switches::kDisableBundledPpapiFlash))
346 return; 350 return;
347 BrowserThread::PostTask(BrowserThread::FILE, 351 BrowserThread::PostTask(BrowserThread::FILE,
348 FROM_HERE, 352 FROM_HERE,
349 base::Bind(&StartPepperFlashUpdateRegistration, cus)); 353 base::Bind(&StartPepperFlashUpdateRegistration, cus));
350 #endif // defined(GOOGLE_CHROME_BUILD) 354 #endif // defined(GOOGLE_CHROME_BUILD)
351 } 355 }
352 356
353 } // namespace component_updater 357 } // namespace component_updater
OLDNEW
« no previous file with comments | « no previous file | chrome/common/chrome_content_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698