diff options
-rw-r--r-- | chrome/browser/media/encrypted_media_istypesupported_browsertest.cc | 88 | ||||
-rw-r--r-- | chrome/browser/plugins/plugin_info_message_filter.cc | 22 | ||||
-rw-r--r-- | chrome/browser/plugins/plugin_info_message_filter.h | 6 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 8 | ||||
-rw-r--r-- | chrome/renderer/media/chrome_key_systems.cc | 112 | ||||
-rw-r--r-- | content/browser/plugin_service_impl.cc | 2 |
6 files changed, 187 insertions, 51 deletions
diff --git a/chrome/browser/media/encrypted_media_istypesupported_browsertest.cc b/chrome/browser/media/encrypted_media_istypesupported_browsertest.cc index 6685abb..c96d578 100644 --- a/chrome/browser/media/encrypted_media_istypesupported_browsertest.cc +++ b/chrome/browser/media/encrypted_media_istypesupported_browsertest.cc @@ -155,12 +155,13 @@ class EncryptedMediaIsTypeSupportedTest : public InProcessBrowserTest { // |pepper_type_for_key_system|. void RegisterPepperCdm(CommandLine* command_line, const std::string& adapter_name, - const std::string& pepper_type_for_key_system) { + const std::string& pepper_type_for_key_system, + bool expect_adapter_exists = true) { // Append the switch to register the appropriate adapter. base::FilePath plugin_dir; EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); base::FilePath plugin_lib = plugin_dir.AppendASCII(adapter_name); - EXPECT_TRUE(base::PathExists(plugin_lib)); + EXPECT_EQ(expect_adapter_exists, base::PathExists(plugin_lib)); base::FilePath::StringType pepper_plugin = plugin_lib.value(); pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;")); #if defined(OS_WIN) @@ -199,7 +200,7 @@ class EncryptedMediaIsTypeSupportedTest : public InProcessBrowserTest { browser()->tab_strip_model()->GetActiveWebContents(), command, &result)); - DCHECK(result == "success" || result == "NotSupportedError"); + CHECK(result == "success" || result == "NotSupportedError") << result; return (result == "success"); } @@ -296,8 +297,27 @@ class EncryptedMediaIsTypeSupportedWidevineTest const std::string pepper_name("application/x-ppapi-widevine-cdm"); RegisterPepperCdm(command_line, adapter_file_name, pepper_name); } -#endif // defined(ENABLE_PEPPER_CDMS) +#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) +}; + +#if defined(ENABLE_PEPPER_CDMS) +// Registers all possibly supported Pepper CDMs with the wrong path (filename). +class EncryptedMediaIsTypeSupportedPepperCDMRegisteredWithWrongPathTest + : public EncryptedMediaIsTypeSupportedTest { + protected: + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { + RegisterPepperCdm(command_line, + "clearkeycdmadapterwrongname.dll", + "application/x-ppapi-clearkey-cdm", + false); + RegisterPepperCdm(command_line, + "widevinecdmadapterwrongname.dll", + "application/x-ppapi-widevine-cdm", + false); + } }; +#endif // defined(ENABLE_PEPPER_CDMS) + IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest, ClearKey_Basic) { EXPECT_TRUE(IsConcreteSupportedKeySystem(kPrefixedClearKey)); @@ -471,6 +491,7 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest, // External Clear Key // +// When defined(ENABLE_PEPPER_CDMS), this also tests the Pepper CDM check. IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedExternalClearKeyTest, ExternalClearKey_Basic) { EXPECT_ECK(IsConcreteSupportedKeySystem(kExternalClearKey)); @@ -831,4 +852,63 @@ IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest, "audio/mp4", vorbis_codec(), kWidevineAlpha)); } +#if defined(ENABLE_PEPPER_CDMS) +// Since this test fixture does not register the CDMs on the command line, the +// check for the CDMs in chrome_key_systems.cc should fail, and they should not +// be registered with KeySystems. +IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest, + PepperCDMsNotRegistered) { + EXPECT_FALSE(IsConcreteSupportedKeySystem(kExternalClearKey)); + EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( + "video/webm", no_codecs(), kExternalClearKey)); + + // This will fail in all builds unless widevine is available but not a + // component, in which case it is registered internally +#if !defined(WIDEVINE_CDM_AVAILABLE) || defined(WIDEVINE_CDM_IS_COMPONENT) + EXPECT_FALSE(IsConcreteSupportedKeySystem(kWidevineAlpha)); + EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( + "video/webm", no_codecs(), kWidevineAlpha)); +#endif + + // Clear Key should still be registered. + EXPECT_TRUE(IsConcreteSupportedKeySystem(kPrefixedClearKey)); + EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( + "video/webm", no_codecs(), kPrefixedClearKey)); + + // Not yet out from behind the vendor prefix. + EXPECT_FALSE(IsConcreteSupportedKeySystem(kUnprefixedClearKey)); + EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( + "video/webm", no_codecs(), kUnprefixedClearKey)); +} + +// Since this test fixture does not register the CDMs on the command line, the +// check for the CDMs in chrome_key_systems.cc should fail, and they should not +// be registered with KeySystems. +IN_PROC_BROWSER_TEST_F( + EncryptedMediaIsTypeSupportedPepperCDMRegisteredWithWrongPathTest, + PepperCDMsRegisteredButAdapterNotPresent) { + EXPECT_FALSE(IsConcreteSupportedKeySystem(kExternalClearKey)); + EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( + "video/webm", no_codecs(), kExternalClearKey)); + + // This will fail in all builds unless widevine is available but not a + // component, in which case it is registered internally +#if !defined(WIDEVINE_CDM_AVAILABLE) || defined(WIDEVINE_CDM_IS_COMPONENT) + EXPECT_FALSE(IsConcreteSupportedKeySystem(kWidevineAlpha)); + EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( + "video/webm", no_codecs(), kWidevineAlpha)); +#endif + + // Clear Key should still be registered. + EXPECT_TRUE(IsConcreteSupportedKeySystem(kPrefixedClearKey)); + EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( + "video/webm", no_codecs(), kPrefixedClearKey)); + + // Not yet out from behind the vendor prefix. + EXPECT_FALSE(IsConcreteSupportedKeySystem(kUnprefixedClearKey)); + EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( + "video/webm", no_codecs(), kUnprefixedClearKey)); +} +#endif // defined(ENABLE_PEPPER_CDMS) + } // namespace chrome diff --git a/chrome/browser/plugins/plugin_info_message_filter.cc b/chrome/browser/plugins/plugin_info_message_filter.cc index f2260e4..9a15415 100644 --- a/chrome/browser/plugins/plugin_info_message_filter.cc +++ b/chrome/browser/plugins/plugin_info_message_filter.cc @@ -97,6 +97,9 @@ bool PluginInfoMessageFilter::OnMessageReceived(const IPC::Message& message, IPC_BEGIN_MESSAGE_MAP_EX(PluginInfoMessageFilter, message, *message_was_ok) IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_GetPluginInfo, OnGetPluginInfo) + IPC_MESSAGE_HANDLER( + ChromeViewHostMsg_IsInternalPluginRegisteredForMimeType, + OnIsInternalPluginRegisteredForMimeType) IPC_MESSAGE_UNHANDLED(return false) IPC_END_MESSAGE_MAP() return true; @@ -164,6 +167,25 @@ void PluginInfoMessageFilter::PluginsLoaded( Send(reply_msg); } +void PluginInfoMessageFilter::OnIsInternalPluginRegisteredForMimeType( + const std::string& mime_type, + bool* is_registered) { + std::vector<WebPluginInfo> plugins; + PluginService::GetInstance()->GetInternalPlugins(&plugins); + for (size_t i = 0; i < plugins.size(); ++i) { + const std::vector<content::WebPluginMimeType>& mime_types = + plugins[i].mime_types; + for (size_t j = 0; j < mime_types.size(); ++j) { + if (mime_types[j].mime_type == mime_type) { + *is_registered = true; + return; + } + } + } + + *is_registered = false; +} + void PluginInfoMessageFilter::Context::DecidePluginStatus( const GetPluginInfo_Params& params, const WebPluginInfo& plugin, diff --git a/chrome/browser/plugins/plugin_info_message_filter.h b/chrome/browser/plugins/plugin_info_message_filter.h index d57427e..21cd02c 100644 --- a/chrome/browser/plugins/plugin_info_message_filter.h +++ b/chrome/browser/plugins/plugin_info_message_filter.h @@ -98,6 +98,12 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter { IPC::Message* reply_msg, const std::vector<content::WebPluginInfo>& plugins); + // Returns whether any internal plugin supporting |mime_type| is registered. + // Does not determine whether the plugin can actually be instantiated + // (e.g. whether it is allowed or has all its dependencies). + void OnIsInternalPluginRegisteredForMimeType(const std::string& mime_type, + bool* is_registered); + Context context_; base::WeakPtrFactory<PluginInfoMessageFilter> weak_ptr_factory_; diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 90dab6f..f5d997d 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -503,6 +503,14 @@ IPC_SYNC_MESSAGE_CONTROL4_1(ChromeViewHostMsg_GetPluginInfo, std::string /* mime_type */, ChromeViewHostMsg_GetPluginInfo_Output /* output */) +// Returns whether any internal plugin supporting |mime_type| is registered +// Does not determine whether the plugin can actually be instantiated +// (e.g. whether it is allowed or has all its dependencies). +IPC_SYNC_MESSAGE_CONTROL1_1( + ChromeViewHostMsg_IsInternalPluginRegisteredForMimeType, + std::string /* mime_type */, + bool /* registered */) + #if defined(ENABLE_PLUGIN_INSTALLATION) // Tells the browser to search for a plug-in that can handle the given MIME // type. The result will be sent asynchronously to the routing ID diff --git a/chrome/renderer/media/chrome_key_systems.cc b/chrome/renderer/media/chrome_key_systems.cc index be7c4b1..e8b5058 100644 --- a/chrome/renderer/media/chrome_key_systems.cc +++ b/chrome/renderer/media/chrome_key_systems.cc @@ -5,6 +5,8 @@ #include "chrome/renderer/media/chrome_key_systems.h" #include "base/logging.h" +#include "chrome/common/render_messages.h" +#include "content/public/renderer/render_thread.h" #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. @@ -30,6 +32,58 @@ static const char kMp4a[] = "mp4a"; static const char kAvc1[] = "avc1"; static const char kMp4aAvc1[] = "mp4a,avc1"; +static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) { + KeySystemInfo info(kClearKeyKeySystem); + + info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); + info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); +#if defined(USE_PROPRIETARY_CODECS) + info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); + info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1)); +#endif // defined(USE_PROPRIETARY_CODECS) + + info.use_aes_decryptor = true; + + concrete_key_systems->push_back(info); +} + +#if defined(ENABLE_PEPPER_CDMS) +static bool IsPepperCdmRegistered(const std::string& pepper_type) { + bool is_registered = false; + content::RenderThread::Get()->Send( + new ChromeViewHostMsg_IsInternalPluginRegisteredForMimeType( + pepper_type, &is_registered)); + + return is_registered; +} + +// External Clear Key (used for testing). +static void AddExternalClearKey( + std::vector<KeySystemInfo>* concrete_key_systems) { + static const char kExternalClearKeyKeySystem[] = + "org.chromium.externalclearkey"; + static const char kExternalClearKeyPepperType[] = + "application/x-ppapi-clearkey-cdm"; + + if (!IsPepperCdmRegistered(kExternalClearKeyPepperType)) + return; + + KeySystemInfo info(kExternalClearKeyKeySystem); + + info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); + info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); +#if defined(USE_PROPRIETARY_CODECS) + info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); + info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1)); +#endif // defined(USE_PROPRIETARY_CODECS) + + info.pepper_type = kExternalClearKeyPepperType; + + concrete_key_systems->push_back(info); +} +#endif // defined(ENABLE_PEPPER_CDMS) + + #if defined(WIDEVINE_CDM_AVAILABLE) // Defines bitmask values used to specify supported codecs. // Each value represents a codec within a specific container. @@ -51,13 +105,6 @@ static void AddWidevineWithCodecs( 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; #endif -#if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) - Version glibc_version(gnu_get_libc_version()); - DCHECK(glibc_version.IsValid()); - if (glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION)) - return; -#endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) - KeySystemInfo info(kWidevineKeySystem); if (supported_codecs & WEBM_VP8_AND_VORBIS) { @@ -90,6 +137,18 @@ static void AddWidevineWithCodecs( // Supported types are determined at compile time. static void AddPepperBasedWidevine( std::vector<KeySystemInfo>* concrete_key_systems) { +#if defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) + Version glibc_version(gnu_get_libc_version()); + DCHECK(glibc_version.IsValid()); + if (glibc_version.IsOlderThan(WIDEVINE_CDM_MIN_GLIBC_VERSION)) + return; +#endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) + + if (!IsPepperCdmRegistered(kWidevineCdmPluginMimeType)) { + DVLOG(1) << "Widevine CDM is not currently available."; + return; + } + SupportedCodecs supported_codecs = WEBM_VP8_AND_VORBIS; #if defined(USE_PROPRIETARY_CODECS) @@ -115,45 +174,6 @@ static void AddAndroidWidevine( #endif // defined(ENABLE_PEPPER_CDMS) #endif // defined(WIDEVINE_CDM_AVAILABLE) -static void AddClearKey(std::vector<KeySystemInfo>* concrete_key_systems) { - KeySystemInfo info(kClearKeyKeySystem); - - info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); - info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); -#if defined(USE_PROPRIETARY_CODECS) - info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); - info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1)); -#endif // defined(USE_PROPRIETARY_CODECS) - - info.use_aes_decryptor = true; - - concrete_key_systems->push_back(info); -} - -#if defined(ENABLE_PEPPER_CDMS) -// External Clear Key (used for testing). -static void AddExternalClearKey( - std::vector<KeySystemInfo>* concrete_key_systems) { - static const char kExternalClearKeyKeySystem[] = - "org.chromium.externalclearkey"; - static const char kExternalClearKeyPepperType[] = - "application/x-ppapi-clearkey-cdm"; - - KeySystemInfo info(kExternalClearKeyKeySystem); - - info.supported_types.push_back(std::make_pair(kAudioWebM, kVorbis)); - info.supported_types.push_back(std::make_pair(kVideoWebM, kVorbisVP8)); -#if defined(USE_PROPRIETARY_CODECS) - info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a)); - info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1)); -#endif // defined(USE_PROPRIETARY_CODECS) - - info.pepper_type = kExternalClearKeyPepperType; - - concrete_key_systems->push_back(info); -} -#endif // defined(ENABLE_PEPPER_CDMS) - void AddChromeKeySystems(std::vector<KeySystemInfo>* key_systems_info) { AddClearKey(key_systems_info); diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc index 5a79f7d..8ffea2d 100644 --- a/content/browser/plugin_service_impl.cc +++ b/content/browser/plugin_service_impl.cc @@ -658,7 +658,7 @@ void PluginServiceImpl::RegisterPepperPlugins() { PepperPluginInfo* PluginServiceImpl::GetRegisteredPpapiPluginInfo( const base::FilePath& plugin_path) { PepperPluginInfo* info = NULL; - for (size_t i = 0; i < ppapi_plugins_.size(); i++) { + for (size_t i = 0; i < ppapi_plugins_.size(); ++i) { if (ppapi_plugins_[i].path == plugin_path) { info = &ppapi_plugins_[i]; break; |