Chromium Code Reviews| 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 <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 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/crash_keys.h" | 28 #include "chrome/common/crash_keys.h" |
| 29 #include "chrome/common/pepper_flash.h" | 29 #include "chrome/common/pepper_flash.h" |
| 30 #include "chrome/common/secure_origin_whitelist.h" | 30 #include "chrome/common/secure_origin_whitelist.h" |
| 31 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| 32 #include "chrome/grit/common_resources.h" | 32 #include "chrome/grit/common_resources.h" |
| 33 #include "components/data_reduction_proxy/content/common/data_reduction_proxy_me ssages.h" | 33 #include "components/data_reduction_proxy/content/common/data_reduction_proxy_me ssages.h" |
| 34 #include "components/dom_distiller/core/url_constants.h" | 34 #include "components/dom_distiller/core/url_constants.h" |
| 35 #include "components/version_info/version_info.h" | 35 #include "components/version_info/version_info.h" |
| 36 #include "content/public/common/cdm_info.h" | |
| 36 #include "content/public/common/content_constants.h" | 37 #include "content/public/common/content_constants.h" |
| 37 #include "content/public/common/content_switches.h" | 38 #include "content/public/common/content_switches.h" |
| 38 #include "content/public/common/url_constants.h" | 39 #include "content/public/common/url_constants.h" |
| 39 #include "content/public/common/user_agent.h" | 40 #include "content/public/common/user_agent.h" |
| 40 #include "extensions/common/constants.h" | 41 #include "extensions/common/constants.h" |
| 41 #include "gpu/config/gpu_info.h" | 42 #include "gpu/config/gpu_info.h" |
| 42 #include "net/http/http_util.h" | 43 #include "net/http/http_util.h" |
| 43 #include "ui/base/l10n/l10n_util.h" | 44 #include "ui/base/l10n/l10n_util.h" |
| 44 #include "ui/base/layout.h" | 45 #include "ui/base/layout.h" |
| 45 #include "ui/base/resource/resource_bundle.h" | 46 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface; | 93 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface; |
| 93 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module; | 94 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module; |
| 94 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module; | 95 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module; |
| 95 | 96 |
| 96 #if !defined(DISABLE_NACL) | 97 #if !defined(DISABLE_NACL) |
| 97 content::PepperPluginInfo::GetInterfaceFunc g_nacl_get_interface; | 98 content::PepperPluginInfo::GetInterfaceFunc g_nacl_get_interface; |
| 98 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module; | 99 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module; |
| 99 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module; | 100 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module; |
| 100 #endif | 101 #endif |
| 101 | 102 |
| 103 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ | |
| 104 !defined(WIDEVINE_CDM_IS_COMPONENT) | |
| 105 static bool IsWidevineAvailable(base::FilePath* adapter_path, | |
| 106 base::FilePath* cdm_path, | |
| 107 std::vector<std::string>* codecs_supported) { | |
| 108 static bool skip_widevine_cdm_file_check = false; | |
| 109 // TODO(jrummell): We should add a new path for DIR_WIDEVINE_CDM and use that | |
| 110 // to locate the CDM and the CDM adapter. | |
| 111 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, adapter_path)) { | |
| 112 *cdm_path = adapter_path->DirName().AppendASCII(kWidevineCdmFileName); | |
| 113 if (skip_widevine_cdm_file_check || | |
| 114 (base::PathExists(*adapter_path) && base::PathExists(*cdm_path))) { | |
| 115 skip_widevine_cdm_file_check = true; | |
| 116 | |
| 117 // Add the supported codecs as if they came from the component manifest. | |
| 118 // This list must match the CDM that is being bundled with Chrome. | |
| 119 codecs_supported->push_back(kCdmSupportedCodecVp8); | |
| 120 codecs_supported->push_back(kCdmSupportedCodecVp9); | |
| 121 #if defined(USE_PROPRIETARY_CODECS) | |
| 122 codecs_supported->push_back(kCdmSupportedCodecAvc1); | |
| 123 #endif // defined(USE_PROPRIETARY_CODECS) | |
| 124 return true; | |
| 125 } | |
| 126 } | |
| 127 | |
| 128 return false; | |
| 129 } | |
| 130 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && | |
| 131 // !defined(WIDEVINE_CDM_IS_COMPONENT) | |
| 132 | |
| 102 // Appends the known built-in plugins to the given vector. Some built-in | 133 // Appends the known built-in plugins to the given vector. Some built-in |
| 103 // plugins are "internal" which means they are compiled into the Chrome binary, | 134 // plugins are "internal" which means they are compiled into the Chrome binary, |
| 104 // and some are extra shared libraries distributed with the browser (these are | 135 // and some are extra shared libraries distributed with the browser (these are |
| 105 // not marked internal, aside from being automatically registered, they're just | 136 // not marked internal, aside from being automatically registered, they're just |
| 106 // regular plugins). | 137 // regular plugins). |
| 107 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { | 138 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { |
| 108 #if defined(ENABLE_PDF) | 139 #if defined(ENABLE_PDF) |
| 109 content::PepperPluginInfo pdf_info; | 140 content::PepperPluginInfo pdf_info; |
| 110 pdf_info.is_internal = true; | 141 pdf_info.is_internal = true; |
| 111 pdf_info.is_out_of_process = true; | 142 pdf_info.is_out_of_process = true; |
| 112 pdf_info.name = ChromeContentClient::kPDFPluginName; | 143 pdf_info.name = ChromeContentClient::kPDFPluginName; |
| 113 pdf_info.description = kPDFPluginDescription; | 144 pdf_info.description = kPDFPluginDescription; |
| 114 pdf_info.path = base::FilePath::FromUTF8Unsafe( | 145 pdf_info.path = base::FilePath::FromUTF8Unsafe( |
| 115 ChromeContentClient::kPDFPluginPath); | 146 ChromeContentClient::kPDFPluginPath); |
| 116 content::WebPluginMimeType pdf_mime_type( | 147 content::WebPluginMimeType pdf_mime_type( |
| 117 kPDFPluginOutOfProcessMimeType, | 148 kPDFPluginOutOfProcessMimeType, |
| 118 kPDFPluginExtension, | 149 kPDFPluginExtension, |
| 119 kPDFPluginDescription); | 150 kPDFPluginDescription); |
| 120 pdf_info.mime_types.push_back(pdf_mime_type); | 151 pdf_info.mime_types.push_back(pdf_mime_type); |
| 121 pdf_info.internal_entry_points.get_interface = g_pdf_get_interface; | 152 pdf_info.internal_entry_points.get_interface = g_pdf_get_interface; |
| 122 pdf_info.internal_entry_points.initialize_module = g_pdf_initialize_module; | 153 pdf_info.internal_entry_points.initialize_module = g_pdf_initialize_module; |
| 123 pdf_info.internal_entry_points.shutdown_module = g_pdf_shutdown_module; | 154 pdf_info.internal_entry_points.shutdown_module = g_pdf_shutdown_module; |
| 124 pdf_info.permissions = kPDFPluginPermissions; | 155 pdf_info.permissions = kPDFPluginPermissions; |
| 125 plugins->push_back(pdf_info); | 156 plugins->push_back(pdf_info); |
| 126 #endif // defined(ENABLE_PDF) | 157 #endif // defined(ENABLE_PDF) |
| 127 | 158 |
| 128 base::FilePath path; | |
| 129 | |
| 130 #if !defined(DISABLE_NACL) | 159 #if !defined(DISABLE_NACL) |
| 131 // Handle Native Client just like the PDF plugin. This means that it is | 160 // Handle Native Client just like the PDF plugin. This means that it is |
| 132 // enabled by default for the non-portable case. This allows apps installed | 161 // enabled by default for the non-portable case. This allows apps installed |
| 133 // from the Chrome Web Store to use NaCl even if the command line switch | 162 // from the Chrome Web Store to use NaCl even if the command line switch |
| 134 // isn't set. For other uses of NaCl we check for the command line switch. | 163 // isn't set. For other uses of NaCl we check for the command line switch. |
| 164 base::FilePath path; | |
| 135 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) { | 165 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) { |
| 136 content::PepperPluginInfo nacl; | 166 content::PepperPluginInfo nacl; |
| 137 // The nacl plugin is now built into the Chromium binary. | 167 // The nacl plugin is now built into the Chromium binary. |
| 138 nacl.is_internal = true; | 168 nacl.is_internal = true; |
| 139 nacl.path = path; | 169 nacl.path = path; |
| 140 nacl.name = nacl::kNaClPluginName; | 170 nacl.name = nacl::kNaClPluginName; |
| 141 content::WebPluginMimeType nacl_mime_type(nacl::kNaClPluginMimeType, | 171 content::WebPluginMimeType nacl_mime_type(nacl::kNaClPluginMimeType, |
| 142 nacl::kNaClPluginExtension, | 172 nacl::kNaClPluginExtension, |
| 143 nacl::kNaClPluginDescription); | 173 nacl::kNaClPluginDescription); |
| 144 nacl.mime_types.push_back(nacl_mime_type); | 174 nacl.mime_types.push_back(nacl_mime_type); |
| 145 content::WebPluginMimeType pnacl_mime_type(nacl::kPnaclPluginMimeType, | 175 content::WebPluginMimeType pnacl_mime_type(nacl::kPnaclPluginMimeType, |
| 146 nacl::kPnaclPluginExtension, | 176 nacl::kPnaclPluginExtension, |
| 147 nacl::kPnaclPluginDescription); | 177 nacl::kPnaclPluginDescription); |
| 148 nacl.mime_types.push_back(pnacl_mime_type); | 178 nacl.mime_types.push_back(pnacl_mime_type); |
| 149 nacl.internal_entry_points.get_interface = g_nacl_get_interface; | 179 nacl.internal_entry_points.get_interface = g_nacl_get_interface; |
| 150 nacl.internal_entry_points.initialize_module = g_nacl_initialize_module; | 180 nacl.internal_entry_points.initialize_module = g_nacl_initialize_module; |
| 151 nacl.internal_entry_points.shutdown_module = g_nacl_shutdown_module; | 181 nacl.internal_entry_points.shutdown_module = g_nacl_shutdown_module; |
| 152 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; | 182 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; |
| 153 plugins->push_back(nacl); | 183 plugins->push_back(nacl); |
| 154 } | 184 } |
| 155 #endif // !defined(DISABLE_NACL) | 185 #endif // !defined(DISABLE_NACL) |
| 156 | 186 |
| 157 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ | 187 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ |
| 158 !defined(WIDEVINE_CDM_IS_COMPONENT) | 188 !defined(WIDEVINE_CDM_IS_COMPONENT) |
| 159 static bool skip_widevine_cdm_file_check = false; | 189 base::FilePath adapter_path; |
| 160 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &path)) { | 190 base::FilePath cdm_path; |
| 161 if (skip_widevine_cdm_file_check || base::PathExists(path)) { | 191 std::vector<std::string> codecs_supported; |
| 162 content::PepperPluginInfo widevine_cdm; | 192 if (IsWidevineAvailable(&adapter_path, &cdm_path, &codecs_supported)) { |
| 163 widevine_cdm.is_out_of_process = true; | 193 content::PepperPluginInfo widevine_cdm; |
| 164 widevine_cdm.path = path; | 194 widevine_cdm.is_out_of_process = true; |
| 165 widevine_cdm.name = kWidevineCdmDisplayName; | 195 widevine_cdm.path = adapter_path; |
| 166 widevine_cdm.description = kWidevineCdmDescription + | 196 widevine_cdm.name = kWidevineCdmDisplayName; |
| 167 std::string(" (version: ") + | 197 widevine_cdm.description = kWidevineCdmDescription + |
|
Sorin Jianu
2016/04/15 01:53:26
Could use stringprintf.h for more efficient format
jrummell
2016/04/18 20:39:47
Done.
| |
| 168 WIDEVINE_CDM_VERSION_STRING + ")"; | 198 std::string(" (version: ") + |
| 169 widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING; | 199 WIDEVINE_CDM_VERSION_STRING + ")"; |
| 170 content::WebPluginMimeType widevine_cdm_mime_type( | 200 widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING; |
| 171 kWidevineCdmPluginMimeType, | 201 content::WebPluginMimeType widevine_cdm_mime_type( |
| 172 kWidevineCdmPluginExtension, | 202 kWidevineCdmPluginMimeType, kWidevineCdmPluginExtension, |
| 173 kWidevineCdmPluginMimeTypeDescription); | 203 kWidevineCdmPluginMimeTypeDescription); |
| 174 | 204 |
| 175 // Add the supported codecs as if they came from the component manifest. | 205 widevine_cdm_mime_type.additional_param_names.push_back( |
| 176 // This list must match the CDM that is being bundled with Chrome. | 206 base::ASCIIToUTF16(kCdmSupportedCodecsParamName)); |
| 177 std::vector<std::string> codecs; | 207 widevine_cdm_mime_type.additional_param_values.push_back(base::ASCIIToUTF16( |
| 178 codecs.push_back(kCdmSupportedCodecVp8); | 208 base::JoinString(codecs_supported, |
| 179 codecs.push_back(kCdmSupportedCodecVp9); | 209 std::string(1, kCdmSupportedCodecsValueDelimiter)))); |
| 180 #if defined(USE_PROPRIETARY_CODECS) | |
| 181 codecs.push_back(kCdmSupportedCodecAvc1); | |
| 182 #endif // defined(USE_PROPRIETARY_CODECS) | |
| 183 std::string codec_string = base::JoinString( | |
| 184 codecs, std::string(1, kCdmSupportedCodecsValueDelimiter)); | |
| 185 widevine_cdm_mime_type.additional_param_names.push_back( | |
| 186 base::ASCIIToUTF16(kCdmSupportedCodecsParamName)); | |
| 187 widevine_cdm_mime_type.additional_param_values.push_back( | |
| 188 base::ASCIIToUTF16(codec_string)); | |
| 189 | 210 |
| 190 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); | 211 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); |
| 191 widevine_cdm.permissions = kWidevineCdmPluginPermissions; | 212 widevine_cdm.permissions = kWidevineCdmPluginPermissions; |
| 192 plugins->push_back(widevine_cdm); | 213 plugins->push_back(widevine_cdm); |
| 193 | |
| 194 skip_widevine_cdm_file_check = true; | |
| 195 } | |
| 196 } | 214 } |
| 197 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && | 215 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && |
| 198 // !defined(WIDEVINE_CDM_IS_COMPONENT) | 216 // !defined(WIDEVINE_CDM_IS_COMPONENT) |
| 199 } | 217 } |
| 200 | 218 |
| 201 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, | 219 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, |
| 202 const std::string& version, | 220 const std::string& version, |
| 203 bool is_debug) { | 221 bool is_debug) { |
| 204 content::PepperPluginInfo plugin; | 222 content::PepperPluginInfo plugin; |
| 205 | 223 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 flash_versions.push_back(system_flash.release()); | 532 flash_versions.push_back(system_flash.release()); |
| 515 | 533 |
| 516 // This function will return only the most recent version of the flash plugin. | 534 // This function will return only the most recent version of the flash plugin. |
| 517 content::PepperPluginInfo* max_flash = | 535 content::PepperPluginInfo* max_flash = |
| 518 FindMostRecentPlugin(flash_versions.get()); | 536 FindMostRecentPlugin(flash_versions.get()); |
| 519 if (max_flash) | 537 if (max_flash) |
| 520 plugins->push_back(*max_flash); | 538 plugins->push_back(*max_flash); |
| 521 #endif // defined(ENABLE_PLUGINS) | 539 #endif // defined(ENABLE_PLUGINS) |
| 522 } | 540 } |
| 523 | 541 |
| 542 void ChromeContentClient::AddContentDecryptionModules( | |
| 543 std::vector<content::CdmInfo>* cdms) { | |
| 544 // TODO(jrummell): Need to have a better flag to indicate systems Widevine | |
| 545 // is available on. For now we continue to use ENABLE_PEPPER_CDMS so that | |
| 546 // we can experiment between pepper and mojo. | |
| 547 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ | |
| 548 !defined(WIDEVINE_CDM_IS_COMPONENT) | |
| 549 base::FilePath adapter_path; | |
| 550 base::FilePath cdm_path; | |
| 551 std::vector<std::string> codecs_supported; | |
| 552 if (IsWidevineAvailable(&adapter_path, &cdm_path, &codecs_supported)) { | |
| 553 // CdmInfo needs |path| to be the actual Widevine library, | |
| 554 // not the adapter, so adjust as necessary. It will be in the | |
| 555 // same directory as the installed adapter. | |
| 556 base::Version version(WIDEVINE_CDM_VERSION_STRING); | |
|
Sorin Jianu
2016/04/15 01:53:26
const
jrummell
2016/04/18 20:39:47
Done.
| |
| 557 DCHECK(version.IsValid()); | |
| 558 cdms->push_back(content::CdmInfo(kWidevineCdmType, version, cdm_path, | |
| 559 codecs_supported)); | |
| 560 } | |
| 561 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && | |
| 562 // !defined(WIDEVINE_CDM_IS_COMPONENT) | |
| 563 | |
| 564 // TODO(jrummell): Add External Clear Key CDM for testing, if it's available. | |
| 565 } | |
| 566 | |
| 524 #if defined(OS_CHROMEOS) | 567 #if defined(OS_CHROMEOS) |
| 525 static const int kNumChromeStandardURLSchemes = 6; | 568 static const int kNumChromeStandardURLSchemes = 6; |
| 526 #else | 569 #else |
| 527 static const int kNumChromeStandardURLSchemes = 5; | 570 static const int kNumChromeStandardURLSchemes = 5; |
| 528 #endif | 571 #endif |
| 529 static const url::SchemeWithType kChromeStandardURLSchemes[ | 572 static const url::SchemeWithType kChromeStandardURLSchemes[ |
| 530 kNumChromeStandardURLSchemes] = { | 573 kNumChromeStandardURLSchemes] = { |
| 531 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT}, | 574 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT}, |
| 532 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT}, | 575 {chrome::kChromeNativeScheme, url::SCHEME_WITHOUT_PORT}, |
| 533 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT}, | 576 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT}, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 #if defined(ENABLE_EXTENSIONS) | 683 #if defined(ENABLE_EXTENSIONS) |
| 641 return extensions::IsIsolateExtensionsEnabled(); | 684 return extensions::IsIsolateExtensionsEnabled(); |
| 642 #else | 685 #else |
| 643 return false; | 686 return false; |
| 644 #endif | 687 #endif |
| 645 } | 688 } |
| 646 | 689 |
| 647 base::StringPiece ChromeContentClient::GetOriginTrialPublicKey() { | 690 base::StringPiece ChromeContentClient::GetOriginTrialPublicKey() { |
| 648 return origin_trial_key_manager_.GetPublicKey(); | 691 return origin_trial_key_manager_.GetPublicKey(); |
| 649 } | 692 } |
| OLD | NEW |