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

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: Additional cleanup work for the component flash updates on Linux. 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 (chrome::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 (chrome::component_flash_hint_file::VerifyAndReturnFlashLocation(
263 &flash_path, &version)) { 266 &flash_path, &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 (!chrome::component_flash_hint_file::TestExecutableMapping(
268 flash_path)) { 271 flash_path)) {
269 LOG(WARNING) << "The component updated flash plugin could not be " 272 LOG(WARNING) << "The component updated flash plugin could not be "
270 "mapped as executable. Attempting to fallback to the " 273 "mapped as executable. Attempting to fallback to the "
271 "bundled or system plugin."; 274 "bundled or system plugin.";
272 return false; 275 return false;
273 } 276 }
274 *plugin = CreatePepperFlashInfo(flash_path, version); 277 *plugin = CreatePepperFlashInfo(flash_path, version);
275 return true; 278 return true;
276 } else {
277 LOG(ERROR)
278 << "Failed to locate and load the component updated flash plugin.";
279 } 279 }
280 LOG(ERROR)
281 << "Failed to locate and load the component updated flash plugin.";
280 } 282 }
281 #endif // defined(FLAPPER_AVAILABLE) 283 #endif // defined(FLAPPER_AVAILABLE)
282 return false; 284 return false;
283 } 285 }
284 #endif // defined(OS_LINUX) 286 #endif // defined(OS_LINUX)
285 287
286 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) { 288 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) {
287 #if defined(FLAPPER_AVAILABLE) 289 #if defined(FLAPPER_AVAILABLE)
288 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 290 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
289 291
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 #elif defined(OS_POSIX) 446 #elif defined(OS_POSIX)
445 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor); 447 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor);
446 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); 448 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer);
447 #endif 449 #endif
448 } 450 }
449 451
450 #if defined(ENABLE_PLUGINS) 452 #if defined(ENABLE_PLUGINS)
451 // static 453 // static
452 content::PepperPluginInfo* ChromeContentClient::FindMostRecentPlugin( 454 content::PepperPluginInfo* ChromeContentClient::FindMostRecentPlugin(
453 const std::vector<content::PepperPluginInfo*>& plugins) { 455 const std::vector<content::PepperPluginInfo*>& plugins) {
454 content::PepperPluginInfo* result = nullptr;
455 auto it = std::max_element( 456 auto it = std::max_element(
456 plugins.begin(), plugins.end(), 457 plugins.begin(), plugins.end(),
457 [](content::PepperPluginInfo* x, content::PepperPluginInfo* y) { 458 [](content::PepperPluginInfo* x, content::PepperPluginInfo* y) {
458 Version version_x(x->version); 459 Version version_x(x->version);
459 DCHECK(version_x.IsValid()); 460 DCHECK(version_x.IsValid());
460 return version_x.IsOlderThan(y->version); 461 return version_x.IsOlderThan(y->version);
461 }); 462 });
462 if (it != plugins.end()) 463 return it != plugins.end() ? *it : nullptr;
463 result = *it;
464 return result;
465 } 464 }
466 #endif // defined(ENABLE_PLUGINS) 465 #endif // defined(ENABLE_PLUGINS)
467 466
468 void ChromeContentClient::AddPepperPlugins( 467 void ChromeContentClient::AddPepperPlugins(
469 std::vector<content::PepperPluginInfo>* plugins) { 468 std::vector<content::PepperPluginInfo>* plugins) {
470 #if defined(ENABLE_PLUGINS) 469 #if defined(ENABLE_PLUGINS)
471 ComputeBuiltInPlugins(plugins); 470 ComputeBuiltInPlugins(plugins);
472 AddPepperFlashFromCommandLine(plugins); 471 AddPepperFlashFromCommandLine(plugins);
473 472
474 #if defined(OS_LINUX) 473 #if defined(OS_LINUX)
(...skipping 21 matching lines...) Expand all
496 flash_versions.push_back(bundled_flash.release()); 495 flash_versions.push_back(bundled_flash.release());
497 496
498 scoped_ptr<content::PepperPluginInfo> system_flash( 497 scoped_ptr<content::PepperPluginInfo> system_flash(
499 new content::PepperPluginInfo); 498 new content::PepperPluginInfo);
500 if (GetSystemPepperFlash(system_flash.get())) 499 if (GetSystemPepperFlash(system_flash.get()))
501 flash_versions.push_back(system_flash.release()); 500 flash_versions.push_back(system_flash.release());
502 501
503 // This function will return only the most recent version of the flash plugin. 502 // This function will return only the most recent version of the flash plugin.
504 content::PepperPluginInfo* max_flash = 503 content::PepperPluginInfo* max_flash =
505 FindMostRecentPlugin(flash_versions.get()); 504 FindMostRecentPlugin(flash_versions.get());
506 if (max_flash != nullptr) 505 if (max_flash)
507 plugins->push_back(*max_flash); 506 plugins->push_back(*max_flash);
508 #endif // defined(ENABLE_PLUGINS) 507 #endif // defined(ENABLE_PLUGINS)
509 } 508 }
510 509
511 void ChromeContentClient::AddAdditionalSchemes( 510 void ChromeContentClient::AddAdditionalSchemes(
512 std::vector<std::string>* standard_schemes, 511 std::vector<std::string>* standard_schemes,
513 std::vector<std::string>* savable_schemes) { 512 std::vector<std::string>* savable_schemes) {
514 standard_schemes->push_back(extensions::kExtensionScheme); 513 standard_schemes->push_back(extensions::kExtensionScheme);
515 savable_schemes->push_back(extensions::kExtensionScheme); 514 savable_schemes->push_back(extensions::kExtensionScheme);
516 standard_schemes->push_back(chrome::kChromeNativeScheme); 515 standard_schemes->push_back(chrome::kChromeNativeScheme);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 schemes->insert(content::kChromeUIScheme); 588 schemes->insert(content::kChromeUIScheme);
590 schemes->insert(extensions::kExtensionScheme); 589 schemes->insert(extensions::kExtensionScheme);
591 schemes->insert(extensions::kExtensionResourceScheme); 590 schemes->insert(extensions::kExtensionResourceScheme);
592 GetSecureOriginWhitelist(origins); 591 GetSecureOriginWhitelist(origins);
593 } 592 }
594 593
595 void ChromeContentClient::AddServiceWorkerSchemes( 594 void ChromeContentClient::AddServiceWorkerSchemes(
596 std::set<std::string>* schemes) { 595 std::set<std::string>* schemes) {
597 schemes->insert(extensions::kExtensionScheme); 596 schemes->insert(extensions::kExtensionScheme);
598 } 597 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698