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 9854e9261278c37f957c650756f96adb80958ee6..55f5a2445f93a30a5a1138a0a888972de220be6f 100644 |
| --- a/chrome/common/chrome_content_client.cc |
| +++ b/chrome/common/chrome_content_client.cc |
| @@ -33,6 +33,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" |
| @@ -99,6 +100,36 @@ 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* adapter_path, |
|
Lei Zhang
2016/04/19 23:46:17
You don't need to decl functions static inside an
jrummell
2016/04/20 21:08:44
Done.
|
| + base::FilePath* cdm_path, |
| + std::vector<std::string>* codecs_supported) { |
| + static bool skip_widevine_cdm_file_check = false; |
|
Lei Zhang
2016/04/19 23:46:17
Questioning the original code - is the intention t
jrummell
2016/04/20 21:08:44
Back when this was added (https://chromiumcoderevi
|
| + // TODO(jrummell): We should add a new path for DIR_WIDEVINE_CDM and use that |
| + // to locate the CDM and the CDM adapter. |
| + if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, adapter_path)) { |
| + *cdm_path = adapter_path->DirName().AppendASCII(kWidevineCdmFileName); |
| + if (skip_widevine_cdm_file_check || |
| + (base::PathExists(*adapter_path) && base::PathExists(*cdm_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 |
| @@ -125,13 +156,12 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { |
| plugins->push_back(pdf_info); |
| #endif // defined(ENABLE_PDF) |
| - base::FilePath path; |
| - |
| #if !defined(DISABLE_NACL) |
| // Handle Native Client just like the PDF plugin. This means that it is |
| // enabled by default for the non-portable case. This allows apps installed |
| // from the Chrome Web Store to use NaCl even if the command line switch |
| // isn't set. For other uses of NaCl we check for the command line switch. |
| + base::FilePath path; |
| if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) { |
| content::PepperPluginInfo nacl; |
| // The nacl plugin is now built into the Chromium binary. |
| @@ -156,43 +186,31 @@ 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; |
| - } |
| + base::FilePath adapter_path; |
| + base::FilePath cdm_path; |
| + std::vector<std::string> codecs_supported; |
| + if (IsWidevineAvailable(&adapter_path, &cdm_path, &codecs_supported)) { |
| + content::PepperPluginInfo widevine_cdm; |
| + widevine_cdm.is_out_of_process = true; |
| + widevine_cdm.path = adapter_path; |
| + widevine_cdm.name = kWidevineCdmDisplayName; |
| + widevine_cdm.description = |
| + base::StringPrintf("%s (version: " WIDEVINE_CDM_VERSION_STRING ")", |
| + kWidevineCdmDescription); |
| + 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) |
| @@ -521,6 +539,31 @@ void ChromeContentClient::AddPepperPlugins( |
| #endif // defined(ENABLE_PLUGINS) |
| } |
| +void ChromeContentClient::AddContentDecryptionModules( |
| + std::vector<content::CdmInfo>* cdms) { |
| +// 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 adapter_path; |
| + base::FilePath cdm_path; |
| + std::vector<std::string> codecs_supported; |
| + if (IsWidevineAvailable(&adapter_path, &cdm_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. |
| + const base::Version version(WIDEVINE_CDM_VERSION_STRING); |
| + DCHECK(version.IsValid()); |
| + cdms->push_back(content::CdmInfo(kWidevineCdmType, version, cdm_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 |