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

Side by Side Diff: chrome/common/chrome_content_client.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: Remove useless GetPepperFlashBaseDirectory() wrapper 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
OLDNEW
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/common/chrome_content_client.h" 5 #include "chrome/common/chrome_content_client.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #endif // defined(OS_LINUX) 9 #endif // defined(OS_LINUX)
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/crash_logging.h" 12 #include "base/debug/crash_logging.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/json/json_reader.h" 14 #include "base/json/json_reader.h"
15 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "chrome/common/child_process_logging.h" 24 #include "chrome/common/child_process_logging.h"
25 #include "chrome/common/chrome_constants.h" 25 #include "chrome/common/chrome_constants.h"
26 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
27 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/component_flash_hint_file_linux.h"
29 #include "chrome/common/crash_keys.h" 28 #include "chrome/common/crash_keys.h"
30 #include "chrome/common/pepper_flash.h" 29 #include "chrome/common/pepper_flash.h"
31 #include "chrome/common/secure_origin_whitelist.h" 30 #include "chrome/common/secure_origin_whitelist.h"
32 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
33 #include "chrome/grit/common_resources.h" 32 #include "chrome/grit/common_resources.h"
34 #include "components/dom_distiller/core/url_constants.h" 33 #include "components/dom_distiller/core/url_constants.h"
35 #include "components/version_info/version_info.h" 34 #include "components/version_info/version_info.h"
36 #include "content/public/common/content_constants.h" 35 #include "content/public/common/content_constants.h"
37 #include "content/public/common/content_switches.h" 36 #include "content/public/common/content_switches.h"
38 #include "content/public/common/url_constants.h" 37 #include "content/public/common/url_constants.h"
39 #include "content/public/common/user_agent.h" 38 #include "content/public/common/user_agent.h"
40 #include "extensions/common/constants.h" 39 #include "extensions/common/constants.h"
41 #include "gpu/config/gpu_info.h" 40 #include "gpu/config/gpu_info.h"
42 #include "net/http/http_util.h" 41 #include "net/http/http_util.h"
43 #include "ui/base/l10n/l10n_util.h" 42 #include "ui/base/l10n/l10n_util.h"
44 #include "ui/base/layout.h" 43 #include "ui/base/layout.h"
45 #include "ui/base/resource/resource_bundle.h" 44 #include "ui/base/resource/resource_bundle.h"
46 45
47 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 46 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
48 47
48 #if defined(OS_LINUX)
49 #include "chrome/common/component_flash_hint_file_linux.h"
50 #endif // defined(OS_LINUX)
51
49 #if defined(OS_WIN) 52 #if defined(OS_WIN)
50 #include "base/win/registry.h" 53 #include "base/win/registry.h"
51 #include "base/win/windows_version.h" 54 #include "base/win/windows_version.h"
52 #endif 55 #endif
53 56
54 #if !defined(DISABLE_NACL) 57 #if !defined(DISABLE_NACL)
55 #include "components/nacl/common/nacl_constants.h" 58 #include "components/nacl/common/nacl_constants.h"
56 #include "components/nacl/common/nacl_process_type.h" 59 #include "components/nacl/common/nacl_process_type.h"
57 #include "components/nacl/common/nacl_sandbox_type.h" 60 #include "components/nacl/common/nacl_sandbox_type.h"
58 #endif 61 #endif
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // or 11.2.123.45. 236 // or 11.2.123.45.
234 std::string flash_version = 237 std::string flash_version =
235 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 238 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
236 switches::kPpapiFlashVersion); 239 switches::kPpapiFlashVersion);
237 240
238 plugins->push_back( 241 plugins->push_back(
239 CreatePepperFlashInfo(base::FilePath(flash_path), flash_version)); 242 CreatePepperFlashInfo(base::FilePath(flash_path), flash_version));
240 } 243 }
241 244
242 #if defined(OS_LINUX) 245 #if defined(OS_LINUX)
246 // This function tests if DIR_USER_DATA can be accessed, as a simple check to
247 // see if the zygote has been sandboxed at this point.
243 bool IsUserDataDirAvailable() { 248 bool IsUserDataDirAvailable() {
244 base::FilePath user_data_dir; 249 base::FilePath user_data_dir;
245 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) 250 return PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
246 return false;
247 return base::PathExists(user_data_dir);
248 } 251 }
249 252
250 // This method is used on Linux only because of architectural differences in how 253 // This method is used on Linux only because of architectural differences in how
251 // it loads the component updated flash plugin, and not because the other 254 // it loads the component updated flash plugin, and not because the other
252 // platforms do not support component updated flash. On other platforms, the 255 // platforms do not support component updated flash. On other platforms, the
253 // component updater sends an IPC message to all threads, at undefined points in 256 // component updater sends an IPC message to all threads, at undefined points in
254 // time, with the URL of the component updated flash. Because the linux zygote 257 // time, with the URL of the component updated flash. Because the linux zygote
255 // thread has no access to the file system after it warms up, it must preload 258 // thread has no access to the file system after it warms up, it must preload
256 // the component updated flash. 259 // the component updated flash.
257 bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo* plugin) { 260 bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo* plugin) {
258 #if defined(FLAPPER_AVAILABLE) 261 #if defined(FLAPPER_AVAILABLE)
259 if (chrome::component_flash_hint_file::DoesHintFileExist()) { 262 if (component_flash_hint_file::DoesHintFileExist()) {
260 base::FilePath flash_path; 263 base::FilePath flash_path;
261 std::string version; 264 std::string version;
262 if (chrome::component_flash_hint_file::VerifyAndReturnFlashLocation( 265 if (component_flash_hint_file::VerifyAndReturnFlashLocation(&flash_path,
263 &flash_path, &version)) { 266 &version)) {
264 // Test if the file can be mapped as executable. If the user's home 267 // Test if the file can be mapped as executable. If the user's home
265 // directory is mounted noexec, the component flash plugin will not load. 268 // directory is mounted noexec, the component flash plugin will not load.
266 // By testing for this, Chrome can fallback to the bundled flash plugin. 269 // By testing for this, Chrome can fallback to the bundled flash plugin.
267 if (!chrome::component_flash_hint_file::TestExecutableMapping( 270 if (!component_flash_hint_file::TestExecutableMapping(flash_path)) {
268 flash_path)) {
269 LOG(WARNING) << "The component updated flash plugin could not be " 271 LOG(WARNING) << "The component updated flash plugin could not be "
270 "mapped as executable. Attempting to fallback to the " 272 "mapped as executable. Attempting to fallback to the "
271 "bundled or system plugin."; 273 "bundled or system plugin.";
272 return false; 274 return false;
273 } 275 }
274 *plugin = CreatePepperFlashInfo(flash_path, version); 276 *plugin = CreatePepperFlashInfo(flash_path, version);
275 return true; 277 return true;
276 } else {
277 LOG(ERROR)
278 << "Failed to locate and load the component updated flash plugin.";
279 } 278 }
279 LOG(ERROR)
280 << "Failed to locate and load the component updated flash plugin.";
280 } 281 }
281 #endif // defined(FLAPPER_AVAILABLE) 282 #endif // defined(FLAPPER_AVAILABLE)
282 return false; 283 return false;
283 } 284 }
284 #endif // defined(OS_LINUX) 285 #endif // defined(OS_LINUX)
285 286
286 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) { 287 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) {
287 #if defined(FLAPPER_AVAILABLE) 288 #if defined(FLAPPER_AVAILABLE)
288 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 289 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
289 290
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 #elif defined(OS_POSIX) 445 #elif defined(OS_POSIX)
445 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor); 446 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor);
446 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); 447 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer);
447 #endif 448 #endif
448 } 449 }
449 450
450 #if defined(ENABLE_PLUGINS) 451 #if defined(ENABLE_PLUGINS)
451 // static 452 // static
452 content::PepperPluginInfo* ChromeContentClient::FindMostRecentPlugin( 453 content::PepperPluginInfo* ChromeContentClient::FindMostRecentPlugin(
453 const std::vector<content::PepperPluginInfo*>& plugins) { 454 const std::vector<content::PepperPluginInfo*>& plugins) {
454 content::PepperPluginInfo* result = nullptr;
455 auto it = std::max_element( 455 auto it = std::max_element(
456 plugins.begin(), plugins.end(), 456 plugins.begin(), plugins.end(),
457 [](content::PepperPluginInfo* x, content::PepperPluginInfo* y) { 457 [](content::PepperPluginInfo* x, content::PepperPluginInfo* y) {
458 Version version_x(x->version); 458 Version version_x(x->version);
459 DCHECK(version_x.IsValid()); 459 DCHECK(version_x.IsValid());
460 return version_x.IsOlderThan(y->version); 460 return version_x.IsOlderThan(y->version);
461 }); 461 });
462 if (it != plugins.end()) 462 return it != plugins.end() ? *it : nullptr;
463 result = *it;
464 return result;
465 } 463 }
466 #endif // defined(ENABLE_PLUGINS) 464 #endif // defined(ENABLE_PLUGINS)
467 465
468 void ChromeContentClient::AddPepperPlugins( 466 void ChromeContentClient::AddPepperPlugins(
469 std::vector<content::PepperPluginInfo>* plugins) { 467 std::vector<content::PepperPluginInfo>* plugins) {
470 #if defined(ENABLE_PLUGINS) 468 #if defined(ENABLE_PLUGINS)
471 ComputeBuiltInPlugins(plugins); 469 ComputeBuiltInPlugins(plugins);
472 AddPepperFlashFromCommandLine(plugins); 470 AddPepperFlashFromCommandLine(plugins);
473 471
474 #if defined(OS_LINUX) 472 #if defined(OS_LINUX)
(...skipping 21 matching lines...) Expand all
496 flash_versions.push_back(bundled_flash.release()); 494 flash_versions.push_back(bundled_flash.release());
497 495
498 scoped_ptr<content::PepperPluginInfo> system_flash( 496 scoped_ptr<content::PepperPluginInfo> system_flash(
499 new content::PepperPluginInfo); 497 new content::PepperPluginInfo);
500 if (GetSystemPepperFlash(system_flash.get())) 498 if (GetSystemPepperFlash(system_flash.get()))
501 flash_versions.push_back(system_flash.release()); 499 flash_versions.push_back(system_flash.release());
502 500
503 // This function will return only the most recent version of the flash plugin. 501 // This function will return only the most recent version of the flash plugin.
504 content::PepperPluginInfo* max_flash = 502 content::PepperPluginInfo* max_flash =
505 FindMostRecentPlugin(flash_versions.get()); 503 FindMostRecentPlugin(flash_versions.get());
506 if (max_flash != nullptr) 504 if (max_flash)
507 plugins->push_back(*max_flash); 505 plugins->push_back(*max_flash);
508 #endif // defined(ENABLE_PLUGINS) 506 #endif // defined(ENABLE_PLUGINS)
509 } 507 }
510 508
511 void ChromeContentClient::AddAdditionalSchemes( 509 void ChromeContentClient::AddAdditionalSchemes(
512 std::vector<std::string>* standard_schemes, 510 std::vector<std::string>* standard_schemes,
513 std::vector<std::string>* savable_schemes) { 511 std::vector<std::string>* savable_schemes) {
514 standard_schemes->push_back(extensions::kExtensionScheme); 512 standard_schemes->push_back(extensions::kExtensionScheme);
515 savable_schemes->push_back(extensions::kExtensionScheme); 513 savable_schemes->push_back(extensions::kExtensionScheme);
516 standard_schemes->push_back(chrome::kChromeNativeScheme); 514 standard_schemes->push_back(chrome::kChromeNativeScheme);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 schemes->insert(content::kChromeUIScheme); 587 schemes->insert(content::kChromeUIScheme);
590 schemes->insert(extensions::kExtensionScheme); 588 schemes->insert(extensions::kExtensionScheme);
591 schemes->insert(extensions::kExtensionResourceScheme); 589 schemes->insert(extensions::kExtensionResourceScheme);
592 GetSecureOriginWhitelist(origins); 590 GetSecureOriginWhitelist(origins);
593 } 591 }
594 592
595 void ChromeContentClient::AddServiceWorkerSchemes( 593 void ChromeContentClient::AddServiceWorkerSchemes(
596 std::set<std::string>* schemes) { 594 std::set<std::string>* schemes) {
597 schemes->insert(extensions::kExtensionScheme); 595 schemes->insert(extensions::kExtensionScheme);
598 } 596 }
OLDNEW
« no previous file with comments | « chrome/browser/component_updater/pepper_flash_component_installer.cc ('k') | chrome/common/chrome_paths.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698