diff --git a/BUILD.gn b/BUILD.gn index 8182c64d1a..9cb8581adf 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1,12 +1,13 @@ -import("//build/config/locales.gni") -import("//tools/grit/repack.gni") -import("//tools/v8_context_snapshot/v8_context_snapshot.gni") import("build/asar.gni") import("build/npm.gni") -import("//pdf/features.gni") -import("//build/config/win/manifest.gni") import("electron_paks.gni") +import("//build/config/locales.gni") +import("//build/config/win/manifest.gni") +import("//pdf/features.gni") import("//third_party/ffmpeg/ffmpeg_options.gni") +import("//third_party/widevine/cdm/widevine.gni") +import("//tools/grit/repack.gni") +import("//tools/v8_context_snapshot/v8_context_snapshot.gni") if (is_mac) { import("//build/config/mac/rules.gni") @@ -186,14 +187,14 @@ asar("js2asar") { ] } if (enable_view_api) { - sources += [ + sources += [ "lib/browser/api/box-layout.js", "lib/browser/api/button.js", "lib/browser/api/label-button.js", "lib/browser/api/layout-manager.js", "lib/browser/api/text-field.js", - ] - } + ] + } outputs = [ "$root_out_dir/resources/electron.asar", ] @@ -224,7 +225,6 @@ static_library("electron_lib") { "//base", "//base:i18n", "//chrome/common:constants", - "//components/cdm/renderer", "//components/network_session_configurator/common", "//components/prefs", "//components/printing/common", @@ -247,6 +247,7 @@ static_library("electron_lib") { "//third_party/leveldatabase", "//third_party/libyuv", "//third_party/webrtc_overrides:init_webrtc", + "//third_party/widevine/cdm:headers", "//ui/events:dom_keycode_converter", "//ui/gl", "//ui/views", @@ -431,6 +432,18 @@ static_library("electron_lib") { if (enable_pepper_flash) { deps += [ "components/pepper_flash" ] } + + if (enable_widevine) { + sources += [ + "//chrome/common/widevine_cdm_constants.cc", + "//chrome/common/widevine_cdm_constants.h", + "//chrome/renderer/media/chrome_key_systems.cc", + "//chrome/renderer/media/chrome_key_systems.h", + "//chrome/renderer/media/chrome_key_systems_provider.cc", + "//chrome/renderer/media/chrome_key_systems_provider.h", + ] + deps += [ "//components/cdm/renderer" ] + } } electron_paks("packed_resources") { @@ -526,7 +539,10 @@ if (is_mac) { deps += [ ":electron_crashpad_helper" ] } info_plist = "atom/common/resources/mac/Info.plist" - extra_substitutions = [ "ATOM_BUNDLE_ID=$electron_mac_bundle_id.framework", "ELECTRON_VERSION=$electron_version" ] + extra_substitutions = [ + "ATOM_BUNDLE_ID=$electron_mac_bundle_id.framework", + "ELECTRON_VERSION=$electron_version", + ] include_dirs = [ "." ] sources = filenames_gypi.framework_sources diff --git a/atom/app/atom_content_client.cc b/atom/app/atom_content_client.cc index f17ae31370..0075c28981 100644 --- a/atom/app/atom_content_client.cc +++ b/atom/app/atom_content_client.cc @@ -22,10 +22,16 @@ #include "ppapi/shared_impl/ppapi_permissions.h" #include "ui/base/l10n/l10n_util.h" #include "url/url_constants.h" +// In SHARED_INTERMEDIATE_DIR. +#include "widevine_cdm_version.h" // NOLINT(build/include) -#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) +#if defined(WIDEVINE_CDM_AVAILABLE) +#include "base/native_library.h" +#include "base/strings/stringprintf.h" #include "chrome/common/widevine_cdm_constants.h" -#endif +#include "content/public/common/cdm_info.h" +#include "media/base/video_codecs.h" +#endif // defined(WIDEVINE_CDM_AVAILABLE) #if defined(ENABLE_PDF_VIEWER) #include "atom/common/atom_constants.h" @@ -36,6 +42,73 @@ namespace atom { namespace { +#if defined(WIDEVINE_CDM_AVAILABLE) +bool IsWidevineAvailable(base::FilePath* adapter_path, + base::FilePath* cdm_path, + std::vector* codecs_supported) { + static enum { + NOT_CHECKED, + FOUND, + NOT_FOUND, + } widevine_cdm_file_check = NOT_CHECKED; + + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + *adapter_path = command_line->GetSwitchValuePath(switches::kWidevineCdmPath); + if (!adapter_path->empty()) { + *cdm_path = adapter_path->DirName().AppendASCII( + base::GetNativeLibraryName(kWidevineCdmLibraryName)); + if (widevine_cdm_file_check == NOT_CHECKED) { + widevine_cdm_file_check = + (base::PathExists(*adapter_path) && base::PathExists(*cdm_path)) + ? FOUND + : NOT_FOUND; + } + if (widevine_cdm_file_check == FOUND) { + // 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(media::VideoCodec::kCodecVP8); + codecs_supported->push_back(media::VideoCodec::kCodecVP9); +#if BUILDFLAG(USE_PROPRIETARY_CODECS) + codecs_supported->push_back(media::VideoCodec::kCodecH264); +#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) + + return true; + } + } + + return false; +} + +void AddWidevineAdapterFromCommandLine( + base::CommandLine* command_line, + std::vector* plugins) { + base::FilePath adapter_path; + base::FilePath cdm_path; + std::vector video_codecs_supported; + if (IsWidevineAvailable(&adapter_path, &cdm_path, &video_codecs_supported)) { + auto cdm_version_string = + command_line->GetSwitchValueASCII(switches::kWidevineCdmVersion); + content::PepperPluginInfo info; + info.is_out_of_process = true; + info.path = adapter_path; + info.name = kWidevineCdmDisplayName; + info.description = + base::StringPrintf("%s (version: %s)", kWidevineCdmDescription, + cdm_version_string.c_str()); + info.version = cdm_version_string; + info.permissions = kWidevineCdmPluginPermissions; + + content::WebPluginMimeType mime_type(kWidevineCdmPluginMimeType, + kWidevineCdmPluginExtension, + kWidevineCdmPluginMimeTypeDescription); + info.mime_types.push_back(mime_type); + + plugins->push_back(info); + } +} +#endif // defined(WIDEVINE_CDM_AVAILABLE) + +#if defined(ENABLE_PEPPER_FLASH) content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, const std::string& version) { content::PepperPluginInfo plugin; @@ -75,29 +148,23 @@ content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, return plugin; } -#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) -content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path, - const std::string& version) { - 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: ") + version + ")"; - widevine_cdm.version = version; - content::WebPluginMimeType widevine_cdm_mime_type( - kWidevineCdmPluginMimeType, kWidevineCdmPluginExtension, - kWidevineCdmPluginMimeTypeDescription); +void AddPepperFlashFromCommandLine( + base::CommandLine* command_line, + std::vector* plugins) { + base::FilePath flash_path = + command_line->GetSwitchValuePath(switches::kPpapiFlashPath); + if (flash_path.empty()) + return; - widevine_cdm.mime_types.push_back(widevine_cdm_mime_type); - widevine_cdm.permissions = kWidevineCdmPluginPermissions; + auto flash_version = + command_line->GetSwitchValueASCII(switches::kPpapiFlashVersion); - return widevine_cdm; + plugins->push_back(CreatePepperFlashInfo(flash_path, flash_version)); } -#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) +#endif // defined(ENABLE_PEPPER_FLASH) -#if defined(ENABLE_PDF_VIEWER) void ComputeBuiltInPlugins(std::vector* plugins) { +#if defined(ENABLE_PDF_VIEWER) content::PepperPluginInfo pdf_info; pdf_info.is_internal = true; pdf_info.is_out_of_process = true; @@ -114,8 +181,8 @@ void ComputeBuiltInPlugins(std::vector* plugins) { chrome_pdf::PPP_ShutdownModule; pdf_info.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV; plugins->push_back(pdf_info); -} #endif // defined(ENABLE_PDF_VIEWER) +} void ConvertStringWithSeparatorToVector(std::vector* vec, const char* separator, @@ -129,42 +196,6 @@ void ConvertStringWithSeparatorToVector(std::vector* vec, } // namespace -void AddPepperFlashFromCommandLine( - std::vector* plugins) { - auto* command_line = base::CommandLine::ForCurrentProcess(); - base::FilePath flash_path = - command_line->GetSwitchValuePath(switches::kPpapiFlashPath); - if (flash_path.empty()) - return; - - auto flash_version = - command_line->GetSwitchValueASCII(switches::kPpapiFlashVersion); - - plugins->push_back(CreatePepperFlashInfo(flash_path, flash_version)); -} - -#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) -void AddWidevineCdmFromCommandLine( - std::vector* plugins) { - auto* command_line = base::CommandLine::ForCurrentProcess(); - base::FilePath widevine_cdm_path = - command_line->GetSwitchValuePath(switches::kWidevineCdmPath); - if (widevine_cdm_path.empty()) - return; - - if (!base::PathExists(widevine_cdm_path)) - return; - - auto widevine_cdm_version = - command_line->GetSwitchValueASCII(switches::kWidevineCdmVersion); - if (widevine_cdm_version.empty()) - return; - - plugins->push_back( - CreateWidevineCdmInfo(widevine_cdm_path, widevine_cdm_version)); -} -#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) - AtomContentClient::AtomContentClient() {} AtomContentClient::~AtomContentClient() {} @@ -200,45 +231,43 @@ void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) { void AtomContentClient::AddPepperPlugins( std::vector* plugins) { - AddPepperFlashFromCommandLine(plugins); -#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) - AddWidevineCdmFromCommandLine(plugins); -#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) -#if defined(ENABLE_PDF_VIEWER) + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); +#if defined(ENABLE_PEPPER_FLASH) + AddPepperFlashFromCommandLine(command_line, plugins); +#endif // defined(ENABLE_PEPPER_FLASH) +#if defined(WIDEVINE_CDM_AVAILABLE) + AddWidevineAdapterFromCommandLine(command_line, plugins); +#endif // defined(WIDEVINE_CDM_AVAILABLE) ComputeBuiltInPlugins(plugins); -#endif // defined(ENABLE_PDF_VIEWER) } void AtomContentClient::AddContentDecryptionModules( std::vector* cdms, std::vector* cdm_host_file_paths) { -#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) - auto command_line = base::CommandLine::ForCurrentProcess(); - base::FilePath widevine_cdm_path = - command_line->GetSwitchValuePath(switches::kWidevineCdmPath); - if (widevine_cdm_path.empty()) - return; + if (cdms) { +#if defined(WIDEVINE_CDM_AVAILABLE) + base::FilePath adapter_path; + base::FilePath cdm_path; + std::vector video_codecs_supported; + bool supports_persistent_license = false; + if (IsWidevineAvailable(&adapter_path, &cdm_path, + &video_codecs_supported)) { + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + auto cdm_version_string = + command_line->GetSwitchValueASCII(switches::kWidevineCdmVersion); + // 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(cdm_version_string); + DCHECK(version.IsValid()); - if (!base::PathExists(widevine_cdm_path)) - return; - - auto widevine_cdm_version = - command_line->GetSwitchValueASCII(switches::kWidevineCdmVersion); - if (widevine_cdm_version.empty()) - return; - - std::vector supported_video_codecs; - supported_video_codecs.push_back(media::VideoCodec::kCodecVP8); - supported_video_codecs.push_back(media::VideoCodec::kCodecVP9); -#if BUILDFLAG(USE_PROPRIETARY_CODECS) - supported_video_codecs.push_back(media::VideoCodec::kCodecH264); -#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) - content::CdmRegistry::GetInstance()->RegisterCdm( - content::CdmInfo(kWidevineCdmDisplayName, kWidevineCdmGuid, - base::Version(widevine_cdm_version), widevine_cdm_path, - kWidevineCdmFileSystemId, supported_video_codecs, false, - kWidevineKeySystem, false)); -#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS) + cdms->push_back(content::CdmInfo( + kWidevineCdmDisplayName, kWidevineCdmGuid, version, cdm_path, + kWidevineCdmFileSystemId, video_codecs_supported, + supports_persistent_license, kWidevineKeySystem, false)); + } +#endif // defined(WIDEVINE_CDM_AVAILABLE) + } } } // namespace atom diff --git a/atom/renderer/renderer_client_base.cc b/atom/renderer/renderer_client_base.cc index 19623f0c8d..1b434d598d 100644 --- a/atom/renderer/renderer_client_base.cc +++ b/atom/renderer/renderer_client_base.cc @@ -227,7 +227,11 @@ bool RendererClientBase::OverrideCreatePlugin( void RendererClientBase::AddSupportedKeySystems( std::vector>* key_systems) { - AddChromeKeySystems(key_systems); + key_systems_provider_.AddSupportedKeySystems(key_systems); +} + +bool RendererClientBase::IsKeySystemsUpdateNeeded() { + return key_systems_provider_.IsKeySystemsUpdateNeeded(); } v8::Local RendererClientBase::GetContext( diff --git a/atom/renderer/renderer_client_base.h b/atom/renderer/renderer_client_base.h index f04be0a0fb..ffad57a6f1 100644 --- a/atom/renderer/renderer_client_base.h +++ b/atom/renderer/renderer_client_base.h @@ -8,6 +8,7 @@ #include #include +#include "chrome/renderer/media/chrome_key_systems_provider.h" #include "content/public/renderer/content_renderer_client.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" @@ -49,9 +50,11 @@ class RendererClientBase : public content::ContentRendererClient { void AddSupportedKeySystems( std::vector>* key_systems) override; + bool IsKeySystemsUpdateNeeded() override; private: std::unique_ptr preferences_manager_; + ChromeKeySystemsProvider key_systems_provider_; bool isolated_world_; // An increasing ID used for indentifying an V8 context in this process. diff --git a/brightray/brightray.gyp b/brightray/brightray.gyp index 5b353f0a7a..667859ef95 100644 --- a/brightray/brightray.gyp +++ b/brightray/brightray.gyp @@ -123,11 +123,13 @@ '<(libchromiumcontent_dir)/libwebrtc_common.a', '<(libchromiumcontent_dir)/libinit_webrtc.a', '<(libchromiumcontent_dir)/libyuv.a', - '<(libchromiumcontent_dir)/librenderer.a', '<(libchromiumcontent_dir)/libsecurity_state.a', '<(libchromiumcontent_dir)/libviz_service.a', # services/device/wake_lock/power_save_blocker/ '<(libchromiumcontent_dir)/libpower_save_blocker.a', + # chrome/renderer/media/chrome_key_systems + '<(libchromiumcontent_dir)/libcdm_support.a', + '<(libchromiumcontent_dir)/librenderer.a', # Friends of libpdf.a: # On Linux we have to use "--whole-archive" to include # all symbols, otherwise there will be plenty of @@ -223,6 +225,8 @@ '<(libchromiumcontent_dir)/libviz_service.a', # services/device/wake_lock/power_save_blocker/ '<(libchromiumcontent_dir)/libpower_save_blocker.a', + # chrome/renderer/media/chrome_key_systems + '<(libchromiumcontent_dir)/libcdm_support.a', # Friends of libpdf.a: '<(libchromiumcontent_dir)/libpdf.a', '<(libchromiumcontent_dir)/libppapi_cpp_objects.a', @@ -362,6 +366,8 @@ '<(libchromiumcontent_dir)/viz_service.lib', # services/device/wake_lock/power_save_blocker/ '<(libchromiumcontent_dir)/power_save_blocker.lib', + # chrome/renderer/media/chrome_key_systems + '<(libchromiumcontent_dir)/cdm_support.lib', # Friends of pdf.lib: '<(libchromiumcontent_dir)/pdf.lib', '<(libchromiumcontent_dir)/ppapi_cpp_objects.lib', diff --git a/build/args/all.gn b/build/args/all.gn index 8f27ad1130..1cdf17d4eb 100644 --- a/build/args/all.gn +++ b/build/args/all.gn @@ -7,5 +7,6 @@ v8_promise_internal_field_count = 1 v8_typed_array_max_size_in_heap = 0 enable_widevine = true +enable_cdm_host_verification = false proprietary_codecs = true ffmpeg_branding = "Chrome" diff --git a/chromium_src/chrome/common/widevine_cdm_constants.cc b/chromium_src/chrome/common/widevine_cdm_constants.cc deleted file mode 100644 index f59563c2cb..0000000000 --- a/chromium_src/chrome/common/widevine_cdm_constants.cc +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/common/widevine_cdm_constants.h" - -#include "build/build_config.h" -#include "ppapi/shared_impl/ppapi_permissions.h" - -const char kWidevineCdmPluginExtension[] = ""; - -const int32_t kWidevineCdmPluginPermissions = - ppapi::PERMISSION_DEV | ppapi::PERMISSION_PRIVATE; diff --git a/chromium_src/chrome/common/widevine_cdm_constants.h b/chromium_src/chrome/common/widevine_cdm_constants.h deleted file mode 100644 index ab0f71d7d0..0000000000 --- a/chromium_src/chrome/common/widevine_cdm_constants.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_COMMON_WIDEVINE_CDM_CONSTANTS_H_ -#define CHROME_COMMON_WIDEVINE_CDM_CONSTANTS_H_ - -#include "base/files/file_path.h" -#include "base/macros.h" -#include "third_party/widevine/cdm/widevine_cdm_common.h" - -extern const char kWidevineCdmPluginExtension[]; - -// Permission bits for Widevine CDM plugin. -extern const int32_t kWidevineCdmPluginPermissions; - -#endif // CHROME_COMMON_WIDEVINE_CDM_CONSTANTS_H_ diff --git a/chromium_src/chrome/renderer/media/chrome_key_systems.cc b/chromium_src/chrome/renderer/media/chrome_key_systems.cc deleted file mode 100644 index c4ab859f06..0000000000 --- a/chromium_src/chrome/renderer/media/chrome_key_systems.cc +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/renderer/media/chrome_key_systems.h" - -#include - -#include -#include - -#include "base/logging.h" -#include "base/strings/string16.h" -#include "base/strings/string_split.h" -#include "base/strings/utf_string_conversions.h" -#include "components/cdm/renderer/widevine_key_system_properties.h" -#include "content/public/renderer/render_thread.h" -#include "media/base/eme_constants.h" -#include "media/base/key_system_properties.h" -#include "media/media_features.h" - -#if BUILDFLAG(ENABLE_LIBRARY_CDMS) -#include "content/public/renderer/key_system_support.h" -#include "media/base/video_codecs.h" -#endif - -#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. - -// The following must be after widevine_cdm_version.h. - -#if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) -#include -#include "base/version.h" -#endif - -using media::KeySystemProperties; -using media::SupportedCodecs; - -#if BUILDFLAG(ENABLE_LIBRARY_CDMS) -static const char kExternalClearKeyPepperType[] = - "application/x-ppapi-clearkey-cdm"; - -// KeySystemProperties implementation for external Clear Key systems. -class ExternalClearKeyProperties : public KeySystemProperties { - public: - explicit ExternalClearKeyProperties(const std::string& key_system_name) - : key_system_name_(key_system_name) {} - - std::string GetKeySystemName() const override { return key_system_name_; } - bool IsSupportedInitDataType( - media::EmeInitDataType init_data_type) const override { - switch (init_data_type) { - case media::EmeInitDataType::WEBM: - case media::EmeInitDataType::KEYIDS: - return true; - - case media::EmeInitDataType::CENC: -#if BUILDFLAG(USE_PROPRIETARY_CODECS) - return true; -#else - return false; -#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) - - case media::EmeInitDataType::UNKNOWN: - return false; - } - NOTREACHED(); - return false; - } - - SupportedCodecs GetSupportedCodecs() const override { -#if BUILDFLAG(USE_PROPRIETARY_CODECS) - return media::EME_CODEC_MP4_ALL | media::EME_CODEC_WEBM_ALL; -#else - return media::EME_CODEC_WEBM_ALL; -#endif - } - - media::EmeConfigRule GetRobustnessConfigRule( - media::EmeMediaType media_type, - const std::string& requested_robustness) const override { - return requested_robustness.empty() ? media::EmeConfigRule::SUPPORTED - : media::EmeConfigRule::NOT_SUPPORTED; - } - - // Persistent license sessions are faked. - media::EmeSessionTypeSupport GetPersistentLicenseSessionSupport() - const override { - return media::EmeSessionTypeSupport::SUPPORTED; - } - - media::EmeSessionTypeSupport GetPersistentReleaseMessageSessionSupport() - const override { - return media::EmeSessionTypeSupport::NOT_SUPPORTED; - } - - media::EmeFeatureSupport GetPersistentStateSupport() const override { - return media::EmeFeatureSupport::REQUESTABLE; - } - - media::EmeFeatureSupport GetDistinctiveIdentifierSupport() const override { - return media::EmeFeatureSupport::NOT_SUPPORTED; - } - - std::string GetPepperType() const override { - return kExternalClearKeyPepperType; - } - - private: - const std::string key_system_name_; -}; - -// External Clear Key (used for testing). -static void AddExternalClearKey( - std::vector>* concrete_key_systems) { - static const char kExternalClearKeyKeySystem[] = - "org.chromium.externalclearkey"; - static const char kExternalClearKeyDecryptOnlyKeySystem[] = - "org.chromium.externalclearkey.decryptonly"; - static const char kExternalClearKeyFileIOTestKeySystem[] = - "org.chromium.externalclearkey.fileiotest"; - static const char kExternalClearKeyInitializeFailKeySystem[] = - "org.chromium.externalclearkey.initializefail"; - static const char kExternalClearKeyCrashKeySystem[] = - "org.chromium.externalclearkey.crash"; - - std::vector supported_video_codecs; - bool supports_persistent_license; - if (!content::IsKeySystemSupported(kExternalClearKeyKeySystem, - &supported_video_codecs, - &supports_persistent_license)) { - return; - } - - concrete_key_systems->emplace_back( - new ExternalClearKeyProperties(kExternalClearKeyKeySystem)); - - // Add support of decrypt-only mode in ClearKeyCdm. - concrete_key_systems->emplace_back( - new ExternalClearKeyProperties(kExternalClearKeyDecryptOnlyKeySystem)); - - // A key system that triggers FileIO test in ClearKeyCdm. - concrete_key_systems->emplace_back( - new ExternalClearKeyProperties(kExternalClearKeyFileIOTestKeySystem)); - - // A key system that Chrome thinks is supported by ClearKeyCdm, but actually - // will be refused by ClearKeyCdm. This is to test the CDM initialization - // failure case. - concrete_key_systems->emplace_back( - new ExternalClearKeyProperties(kExternalClearKeyInitializeFailKeySystem)); - - // A key system that triggers a crash in ClearKeyCdm. - concrete_key_systems->emplace_back( - new ExternalClearKeyProperties(kExternalClearKeyCrashKeySystem)); -} - -#if defined(WIDEVINE_CDM_AVAILABLE) -static void AddPepperBasedWidevine( - std::vector>* concrete_key_systems) { -#if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) - Version glibc_version(gnu_get_libc_version()); - DCHECK(glibc_version.IsValid()); - if (glibc_version < base::Version(WIDEVINE_CDM_MIN_GLIBC_VERSION)) - return; -#endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) - - std::vector supported_video_codecs; - bool supports_persistent_license = false; - if (!content::IsKeySystemSupported(kWidevineKeySystem, - &supported_video_codecs, - &supports_persistent_license)) { - DVLOG(1) << "Widevine CDM is not currently available."; - return; - } - - SupportedCodecs supported_codecs = media::EME_CODEC_NONE; - - // Audio codecs are always supported. - // TODO(sandersd): Distinguish these from those that are directly supported, - // as those may offer a higher level of protection. - supported_codecs |= media::EME_CODEC_WEBM_OPUS; - supported_codecs |= media::EME_CODEC_WEBM_VORBIS; -#if BUILDFLAG(USE_PROPRIETARY_CODECS) - supported_codecs |= media::EME_CODEC_MP4_AAC; -#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) - - // Video codecs are determined by what was registered for the CDM. - for (const auto& codec : supported_video_codecs) { - switch (codec) { - case media::VideoCodec::kCodecVP8: - supported_codecs |= media::EME_CODEC_WEBM_VP8; - break; - case media::VideoCodec::kCodecVP9: - supported_codecs |= media::EME_CODEC_WEBM_VP9; - supported_codecs |= media::EME_CODEC_COMMON_VP9; - break; -#if BUILDFLAG(USE_PROPRIETARY_CODECS) - case media::VideoCodec::kCodecH264: - supported_codecs |= media::EME_CODEC_MP4_AVC1; - break; -#endif // BUILDFLAG(USE_PROPRIETARY_CODECS) - default: - DVLOG(1) << "Unexpected supported codec: " << GetCodecName(codec); - break; - } - } - - using Robustness = cdm::WidevineKeySystemProperties::Robustness; - concrete_key_systems->emplace_back(new cdm::WidevineKeySystemProperties( - supported_codecs, -#if defined(OS_CHROMEOS) - media::EmeRobustness::HW_SECURE_ALL, // Maximum audio robustness. - media::EmeRobustness::HW_SECURE_ALL, // Maximim video robustness. - media::EmeSessionTypeSupport:: - SUPPORTED_WITH_IDENTIFIER, // Persistent-license. - media::EmeSessionTypeSupport:: - NOT_SUPPORTED, // Persistent-release-message. - media::EmeFeatureSupport::REQUESTABLE, // Persistent state. - media::EmeFeatureSupport::REQUESTABLE)); // Distinctive identifier. -#else // (Desktop) - Robustness::SW_SECURE_CRYPTO, // Maximum audio robustness. - Robustness::SW_SECURE_DECODE, // Maximum video robustness. - media::EmeSessionTypeSupport::NOT_SUPPORTED, // persistent-license. - media::EmeSessionTypeSupport:: - NOT_SUPPORTED, // persistent-release-message. - media::EmeFeatureSupport::REQUESTABLE, // Persistent state. - media::EmeFeatureSupport::NOT_SUPPORTED)); // Distinctive identifier. -#endif // defined(OS_CHROMEOS) -} -#endif // defined(WIDEVINE_CDM_AVAILABLE) -#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) - -void AddChromeKeySystems( - std::vector>* key_systems_properties) { -#if BUILDFLAG(ENABLE_LIBRARY_CDMS) - AddExternalClearKey(key_systems_properties); - -#if defined(WIDEVINE_CDM_AVAILABLE) - AddPepperBasedWidevine(key_systems_properties); -#endif // defined(WIDEVINE_CDM_AVAILABLE) -#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS) -} diff --git a/chromium_src/chrome/renderer/media/chrome_key_systems.h b/chromium_src/chrome/renderer/media/chrome_key_systems.h deleted file mode 100644 index 3e82ee70e2..0000000000 --- a/chromium_src/chrome/renderer/media/chrome_key_systems.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_RENDERER_MEDIA_CHROME_KEY_SYSTEMS_H_ -#define CHROME_RENDERER_MEDIA_CHROME_KEY_SYSTEMS_H_ - -#include -#include - -namespace media { -class KeySystemProperties; -} - -// Register the key systems supported by populating |key_systems_properties|. -void AddChromeKeySystems( - std::vector>* - key_systems_properties); - -#endif // CHROME_RENDERER_MEDIA_CHROME_KEY_SYSTEMS_H_ diff --git a/filenames.gypi b/filenames.gypi index a7563a699c..2b51e2040a 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -641,10 +641,6 @@ 'chromium_src/chrome/common/tts_messages.h', 'chromium_src/chrome/common/tts_utterance_request.cc', 'chromium_src/chrome/common/tts_utterance_request.h', - 'chromium_src/chrome/common/widevine_cdm_constants.cc', - 'chromium_src/chrome/common/widevine_cdm_constants.h', - 'chromium_src/chrome/renderer/media/chrome_key_systems.cc', - 'chromium_src/chrome/renderer/media/chrome_key_systems.h', 'chromium_src/chrome/renderer/printing/print_web_view_helper.cc', 'chromium_src/chrome/renderer/printing/print_web_view_helper_linux.cc', 'chromium_src/chrome/renderer/printing/print_web_view_helper_mac.mm',