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

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: Created 4 years, 11 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 a956d00c50fb119e58f3dfda3aaa367ce239bb12..4803bc6692c9d520d6daba35ae7b350439523072 100644
--- a/chrome/common/chrome_content_client.cc
+++ b/chrome/common/chrome_content_client.cc
@@ -33,6 +33,7 @@
#include "components/version_info/version_info.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
+#include "content/public/common/key_system_registration.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/user_agent.h"
#include "extensions/common/constants.h"
@@ -78,6 +79,28 @@
namespace {
+// File name of the External ClearKey CDM on different platforms.
+const base::FilePath::CharType kExternalClearKeyCdmFileName[] =
+#if defined(OS_MACOSX)
+ FILE_PATH_LITERAL("libclearkeycdm.dylib");
+#elif defined(OS_WIN)
+ FILE_PATH_LITERAL("clearkeycdm.dll");
+#else // OS_LINUX, etc.
+ FILE_PATH_LITERAL("libclearkeycdm.so");
+#endif
+
+// Key system name for External Clear Key (used for testing). The different
+// variations cause different behavior, but they all come from the same library.
+const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey";
+const char kExternalClearKeyDecryptOnlyKeySystem[] =
+ "org.chromium.externalclearkey.decryptonly";
+const char kExternalClearKeyFileIOTestKeySystem[] =
+ "org.chromium.externalclearkey.fileiotest";
+const char kExternalClearKeyInitializeFailKeySystem[] =
+ "org.chromium.externalclearkey.initializefail";
+const char kExternalClearKeyCrashKeySystem[] =
+ "org.chromium.externalclearkey.crash";
+
#if defined(ENABLE_PLUGINS)
#if defined(ENABLE_PDF)
const char kPDFPluginExtension[] = "pdf";
@@ -98,6 +121,34 @@ 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,
xhwang 2016/01/29 07:43:06 Probably we should move this function and the ECK
+ base::string16* 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.
+ std::vector<std::string> codecs;
+ codecs.push_back(kCdmSupportedCodecVorbis);
+ codecs.push_back(kCdmSupportedCodecVp8);
+ codecs.push_back(kCdmSupportedCodecVp9);
+#if defined(USE_PROPRIETARY_CODECS)
+ codecs.push_back(kCdmSupportedCodecAac);
+ codecs.push_back(kCdmSupportedCodecAvc1);
+#endif // defined(USE_PROPRIETARY_CODECS)
+ *codecs_supported = base::ASCIIToUTF16(base::JoinString(
+ codecs, std::string(1, kCdmSupportedCodecsValueDelimiter)));
+ 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,44 +206,27 @@ 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.
- std::vector<std::string> codecs;
- codecs.push_back(kCdmSupportedCodecVorbis);
- codecs.push_back(kCdmSupportedCodecVp8);
- codecs.push_back(kCdmSupportedCodecVp9);
-#if defined(USE_PROPRIETARY_CODECS)
- codecs.push_back(kCdmSupportedCodecAac);
- 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::string16 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(codecs_supported);
+
+ 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 +555,61 @@ void ChromeContentClient::AddPepperPlugins(
#endif // defined(ENABLE_PLUGINS)
}
+void ChromeContentClient::AddKeySystems(
+ std::vector<content::KeySystemRegistration>* key_systems) {
+#if defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT)
ddorwin 2016/01/26 20:21:53 This code will run on Android. Yes, we want to reg
+ base::FilePath widevine_adapter_path;
+ base::string16 codecs_supported;
+ if (IsWidevineAvailable(&widevine_adapter_path, &codecs_supported)) {
+ // |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.
+ key_systems->push_back(content::KeySystemRegistration(
+ kWidevineKeySystem,
+ widevine_adapter_path.DirName().AppendASCII(kWidevineCdmFileName),
+ codecs_supported));
+ }
+#endif // defined(WIDEVINE_CDM_AVAILABLE) &&
+ // !defined(WIDEVINE_CDM_IS_COMPONENT)
+
+ // External Clear Key is used for testing the interface to key systems.
xhwang 2016/01/29 07:43:06 This CL is getting large. It seems we can split th
jrummell 2016/03/04 01:19:40 Done.
+ base::FilePath clearkey_path;
+ static bool skip_clearkey_cdm_file_check = false;
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kEnableExternalClearKey)) {
+ if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &clearkey_path)) {
+ clearkey_path = clearkey_path.AppendASCII(kExternalClearKeyCdmFileName);
+ if (skip_clearkey_cdm_file_check || base::PathExists(clearkey_path)) {
+ skip_clearkey_cdm_file_check = true;
+
+ // External Clear Key supports all codecs.
+ std::vector<std::string> codecs_supported;
+ codecs_supported.push_back(kCdmSupportedCodecVorbis);
+ codecs_supported.push_back(kCdmSupportedCodecVp8);
+ codecs_supported.push_back(kCdmSupportedCodecVp9);
+#if defined(USE_PROPRIETARY_CODECS)
+ codecs_supported.push_back(kCdmSupportedCodecAac);
+ codecs_supported.push_back(kCdmSupportedCodecAvc1);
+#endif // defined(USE_PROPRIETARY_CODECS)
+ base::string16 codecs = base::ASCIIToUTF16(base::JoinString(
+ codecs_supported,
+ std::string(1, kCdmSupportedCodecsValueDelimiter)));
+
+ key_systems->push_back(content::KeySystemRegistration(
+ kExternalClearKeyKeySystem, clearkey_path, codecs));
+ key_systems->push_back(content::KeySystemRegistration(
+ kExternalClearKeyDecryptOnlyKeySystem, clearkey_path, codecs));
+ key_systems->push_back(content::KeySystemRegistration(
+ kExternalClearKeyFileIOTestKeySystem, clearkey_path, codecs));
+ key_systems->push_back(content::KeySystemRegistration(
+ kExternalClearKeyInitializeFailKeySystem, clearkey_path, codecs));
+ key_systems->push_back(content::KeySystemRegistration(
+ kExternalClearKeyCrashKeySystem, clearkey_path, codecs));
+ }
+ }
+ }
+}
+
#if defined(OS_CHROMEOS)
static const int kNumChromeStandardURLSchemes = 6;
#else

Powered by Google App Engine
This is Rietveld 408576698