Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5109)

Unified Diff: chrome/common/chrome_content_client.cc

Issue 1637083002: Add CdmService to keep track of CDMs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ContentDecryptionModule Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/chrome_content_client.cc
diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc
index f79b0197614d290f6228a6555cced92518462408..41483c5b5275b6c11dba9fe0e0641595de7e29e6 100644
--- a/chrome/common/chrome_content_client.cc
+++ b/chrome/common/chrome_content_client.cc
@@ -32,6 +32,7 @@
#include "components/dom_distiller/core/url_constants.h"
#include "components/version_info/version_info.h"
#include "content/public/common/content_constants.h"
+#include "content/public/common/content_decryption_module_registration.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/user_agent.h"
@@ -98,6 +99,35 @@ content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module;
content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module;
#endif
+#if defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT)
+static bool IsWidevineAvailable(
+ base::FilePath* cdm_adapter_path,
+ std::vector<base::string16>* codecs_supported,
+ std::vector<base::string16>* supported_init_data_types) {
+ 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(base::ASCIIToUTF16(kCdmSupportedCodecVp8));
+ codecs_supported->push_back(base::ASCIIToUTF16(kCdmSupportedCodecVp9));
+#if defined(USE_PROPRIETARY_CODECS)
+ codecs_supported->push_back(base::ASCIIToUTF16(kCdmSupportedCodecAvc1));
+#endif // defined(USE_PROPRIETARY_CODECS)
+
+ // TODO(crbug.com/469202). Add support for initDataTypes in the component
+ // manifest, and then duplicate the settings here.
+ return true;
+ }
+ }
+
+ return false;
+}
+#endif // defined(WIDEVINE_CDM_AVAILABLE) &&
+ // !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 +185,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;
- }
+ std::vector<base::string16> codecs_supported;
+ std::vector<base::string16> supported_init_data_types;
+ if (IsWidevineAvailable(&path, &codecs_supported,
+ &supported_init_data_types)) {
+ 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::JoinString(
+ codecs_supported,
+ base::ASCIIToUTF16(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 +538,27 @@ void ChromeContentClient::AddPepperPlugins(
#endif // defined(ENABLE_PLUGINS)
}
+void ChromeContentClient::AddContentDecryptionModules(
+ std::vector<content::ContentDecryptionModuleRegistration>* modules) {
+#if defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT)
+ base::FilePath widevine_adapter_path;
+ std::vector<base::string16> codecs_supported;
+ std::vector<base::string16> supported_init_data_types;
+ if (IsWidevineAvailable(&widevine_adapter_path, &codecs_supported,
+ &supported_init_data_types)) {
+ // |key_systems| 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.
+ modules->push_back(content::ContentDecryptionModuleRegistration(
+ kWidevineKeySystem, WIDEVINE_CDM_VERSION_STRING,
+ widevine_adapter_path.DirName().AppendASCII(kWidevineCdmFileName),
+ codecs_supported, supported_init_data_types));
+ }
+#endif // defined(WIDEVINE_CDM_AVAILABLE) &&
+ // !defined(WIDEVINE_CDM_IS_COMPONENT)
+
+}
+
#if defined(OS_CHROMEOS)
static const int kNumChromeStandardURLSchemes = 6;
#else

Powered by Google App Engine
This is Rietveld 408576698