| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 #include "components/nacl/common/nacl_constants.h" | 64 #include "components/nacl/common/nacl_constants.h" |
| 65 #include "components/nacl/common/nacl_process_type.h" | 65 #include "components/nacl/common/nacl_process_type.h" |
| 66 #include "components/nacl/common/nacl_sandbox_type.h" | 66 #include "components/nacl/common/nacl_sandbox_type.h" |
| 67 #endif | 67 #endif |
| 68 | 68 |
| 69 #if BUILDFLAG(ENABLE_EXTENSIONS) | 69 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 70 #include "chrome/common/extensions/extension_process_policy.h" | 70 #include "chrome/common/extensions/extension_process_policy.h" |
| 71 #include "extensions/common/features/feature_util.h" | 71 #include "extensions/common/features/feature_util.h" |
| 72 #endif | 72 #endif |
| 73 | 73 |
| 74 #if defined(ENABLE_PLUGINS) | 74 #if BUILDFLAG(ENABLE_PLUGINS) |
| 75 #include "content/public/common/pepper_plugin_info.h" | 75 #include "content/public/common/pepper_plugin_info.h" |
| 76 #include "flapper_version.h" // nogncheck In SHARED_INTERMEDIATE_DIR. | 76 #include "flapper_version.h" // nogncheck In SHARED_INTERMEDIATE_DIR. |
| 77 #include "ppapi/shared_impl/ppapi_permissions.h" | 77 #include "ppapi/shared_impl/ppapi_permissions.h" |
| 78 #endif | 78 #endif |
| 79 | 79 |
| 80 #if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) && \ | 80 #if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_PEPPER_CDMS) && \ |
| 81 !defined(WIDEVINE_CDM_IS_COMPONENT) | 81 !defined(WIDEVINE_CDM_IS_COMPONENT) |
| 82 #define WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT | 82 #define WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT |
| 83 #include "chrome/common/widevine_cdm_constants.h" | 83 #include "chrome/common/widevine_cdm_constants.h" |
| 84 #endif | 84 #endif |
| 85 | 85 |
| 86 #if defined(OS_ANDROID) | 86 #if defined(OS_ANDROID) |
| 87 #include "chrome/common/chrome_media_client_android.h" | 87 #include "chrome/common/chrome_media_client_android.h" |
| 88 #endif | 88 #endif |
| 89 | 89 |
| 90 namespace { | 90 namespace { |
| 91 | 91 |
| 92 #if defined(ENABLE_PLUGINS) | 92 #if BUILDFLAG(ENABLE_PLUGINS) |
| 93 #if defined(ENABLE_PDF) | 93 #if defined(ENABLE_PDF) |
| 94 const char kPDFPluginExtension[] = "pdf"; | 94 const char kPDFPluginExtension[] = "pdf"; |
| 95 const char kPDFPluginDescription[] = "Portable Document Format"; | 95 const char kPDFPluginDescription[] = "Portable Document Format"; |
| 96 const char kPDFPluginOutOfProcessMimeType[] = | 96 const char kPDFPluginOutOfProcessMimeType[] = |
| 97 "application/x-google-chrome-pdf"; | 97 "application/x-google-chrome-pdf"; |
| 98 const uint32_t kPDFPluginPermissions = | 98 const uint32_t kPDFPluginPermissions = |
| 99 ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; | 99 ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; |
| 100 #endif // defined(ENABLE_PDF) | 100 #endif // defined(ENABLE_PDF) |
| 101 | 101 |
| 102 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface; | 102 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 if (command_line->HasSwitch(switches::kPpapiFlashPath)) | 376 if (command_line->HasSwitch(switches::kPpapiFlashPath)) |
| 377 return false; | 377 return false; |
| 378 | 378 |
| 379 base::FilePath flash_filename; | 379 base::FilePath flash_filename; |
| 380 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN, | 380 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN, |
| 381 &flash_filename)) | 381 &flash_filename)) |
| 382 return false; | 382 return false; |
| 383 | 383 |
| 384 return TryCreatePepperFlashInfo(flash_filename, plugin); | 384 return TryCreatePepperFlashInfo(flash_filename, plugin); |
| 385 } | 385 } |
| 386 #endif // defined(ENABLE_PLUGINS) | 386 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 387 | 387 |
| 388 std::string GetProduct() { | 388 std::string GetProduct() { |
| 389 return version_info::GetProductNameAndVersionForUserAgent(); | 389 return version_info::GetProductNameAndVersionForUserAgent(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 } // namespace | 392 } // namespace |
| 393 | 393 |
| 394 std::string GetUserAgent() { | 394 std::string GetUserAgent() { |
| 395 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 395 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 396 if (command_line->HasSwitch(switches::kUserAgent)) { | 396 if (command_line->HasSwitch(switches::kUserAgent)) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 418 void ChromeContentClient::SetNaClEntryFunctions( | 418 void ChromeContentClient::SetNaClEntryFunctions( |
| 419 content::PepperPluginInfo::GetInterfaceFunc get_interface, | 419 content::PepperPluginInfo::GetInterfaceFunc get_interface, |
| 420 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module, | 420 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module, |
| 421 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module) { | 421 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module) { |
| 422 g_nacl_get_interface = get_interface; | 422 g_nacl_get_interface = get_interface; |
| 423 g_nacl_initialize_module = initialize_module; | 423 g_nacl_initialize_module = initialize_module; |
| 424 g_nacl_shutdown_module = shutdown_module; | 424 g_nacl_shutdown_module = shutdown_module; |
| 425 } | 425 } |
| 426 #endif | 426 #endif |
| 427 | 427 |
| 428 #if defined(ENABLE_PLUGINS) | 428 #if BUILDFLAG(ENABLE_PLUGINS) |
| 429 void ChromeContentClient::SetPDFEntryFunctions( | 429 void ChromeContentClient::SetPDFEntryFunctions( |
| 430 content::PepperPluginInfo::GetInterfaceFunc get_interface, | 430 content::PepperPluginInfo::GetInterfaceFunc get_interface, |
| 431 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module, | 431 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module, |
| 432 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module) { | 432 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module) { |
| 433 g_pdf_get_interface = get_interface; | 433 g_pdf_get_interface = get_interface; |
| 434 g_pdf_initialize_module = initialize_module; | 434 g_pdf_initialize_module = initialize_module; |
| 435 g_pdf_shutdown_module = shutdown_module; | 435 g_pdf_shutdown_module = shutdown_module; |
| 436 } | 436 } |
| 437 #endif | 437 #endif |
| 438 | 438 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 455 base::debug::SetCrashKeyValue(crash_keys::kGPUVertexShaderVersion, | 455 base::debug::SetCrashKeyValue(crash_keys::kGPUVertexShaderVersion, |
| 456 gpu_info.vertex_shader_version); | 456 gpu_info.vertex_shader_version); |
| 457 #if defined(OS_MACOSX) | 457 #if defined(OS_MACOSX) |
| 458 base::debug::SetCrashKeyValue(crash_keys::kGPUGLVersion, gpu_info.gl_version); | 458 base::debug::SetCrashKeyValue(crash_keys::kGPUGLVersion, gpu_info.gl_version); |
| 459 #elif defined(OS_POSIX) | 459 #elif defined(OS_POSIX) |
| 460 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor); | 460 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor); |
| 461 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); | 461 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); |
| 462 #endif | 462 #endif |
| 463 } | 463 } |
| 464 | 464 |
| 465 #if defined(ENABLE_PLUGINS) | 465 #if BUILDFLAG(ENABLE_PLUGINS) |
| 466 // static | 466 // static |
| 467 content::PepperPluginInfo* ChromeContentClient::FindMostRecentPlugin( | 467 content::PepperPluginInfo* ChromeContentClient::FindMostRecentPlugin( |
| 468 const std::vector<std::unique_ptr<content::PepperPluginInfo>>& plugins) { | 468 const std::vector<std::unique_ptr<content::PepperPluginInfo>>& plugins) { |
| 469 if (plugins.empty()) | 469 if (plugins.empty()) |
| 470 return nullptr; | 470 return nullptr; |
| 471 | 471 |
| 472 using PluginSortKey = std::tuple<base::Version, bool>; | 472 using PluginSortKey = std::tuple<base::Version, bool>; |
| 473 | 473 |
| 474 std::map<PluginSortKey, content::PepperPluginInfo*> plugin_map; | 474 std::map<PluginSortKey, content::PepperPluginInfo*> plugin_map; |
| 475 | 475 |
| 476 for (auto& plugin : plugins) { | 476 for (auto& plugin : plugins) { |
| 477 base::Version version(plugin->version); | 477 base::Version version(plugin->version); |
| 478 DCHECK(version.IsValid()); | 478 DCHECK(version.IsValid()); |
| 479 plugin_map[PluginSortKey(version, plugin->is_external)] = plugin.get(); | 479 plugin_map[PluginSortKey(version, plugin->is_external)] = plugin.get(); |
| 480 } | 480 } |
| 481 | 481 |
| 482 return plugin_map.rbegin()->second; | 482 return plugin_map.rbegin()->second; |
| 483 } | 483 } |
| 484 #endif // defined(ENABLE_PLUGINS) | 484 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 485 | 485 |
| 486 void ChromeContentClient::AddPepperPlugins( | 486 void ChromeContentClient::AddPepperPlugins( |
| 487 std::vector<content::PepperPluginInfo>* plugins) { | 487 std::vector<content::PepperPluginInfo>* plugins) { |
| 488 #if defined(ENABLE_PLUGINS) | 488 #if BUILDFLAG(ENABLE_PLUGINS) |
| 489 ComputeBuiltInPlugins(plugins); | 489 ComputeBuiltInPlugins(plugins); |
| 490 | 490 |
| 491 std::vector<std::unique_ptr<content::PepperPluginInfo>> flash_versions; | 491 std::vector<std::unique_ptr<content::PepperPluginInfo>> flash_versions; |
| 492 | 492 |
| 493 // Get component updated flash for desktop Linux and Chrome OS. | 493 // Get component updated flash for desktop Linux and Chrome OS. |
| 494 #if defined(OS_LINUX) | 494 #if defined(OS_LINUX) |
| 495 // Depending on the sandbox configuration, the file system | 495 // Depending on the sandbox configuration, the file system |
| 496 // is not always available. If it is not available, do not try and load any | 496 // is not always available. If it is not available, do not try and load any |
| 497 // flash plugin. The flash player, if any, preloaded before the sandbox | 497 // flash plugin. The flash player, if any, preloaded before the sandbox |
| 498 // initialization will continue to be used. | 498 // initialization will continue to be used. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 521 // Add a fake Flash plugin even though it doesn't actually exist - if a | 521 // Add a fake Flash plugin even though it doesn't actually exist - if a |
| 522 // web page requests it, it will be component-updated on-demand. There is | 522 // web page requests it, it will be component-updated on-demand. There is |
| 523 // nothing that guarantees the component update will give us the | 523 // nothing that guarantees the component update will give us the |
| 524 // FLAPPER_VERSION_STRING version of Flash, but using this version seems | 524 // FLAPPER_VERSION_STRING version of Flash, but using this version seems |
| 525 // better than any other hardcoded alternative. | 525 // better than any other hardcoded alternative. |
| 526 plugins->push_back(CreatePepperFlashInfo( | 526 plugins->push_back(CreatePepperFlashInfo( |
| 527 base::FilePath::FromUTF8Unsafe(ChromeContentClient::kNotPresent), | 527 base::FilePath::FromUTF8Unsafe(ChromeContentClient::kNotPresent), |
| 528 FLAPPER_VERSION_STRING, false)); | 528 FLAPPER_VERSION_STRING, false)); |
| 529 #endif // defined(GOOGLE_CHROME_BUILD) && defined(FLAPPER_AVAILABLE) | 529 #endif // defined(GOOGLE_CHROME_BUILD) && defined(FLAPPER_AVAILABLE) |
| 530 } | 530 } |
| 531 #endif // defined(ENABLE_PLUGINS) | 531 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 532 } | 532 } |
| 533 | 533 |
| 534 void ChromeContentClient::AddContentDecryptionModules( | 534 void ChromeContentClient::AddContentDecryptionModules( |
| 535 std::vector<content::CdmInfo>* cdms) { | 535 std::vector<content::CdmInfo>* cdms) { |
| 536 // TODO(jrummell): Need to have a better flag to indicate systems Widevine | 536 // TODO(jrummell): Need to have a better flag to indicate systems Widevine |
| 537 // is available on. For now we continue to use ENABLE_PEPPER_CDMS so that | 537 // is available on. For now we continue to use ENABLE_PEPPER_CDMS so that |
| 538 // we can experiment between pepper and mojo. | 538 // we can experiment between pepper and mojo. |
| 539 #if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) | 539 #if defined(WIDEVINE_CDM_AVAILABLE_NOT_COMPONENT) |
| 540 base::FilePath adapter_path; | 540 base::FilePath adapter_path; |
| 541 base::FilePath cdm_path; | 541 base::FilePath cdm_path; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 if (!origin_trial_policy_) | 686 if (!origin_trial_policy_) |
| 687 origin_trial_policy_ = base::MakeUnique<ChromeOriginTrialPolicy>(); | 687 origin_trial_policy_ = base::MakeUnique<ChromeOriginTrialPolicy>(); |
| 688 return origin_trial_policy_.get(); | 688 return origin_trial_policy_.get(); |
| 689 } | 689 } |
| 690 | 690 |
| 691 #if defined(OS_ANDROID) | 691 #if defined(OS_ANDROID) |
| 692 media::MediaClientAndroid* ChromeContentClient::GetMediaClientAndroid() { | 692 media::MediaClientAndroid* ChromeContentClient::GetMediaClientAndroid() { |
| 693 return new ChromeMediaClientAndroid(); | 693 return new ChromeMediaClientAndroid(); |
| 694 } | 694 } |
| 695 #endif // OS_ANDROID | 695 #endif // OS_ANDROID |
| OLD | NEW |