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" |
23 #include "chrome/common/chrome_version_info.h" | 25 #include "chrome/common/chrome_version_info.h" |
26 #include "chrome/common/component_flash_hint_file.h" | |
24 #include "chrome/common/crash_keys.h" | 27 #include "chrome/common/crash_keys.h" |
25 #include "chrome/common/pepper_flash.h" | 28 #include "chrome/common/pepper_flash.h" |
26 #include "chrome/common/secure_origin_whitelist.h" | 29 #include "chrome/common/secure_origin_whitelist.h" |
27 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
28 #include "chrome/grit/common_resources.h" | 31 #include "chrome/grit/common_resources.h" |
29 #include "components/dom_distiller/core/url_constants.h" | 32 #include "components/dom_distiller/core/url_constants.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" |
33 #include "content/public/common/user_agent.h" | 36 #include "content/public/common/user_agent.h" |
37 #include "crypto/sha2.h" | |
34 #include "extensions/common/constants.h" | 38 #include "extensions/common/constants.h" |
35 #include "gpu/config/gpu_info.h" | 39 #include "gpu/config/gpu_info.h" |
36 #include "net/http/http_util.h" | 40 #include "net/http/http_util.h" |
37 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
38 #include "ui/base/layout.h" | 42 #include "ui/base/layout.h" |
39 #include "ui/base/resource/resource_bundle.h" | 43 #include "ui/base/resource/resource_bundle.h" |
40 | 44 |
41 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 45 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
42 | 46 |
43 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
(...skipping 230 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 | 278 // Also get the version from the command-line. Should be something like 11.2 |
275 // or 11.2.123.45. | 279 // or 11.2.123.45. |
276 std::string flash_version = | 280 std::string flash_version = |
277 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 281 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
278 switches::kPpapiFlashVersion); | 282 switches::kPpapiFlashVersion); |
279 | 283 |
280 plugins->push_back( | 284 plugins->push_back( |
281 CreatePepperFlashInfo(base::FilePath(flash_path), flash_version)); | 285 CreatePepperFlashInfo(base::FilePath(flash_path), flash_version)); |
282 } | 286 } |
283 | 287 |
288 #if defined(OS_LINUX) | |
289 bool IsUserDataDirAvailable() { | |
290 base::FilePath user_data_dir; | |
291 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) | |
292 return false; | |
293 return base::PathExists(user_data_dir); | |
294 } | |
295 #endif // defined(OS_LINUX) | |
296 | |
297 // This method is used on Linux only because of architectural differences in how | |
298 // it loads the component updated flash plugin, and not because the other | |
299 // platforms do not support component updated flash. On other platforms, the | |
300 // component updater sends an IPC message to all threads, at undefined points in | |
301 // time, with the URL of the component updated flash. Because the linux zygote | |
302 // thread has no access to the file system after it warms up, it must preload | |
303 // the component updated flash. | |
304 #if defined(OS_LINUX) | |
305 bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo* plugin) { | |
306 #if defined(FLAPPER_AVAILABLE) | |
307 base::FilePath flash_path; | |
308 std::string version; | |
309 if (chrome::ComponentFlashHintFile::DoesHintFileExist()) { | |
310 bool verified = | |
311 chrome::ComponentFlashHintFile::VerifyAndReturnFlashLocation( | |
312 &flash_path, &version); | |
313 if (verified) { | |
314 *plugin = CreatePepperFlashInfo(flash_path, version); | |
315 return true; | |
rickyz (no longer on Chrome)
2015/07/31 00:13:56
Is there any handling for when DIR_USER_DATA is on
Greg K
2015/08/04 00:21:17
Done.
| |
316 } | |
317 } | |
318 return false; | |
319 #else | |
320 return false; | |
321 #endif // defined(FLAPPER_AVAILABLE) | |
322 } | |
323 #endif // defined(OS_LINUX) | |
324 | |
284 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) { | 325 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) { |
285 #if defined(FLAPPER_AVAILABLE) | 326 #if defined(FLAPPER_AVAILABLE) |
286 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 327 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
287 | 328 |
288 // Ignore bundled Pepper Flash if there is Pepper Flash specified from the | 329 // Ignore bundled Pepper Flash if there is Pepper Flash specified from the |
289 // command-line. | 330 // command-line. |
290 if (command_line->HasSwitch(switches::kPpapiFlashPath)) | 331 if (command_line->HasSwitch(switches::kPpapiFlashPath)) |
291 return false; | 332 return false; |
292 | 333 |
293 bool force_disable = | 334 bool force_disable = |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); | 499 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); |
459 #endif | 500 #endif |
460 } | 501 } |
461 | 502 |
462 void ChromeContentClient::AddPepperPlugins( | 503 void ChromeContentClient::AddPepperPlugins( |
463 std::vector<content::PepperPluginInfo>* plugins) { | 504 std::vector<content::PepperPluginInfo>* plugins) { |
464 #if defined(ENABLE_PLUGINS) | 505 #if defined(ENABLE_PLUGINS) |
465 ComputeBuiltInPlugins(plugins); | 506 ComputeBuiltInPlugins(plugins); |
466 AddPepperFlashFromCommandLine(plugins); | 507 AddPepperFlashFromCommandLine(plugins); |
467 | 508 |
468 content::PepperPluginInfo plugin; | 509 #if defined(OS_LINUX) |
469 if (GetBundledPepperFlash(&plugin)) | 510 // Depending on the sandbox configurtion, the user data directory |
470 plugins->push_back(plugin); | 511 // is not always available. If it is not available, do not try and load and |
471 if (GetSystemPepperFlash(&plugin)) | 512 // flash plugin. It may incorrectly try to load the system flash plugin in |
472 plugins->push_back(plugin); | 513 // this case. |
514 if (!IsUserDataDirAvailable()) { | |
515 return; | |
516 } | |
517 #endif | |
518 | |
519 std::vector<content::PepperPluginInfo*> flash_versions; | |
520 | |
521 #if defined(OS_LINUX) | |
522 content::PepperPluginInfo component_flash; | |
523 if (GetComponentUpdatedPepperFlash(&component_flash)) | |
524 flash_versions.push_back(&component_flash); | |
525 #endif | |
526 | |
527 content::PepperPluginInfo bundled_flash; | |
528 if (GetBundledPepperFlash(&bundled_flash)) | |
529 flash_versions.push_back(&bundled_flash); | |
530 | |
531 content::PepperPluginInfo system_flash; | |
532 if (GetSystemPepperFlash(&system_flash)) | |
533 flash_versions.push_back(&system_flash); | |
534 | |
535 // Now sort the list and add the most recent flash plugin to the plugins list. | |
536 std::sort(flash_versions.begin(), flash_versions.end(), | |
537 [](content::PepperPluginInfo* x, content::PepperPluginInfo* y) { | |
538 Version version_x(x->version); | |
539 DCHECK(version_x.IsValid()); | |
540 return version_x.IsOlderThan(y->version); | |
541 }); | |
542 // Use the last element in the list, which will be the most recent flash. | |
543 plugins->push_back(*flash_versions.back()); | |
473 #endif | 544 #endif |
474 } | 545 } |
475 | 546 |
476 void ChromeContentClient::AddAdditionalSchemes( | 547 void ChromeContentClient::AddAdditionalSchemes( |
477 std::vector<std::string>* standard_schemes, | 548 std::vector<std::string>* standard_schemes, |
478 std::vector<std::string>* savable_schemes) { | 549 std::vector<std::string>* savable_schemes) { |
479 standard_schemes->push_back(extensions::kExtensionScheme); | 550 standard_schemes->push_back(extensions::kExtensionScheme); |
480 savable_schemes->push_back(extensions::kExtensionScheme); | 551 savable_schemes->push_back(extensions::kExtensionScheme); |
481 standard_schemes->push_back(chrome::kChromeNativeScheme); | 552 standard_schemes->push_back(chrome::kChromeNativeScheme); |
482 standard_schemes->push_back(extensions::kExtensionResourceScheme); | 553 standard_schemes->push_back(extensions::kExtensionResourceScheme); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
553 schemes->insert(content::kChromeUIScheme); | 624 schemes->insert(content::kChromeUIScheme); |
554 schemes->insert(extensions::kExtensionScheme); | 625 schemes->insert(extensions::kExtensionScheme); |
555 schemes->insert(extensions::kExtensionResourceScheme); | 626 schemes->insert(extensions::kExtensionResourceScheme); |
556 GetSecureOriginWhitelist(origins); | 627 GetSecureOriginWhitelist(origins); |
557 } | 628 } |
558 | 629 |
559 void ChromeContentClient::AddServiceWorkerSchemes( | 630 void ChromeContentClient::AddServiceWorkerSchemes( |
560 std::set<std::string>* schemes) { | 631 std::set<std::string>* schemes) { |
561 schemes->insert(extensions::kExtensionScheme); | 632 schemes->insert(extensions::kExtensionScheme); |
562 } | 633 } |
OLD | NEW |