Add Widevine CDM support (issue #1631)

- Windows/Mac: Use `--enable-widevine-cdm` command-line flag to
  enable download of CDM binaries via the component updater.
- Linux: Use `--widevide-cdm-path` and `--widevine-cdm-version`
  command-line flags to load CDM binaries that already exist on
  the system.
- A cache-path value is usually required when CDM is enabled.
This commit is contained in:
Marshall Greenblatt
2015-08-31 13:28:07 +02:00
parent 4a8546efd7
commit 3640f81f01
23 changed files with 1002 additions and 2 deletions

View File

@@ -230,6 +230,20 @@ IPC_SYNC_MESSAGE_CONTROL4_1(CefViewHostMsg_GetPluginInfo,
std::string /* mime_type */,
CefViewHostMsg_GetPluginInfo_Output /* output */)
// Returns whether any internal plugin supporting |mime_type| is registered and
// enabled. Does not determine whether the plugin can actually be instantiated
// (e.g. whether it has all its dependencies).
// When the returned *|is_available| is true, |additional_param_names| and
// |additional_param_values| contain the name-value pairs, if any, specified
// for the *first* non-disabled plugin found that is registered for |mime_type|.
// Based on ChromeViewHostMsg_IsInternalPluginAvailableForMimeType.
IPC_SYNC_MESSAGE_CONTROL1_3(
CefViewHostMsg_IsInternalPluginAvailableForMimeType,
std::string /* mime_type */,
bool /* is_available */,
std::vector<base::string16> /* additional_param_names */,
std::vector<base::string16> /* additional_param_values */)
// Sent when a frame is identified for the first time.
IPC_MESSAGE_ROUTED3(CefHostMsg_FrameIdentified,
int64 /* frame_id */,

View File

@@ -107,4 +107,13 @@ const char kDisablePdfExtension[] = "disable-pdf-extension";
// upcoming version of Chromium.
const char kEnableNPAPI[] = "enable-npapi";
// Enable Widevine CDM.
const char kEnableWidevineCdm[] = "enable-widevine-cdm";
// Path to Widevine CDM binaries.
const char kWidevineCdmPath[] = "widevine-cdm-path";
// Widevine CDM version.
const char kWidevineCdmVersion[] = "widevine-cdm-version";
} // namespace switches

View File

@@ -45,6 +45,9 @@ extern const char kEnableSystemFlash[];
extern const char kDisableScrollBounce[];
extern const char kDisablePdfExtension[];
extern const char kEnableNPAPI[];
extern const char kEnableWidevineCdm[];
extern const char kWidevineCdmPath[];
extern const char kWidevineCdmVersion[];
} // namespace switches

View File

@@ -34,6 +34,14 @@
#include "ppapi/shared_impl/ppapi_permissions.h"
#include "ui/base/resource/resource_bundle.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
// The following must be after widevine_cdm_version.h.
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
!defined(WIDEVINE_CDM_IS_COMPONENT)
#include "chrome/common/widevine_cdm_constants.h"
#endif
namespace {
CefContentClient* g_content_client = NULL;
@@ -171,6 +179,68 @@ bool GetSystemPepperFlash(content::PepperPluginInfo* plugin) {
return true;
}
void AddWidevineCdmFromCommandLine(
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;
base::FilePath widevine_cdm_path =
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
switches::kWidevineCdmPath);
if (!widevine_cdm_path.empty()) {
widevine_cdm_path =
widevine_cdm_path.AppendASCII(kWidevineCdmAdapterFileName);
}
// Also get the version from the command-line. Should be something like
// 1.4.8.824.
const std::string& widevine_cdm_version =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kWidevineCdmVersion);
if (!widevine_cdm_path.empty() && !widevine_cdm_version.empty()) {
if (skip_widevine_cdm_file_check || base::PathExists(widevine_cdm_path)) {
content::PepperPluginInfo widevine_cdm;
widevine_cdm.is_out_of_process = true;
widevine_cdm.path = widevine_cdm_path;
widevine_cdm.name = kWidevineCdmDisplayName;
widevine_cdm.description = kWidevineCdmDescription +
std::string(" (version: ") +
widevine_cdm_version + ")";
widevine_cdm.version = widevine_cdm_version;
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;
}
}
#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
// !defined(WIDEVINE_CDM_IS_COMPONENT)
}
} // namespace
const char CefContentClient::kPDFPluginPath[] = "internal-pdf-viewer";
@@ -197,6 +267,7 @@ void CefContentClient::AddPepperPlugins(
std::vector<content::PepperPluginInfo>* plugins) {
ComputeBuiltInPlugins(plugins);
AddPepperFlashFromCommandLine(plugins);
AddWidevineCdmFromCommandLine(plugins);
content::PepperPluginInfo plugin;
if (GetSystemPepperFlash(&plugin))

View File

@@ -26,6 +26,7 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/widevine_cdm_constants.h"
#include "content/public/browser/browser_main_runner.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h"
@@ -36,6 +37,8 @@
#include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
#if defined(IPC_MESSAGE_LOG_ENABLED)
@@ -525,6 +528,18 @@ void CefMainDelegate::PreSandboxStartup() {
user_data_path.AppendASCII("Dictionaries"),
false, // May not be an absolute path.
true); // Create if necessary.
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
const base::FilePath& widevine_plugin_path = GetResourcesFilePath();
PathService::Override(chrome::FILE_WIDEVINE_CDM_ADAPTER,
widevine_plugin_path.AppendASCII(
kWidevineCdmAdapterFileName));
#if defined(WIDEVINE_CDM_IS_COMPONENT)
PathService::Override(chrome::DIR_COMPONENT_WIDEVINE_CDM,
user_data_path.Append(kWidevineCdmBaseDirectory));
#endif // defined(WIDEVINE_CDM_IS_COMPONENT)
#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
}
if (command_line->HasSwitch(switches::kDisablePackLoading))