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/common/chrome_content_client.h" | 5 #include "chrome/common/chrome_content_client.h" |
6 | 6 |
7 #include <fcntl.h> | |
8 | |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/debug/crash_logging.h" | 10 #include "base/debug/crash_logging.h" |
9 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
10 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
11 #include "base/path_service.h" | 13 #include "base/path_service.h" |
12 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
13 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
15 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
16 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
18 #include "build/build_config.h" | 20 #include "build/build_config.h" |
19 #include "chrome/common/child_process_logging.h" | 21 #include "chrome/common/child_process_logging.h" |
20 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
21 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
22 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/component_flash_hint_file.h" | |
23 #include "chrome/common/crash_keys.h" | 26 #include "chrome/common/crash_keys.h" |
24 #include "chrome/common/pepper_flash.h" | 27 #include "chrome/common/pepper_flash.h" |
25 #include "chrome/common/secure_origin_whitelist.h" | 28 #include "chrome/common/secure_origin_whitelist.h" |
26 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
27 #include "chrome/grit/common_resources.h" | 30 #include "chrome/grit/common_resources.h" |
28 #include "components/dom_distiller/core/url_constants.h" | 31 #include "components/dom_distiller/core/url_constants.h" |
29 #include "components/version_info/version_info.h" | 32 #include "components/version_info/version_info.h" |
30 #include "content/public/common/content_constants.h" | 33 #include "content/public/common/content_constants.h" |
31 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
32 #include "content/public/common/url_constants.h" | 35 #include "content/public/common/url_constants.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 // Also get the version from the command-line. Should be something like 11.2 | 277 // Also get the version from the command-line. Should be something like 11.2 |
275 // or 11.2.123.45. | 278 // or 11.2.123.45. |
276 std::string flash_version = | 279 std::string flash_version = |
277 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 280 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
278 switches::kPpapiFlashVersion); | 281 switches::kPpapiFlashVersion); |
279 | 282 |
280 plugins->push_back( | 283 plugins->push_back( |
281 CreatePepperFlashInfo(base::FilePath(flash_path), flash_version)); | 284 CreatePepperFlashInfo(base::FilePath(flash_path), flash_version)); |
282 } | 285 } |
283 | 286 |
287 #if defined(OS_LINUX) | |
288 bool IsUserDataDirAvailable() { | |
289 base::FilePath user_data_dir; | |
290 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) | |
291 return false; | |
292 return base::PathExists(user_data_dir); | |
293 } | |
294 #endif // defined(OS_LINUX) | |
295 | |
296 // This method is used on Linux only because of architectural differences in how | |
297 // it loads the component updated flash plugin, and not because the other | |
298 // platforms do not support component updated flash. On other platforms, the | |
299 // component updater sends an IPC message to all threads, at undefined points in | |
300 // time, with the URL of the component updated flash. Because the linux zygote | |
301 // thread has no access to the file system after it warms up, it must preload | |
302 // the component updated flash. | |
303 #if defined(OS_LINUX) | |
304 bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo* plugin) { | |
305 #if defined(FLAPPER_AVAILABLE) | |
306 if (chrome::ComponentFlashHintFile::DoesHintFileExist()) { | |
307 base::FilePath flash_path; | |
308 std::string version; | |
309 bool verified = | |
310 chrome::ComponentFlashHintFile::VerifyAndReturnFlashLocation( | |
311 &flash_path, &version); | |
312 // In case the user's home directory is mounted NOEXEC, or the plugin could | |
313 // not be verified, do not use the plugin. | |
314 if (verified && | |
315 chrome::ComponentFlashHintFile::TestExecutableMapping(flash_path)) { | |
316 *plugin = CreatePepperFlashInfo(flash_path, version); | |
317 return true; | |
318 } | |
319 } | |
320 return false; | |
321 #else | |
322 return false; | |
323 #endif // defined(FLAPPER_AVAILABLE) | |
jln (very slow on Chromium)
2015/08/04 01:08:33
You should return something even if !FLAPPER_AVAIL
Greg K
2015/08/04 18:30:00
Yes, if I #undef FLAPPER_AVAILABLE it still builds
| |
324 } | |
325 #endif // defined(OS_LINUX) | |
326 | |
284 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) { | 327 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) { |
285 #if defined(FLAPPER_AVAILABLE) | 328 #if defined(FLAPPER_AVAILABLE) |
286 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 329 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
287 | 330 |
288 // Ignore bundled Pepper Flash if there is Pepper Flash specified from the | 331 // Ignore bundled Pepper Flash if there is Pepper Flash specified from the |
289 // command-line. | 332 // command-line. |
290 if (command_line->HasSwitch(switches::kPpapiFlashPath)) | 333 if (command_line->HasSwitch(switches::kPpapiFlashPath)) |
291 return false; | 334 return false; |
292 | 335 |
293 bool force_disable = | 336 bool force_disable = |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); | 500 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); |
458 #endif | 501 #endif |
459 } | 502 } |
460 | 503 |
461 void ChromeContentClient::AddPepperPlugins( | 504 void ChromeContentClient::AddPepperPlugins( |
462 std::vector<content::PepperPluginInfo>* plugins) { | 505 std::vector<content::PepperPluginInfo>* plugins) { |
463 #if defined(ENABLE_PLUGINS) | 506 #if defined(ENABLE_PLUGINS) |
464 ComputeBuiltInPlugins(plugins); | 507 ComputeBuiltInPlugins(plugins); |
465 AddPepperFlashFromCommandLine(plugins); | 508 AddPepperFlashFromCommandLine(plugins); |
466 | 509 |
467 content::PepperPluginInfo plugin; | 510 #if defined(OS_LINUX) |
468 if (GetBundledPepperFlash(&plugin)) | 511 // Depending on the sandbox configurtion, the user data directory |
469 plugins->push_back(plugin); | 512 // is not always available. If it is not available, do not try and load and |
470 if (GetSystemPepperFlash(&plugin)) | 513 // flash plugin. It may incorrectly try to load the system flash plugin in |
471 plugins->push_back(plugin); | 514 // this case. |
515 if (!IsUserDataDirAvailable()) { | |
516 return; | |
517 } | |
518 #endif | |
jln (very slow on Chromium)
2015/08/04 01:08:33
// defined(OS_LINUX)
Greg K
2015/08/04 18:30:00
Done.
| |
519 | |
520 std::vector<content::PepperPluginInfo*> flash_versions; | |
521 | |
522 #if defined(OS_LINUX) | |
523 content::PepperPluginInfo component_flash; | |
524 if (GetComponentUpdatedPepperFlash(&component_flash)) | |
525 flash_versions.push_back(&component_flash); | |
526 #endif | |
jln (very slow on Chromium)
2015/08/04 01:08:33
// defined(OS_LINUX)
Greg K
2015/08/04 18:30:00
Done.
| |
527 | |
528 content::PepperPluginInfo bundled_flash; | |
529 if (GetBundledPepperFlash(&bundled_flash)) | |
530 flash_versions.push_back(&bundled_flash); | |
531 | |
532 content::PepperPluginInfo system_flash; | |
533 if (GetSystemPepperFlash(&system_flash)) | |
534 flash_versions.push_back(&system_flash); | |
535 | |
536 // Now sort the list and add the most recent flash plugin to the plugins list. | |
537 std::sort(flash_versions.begin(), flash_versions.end(), | |
538 [](content::PepperPluginInfo* x, content::PepperPluginInfo* y) { | |
539 Version version_x(x->version); | |
540 DCHECK(version_x.IsValid()); | |
541 return version_x.IsOlderThan(y->version); | |
542 }); | |
543 // Use the last element in the list, which will be the most recent flash. | |
544 if (flash_versions.size() > 0) | |
545 plugins->push_back(*flash_versions.back()); | |
472 #endif | 546 #endif |
jln (very slow on Chromium)
2015/08/04 01:08:33
// defined(ENABLE_PLUGINS)
Greg K
2015/08/04 18:30:00
Done.
| |
473 } | 547 } |
474 | 548 |
475 void ChromeContentClient::AddAdditionalSchemes( | 549 void ChromeContentClient::AddAdditionalSchemes( |
476 std::vector<std::string>* standard_schemes, | 550 std::vector<std::string>* standard_schemes, |
477 std::vector<std::string>* savable_schemes) { | 551 std::vector<std::string>* savable_schemes) { |
478 standard_schemes->push_back(extensions::kExtensionScheme); | 552 standard_schemes->push_back(extensions::kExtensionScheme); |
479 savable_schemes->push_back(extensions::kExtensionScheme); | 553 savable_schemes->push_back(extensions::kExtensionScheme); |
480 standard_schemes->push_back(chrome::kChromeNativeScheme); | 554 standard_schemes->push_back(chrome::kChromeNativeScheme); |
481 standard_schemes->push_back(extensions::kExtensionResourceScheme); | 555 standard_schemes->push_back(extensions::kExtensionResourceScheme); |
482 savable_schemes->push_back(extensions::kExtensionResourceScheme); | 556 savable_schemes->push_back(extensions::kExtensionResourceScheme); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
552 schemes->insert(content::kChromeUIScheme); | 626 schemes->insert(content::kChromeUIScheme); |
553 schemes->insert(extensions::kExtensionScheme); | 627 schemes->insert(extensions::kExtensionScheme); |
554 schemes->insert(extensions::kExtensionResourceScheme); | 628 schemes->insert(extensions::kExtensionResourceScheme); |
555 GetSecureOriginWhitelist(origins); | 629 GetSecureOriginWhitelist(origins); |
556 } | 630 } |
557 | 631 |
558 void ChromeContentClient::AddServiceWorkerSchemes( | 632 void ChromeContentClient::AddServiceWorkerSchemes( |
559 std::set<std::string>* schemes) { | 633 std::set<std::string>* schemes) { |
560 schemes->insert(extensions::kExtensionScheme); | 634 schemes->insert(extensions::kExtensionScheme); |
561 } | 635 } |
OLD | NEW |