Chromium Code Reviews| Index: chrome/common/chrome_content_client.cc |
| diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc |
| index 4a2456f278f66a9a9ef94f3723c46f458e1cb281..f6e9dcd9323fa6fb4eea68801363d9e7111738d4 100644 |
| --- a/chrome/common/chrome_content_client.cc |
| +++ b/chrome/common/chrome_content_client.cc |
| @@ -31,6 +31,7 @@ |
| #include "components/data_reduction_proxy/content/common/data_reduction_proxy_messages.h" |
| #include "components/dom_distiller/core/url_constants.h" |
| #include "components/version_info/version_info.h" |
| +#include "content/public/common/cdm_info.h" |
| #include "content/public/common/content_constants.h" |
| #include "content/public/common/content_switches.h" |
| #include "content/public/common/url_constants.h" |
| @@ -98,6 +99,31 @@ content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module; |
| content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module; |
| #endif |
| +#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ |
| + !defined(WIDEVINE_CDM_IS_COMPONENT) |
| +static bool IsWidevineAvailable(base::FilePath* cdm_adapter_path, |
| + std::vector<std::string>* codecs_supported) { |
| + static bool skip_widevine_cdm_file_check = false; |
| + if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, cdm_adapter_path)) { |
| + if (skip_widevine_cdm_file_check || base::PathExists(*cdm_adapter_path)) { |
| + skip_widevine_cdm_file_check = true; |
| + |
| + // Add the supported codecs as if they came from the component manifest. |
| + // This list must match the CDM that is being bundled with Chrome. |
| + codecs_supported->push_back(kCdmSupportedCodecVp8); |
| + codecs_supported->push_back(kCdmSupportedCodecVp9); |
| +#if defined(USE_PROPRIETARY_CODECS) |
| + codecs_supported->push_back(kCdmSupportedCodecAvc1); |
| +#endif // defined(USE_PROPRIETARY_CODECS) |
| + return true; |
| + } |
| + } |
| + |
| + return false; |
| +} |
| +#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && |
| + // !defined(WIDEVINE_CDM_IS_COMPONENT) |
| + |
| // Appends the known built-in plugins to the given vector. Some built-in |
| // plugins are "internal" which means they are compiled into the Chrome binary, |
| // and some are extra shared libraries distributed with the browser (these are |
| @@ -155,43 +181,29 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { |
| #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ |
| !defined(WIDEVINE_CDM_IS_COMPONENT) |
| - static bool skip_widevine_cdm_file_check = false; |
| - if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &path)) { |
| - if (skip_widevine_cdm_file_check || base::PathExists(path)) { |
| - content::PepperPluginInfo widevine_cdm; |
| - widevine_cdm.is_out_of_process = true; |
| - widevine_cdm.path = path; |
| - widevine_cdm.name = kWidevineCdmDisplayName; |
| - widevine_cdm.description = kWidevineCdmDescription + |
| - std::string(" (version: ") + |
| - WIDEVINE_CDM_VERSION_STRING + ")"; |
| - widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING; |
| - content::WebPluginMimeType widevine_cdm_mime_type( |
| - kWidevineCdmPluginMimeType, |
| - kWidevineCdmPluginExtension, |
| - kWidevineCdmPluginMimeTypeDescription); |
| - |
| - // Add the supported codecs as if they came from the component manifest. |
| - // This list must match the CDM that is being bundled with Chrome. |
| - std::vector<std::string> codecs; |
| - codecs.push_back(kCdmSupportedCodecVp8); |
| - codecs.push_back(kCdmSupportedCodecVp9); |
| -#if defined(USE_PROPRIETARY_CODECS) |
| - codecs.push_back(kCdmSupportedCodecAvc1); |
| -#endif // defined(USE_PROPRIETARY_CODECS) |
| - std::string codec_string = base::JoinString( |
| - codecs, std::string(1, kCdmSupportedCodecsValueDelimiter)); |
| - widevine_cdm_mime_type.additional_param_names.push_back( |
| - base::ASCIIToUTF16(kCdmSupportedCodecsParamName)); |
| - widevine_cdm_mime_type.additional_param_values.push_back( |
| - base::ASCIIToUTF16(codec_string)); |
| - |
| - widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); |
| - widevine_cdm.permissions = kWidevineCdmPluginPermissions; |
| - plugins->push_back(widevine_cdm); |
| - |
| - skip_widevine_cdm_file_check = true; |
| - } |
| + std::vector<std::string> codecs_supported; |
| + if (IsWidevineAvailable(&path, &codecs_supported)) { |
| + content::PepperPluginInfo widevine_cdm; |
| + widevine_cdm.is_out_of_process = true; |
| + widevine_cdm.path = path; |
| + widevine_cdm.name = kWidevineCdmDisplayName; |
| + widevine_cdm.description = kWidevineCdmDescription + |
| + std::string(" (version: ") + |
| + WIDEVINE_CDM_VERSION_STRING + ")"; |
| + widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING; |
| + content::WebPluginMimeType widevine_cdm_mime_type( |
| + kWidevineCdmPluginMimeType, kWidevineCdmPluginExtension, |
| + kWidevineCdmPluginMimeTypeDescription); |
| + |
| + widevine_cdm_mime_type.additional_param_names.push_back( |
| + base::ASCIIToUTF16(kCdmSupportedCodecsParamName)); |
| + widevine_cdm_mime_type.additional_param_values.push_back(base::ASCIIToUTF16( |
| + base::JoinString(codecs_supported, |
| + std::string(1, kCdmSupportedCodecsValueDelimiter)))); |
| + |
| + widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); |
| + widevine_cdm.permissions = kWidevineCdmPluginPermissions; |
| + plugins->push_back(widevine_cdm); |
| } |
| #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && |
| // !defined(WIDEVINE_CDM_IS_COMPONENT) |
| @@ -520,6 +532,32 @@ void ChromeContentClient::AddPepperPlugins( |
| #endif // defined(ENABLE_PLUGINS) |
| } |
| +void ChromeContentClient::AddContentDecryptionModules( |
| + std::vector<content::CdmInfo>* modules) { |
| +// TODO(jrummell): Need to have a better flag to indicate systems Widevine |
| +// is available on. For now we continue to use ENABLE_PEPPER_CDMS so that |
| +// we can experiment between pepper and mojo. |
| +#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ |
| + !defined(WIDEVINE_CDM_IS_COMPONENT) |
| + base::FilePath widevine_adapter_path; |
| + std::vector<std::string> codecs_supported; |
| + if (IsWidevineAvailable(&widevine_adapter_path, &codecs_supported)) { |
| + // CdmInfo needs |path| to be the actual Widevine library, |
| + // not the adapter, so adjust as necessary. It will be in the |
| + // same directory as the installed adapter. |
|
xhwang
2016/04/13 00:22:12
We probably should have a new path for DIR_WIDEVIN
jrummell
2016/04/14 01:32:15
Done. I also moved it into IsWidevineAvailable() s
|
| + base::FilePath cdm_install_path = |
| + widevine_adapter_path.DirName().AppendASCII(kWidevineCdmFileName); |
| + base::Version version(WIDEVINE_CDM_VERSION_STRING); |
| + DCHECK(version.IsValid()); |
| + modules->push_back(content::CdmInfo(kWidevineCdmType, version, |
| + cdm_install_path, codecs_supported)); |
| + } |
| +#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && |
| + // !defined(WIDEVINE_CDM_IS_COMPONENT) |
| + |
| + // TODO(jrummell): Add External Clear Key CDM for testing, if it's available. |
| +} |
| + |
| #if defined(OS_CHROMEOS) |
| static const int kNumChromeStandardURLSchemes = 6; |
| #else |