summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorycheo@chromium.org <ycheo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-09 14:54:44 +0000
committerycheo@chromium.org <ycheo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-09 14:54:44 +0000
commit649b57279934b2bf99eda48e1b9dc40e6be169be (patch)
treee84d059cadd8de2226b1254813270cad5c15040c /chrome
parentfe7a12a3fe6a32fafe8aa01305fd965262d69755 (diff)
downloadchromium_src-649b57279934b2bf99eda48e1b9dc40e6be169be.zip
chromium_src-649b57279934b2bf99eda48e1b9dc40e6be169be.tar.gz
chromium_src-649b57279934b2bf99eda48e1b9dc40e6be169be.tar.bz2
Componentize EncryptedMediaMessageFilter and rename it CdmMessageFilter.
The motivation is to reuse the Widevine keysystem registration logic in Android Webview. BUG=322395 Review URL: https://codereview.chromium.org/253593002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269297 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/DEPS1
-rw-r--r--chrome/browser/chrome_content_browser_client.cc4
-rw-r--r--chrome/browser/media/encrypted_media_message_filter_android.cc115
-rw-r--r--chrome/browser/media/encrypted_media_message_filter_android.h43
-rw-r--r--chrome/chrome_browser.gypi3
-rw-r--r--chrome/chrome_common.gypi1
-rw-r--r--chrome/chrome_renderer.gypi1
-rw-r--r--chrome/common/common_message_generator.h4
-rw-r--r--chrome/common/encrypted_media_messages_android.h36
-rw-r--r--chrome/renderer/DEPS1
-rw-r--r--chrome/renderer/media/chrome_key_systems.cc124
11 files changed, 21 insertions, 312 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS
index 08683bf..dccea18 100644
--- a/chrome/browser/DEPS
+++ b/chrome/browser/DEPS
@@ -16,6 +16,7 @@ include_rules = [
"+components/bookmarks/core/common",
"+components/bookmarks/core/test",
"+components/breakpad",
+ "+components/cdm/browser",
"+components/cloud_devices/common",
"+components/data_reduction_proxy",
"+components/dom_distiller",
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index e9df65a..06b97e7 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -98,6 +98,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chromeos/chromeos_constants.h"
+#include "components/cdm/browser/cdm_message_filter_android.h"
#include "components/cloud_devices/common/cloud_devices_switches.h"
#include "components/nacl/browser/nacl_browser.h"
#include "components/nacl/browser/nacl_host_message_filter.h"
@@ -177,7 +178,6 @@
#include "chrome/browser/android/new_tab_page_url_handler.h"
#include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h"
#include "chrome/browser/chrome_browser_main_android.h"
-#include "chrome/browser/media/encrypted_media_message_filter_android.h"
#include "chrome/common/descriptors_android.h"
#include "components/breakpad/browser/crash_dump_manager_android.h"
#elif defined(OS_POSIX)
@@ -930,7 +930,7 @@ void ChromeContentBrowserClient::RenderProcessWillLaunch(
context));
#endif
#if defined(OS_ANDROID)
- host->AddFilter(new EncryptedMediaMessageFilterAndroid());
+ host->AddFilter(new cdm::CdmMessageFilterAndroid());
#endif
if (switches::IsNewProfileManagement())
host->AddFilter(new PrincipalsMessageFilter(id));
diff --git a/chrome/browser/media/encrypted_media_message_filter_android.cc b/chrome/browser/media/encrypted_media_message_filter_android.cc
deleted file mode 100644
index e16b0e9..0000000
--- a/chrome/browser/media/encrypted_media_message_filter_android.cc
+++ /dev/null
@@ -1,115 +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/browser/media/encrypted_media_message_filter_android.h"
-
-#include <string>
-
-#include "chrome/common/encrypted_media_messages_android.h"
-#include "ipc/ipc_message_macros.h"
-#include "media/base/android/media_codec_bridge.h"
-#include "media/base/android/media_drm_bridge.h"
-
-using content::BrowserThread;
-using content::SupportedCodecs;
-using media::MediaCodecBridge;
-using media::MediaDrmBridge;
-
-namespace chrome {
-
-const size_t kMaxKeySystemLength = 256;
-
-enum CodecType {
- CODEC_AUDIO,
- CODEC_VIDEO
-};
-
-struct CodecInfo {
- SupportedCodecs codec;
- CodecType codec_type;
- const char* codec_name;
- const char* container_mime_type;
-};
-
-const CodecInfo kCodecsToQuery[] = {
- {content::EME_CODEC_WEBM_VORBIS, CODEC_AUDIO, "vorbis", "video/webm"},
- {content::EME_CODEC_WEBM_VP8, CODEC_VIDEO, "vp8", "video/webm"},
- {content::EME_CODEC_WEBM_VP9, CODEC_VIDEO, "vp9", "video/webm"},
-#if defined(USE_PROPRIETARY_CODECS)
- {content::EME_CODEC_MP4_AAC, CODEC_AUDIO, "mp4a", "video/mp4"},
- {content::EME_CODEC_MP4_AVC1, CODEC_VIDEO, "avc1", "video/mp4"}
-#endif // defined(USE_PROPRIETARY_CODECS)
-};
-
-static SupportedCodecs GetSupportedCodecs(
- const SupportedKeySystemRequest& request,
- bool video_must_be_compositable) {
- const std::string& key_system = request.key_system;
- SupportedCodecs supported_codecs = content::EME_CODEC_NONE;
-
- for (size_t i = 0; i < arraysize(kCodecsToQuery); ++i) {
- const CodecInfo& info = kCodecsToQuery[i];
- // TODO(qinmin): Remove the composition logic when secure contents can be
- // composited.
- bool is_secure = (info.codec_type == CODEC_VIDEO)
- ? (!video_must_be_compositable) : false;
- if ((request.codecs & info.codec) &&
- MediaDrmBridge::IsKeySystemSupportedWithType(
- key_system, info.container_mime_type) &&
- MediaCodecBridge::CanDecode(info.codec_name, is_secure)) {
- supported_codecs |= info.codec;
- }
- }
-
- return supported_codecs;
-}
-
-EncryptedMediaMessageFilterAndroid::EncryptedMediaMessageFilterAndroid()
- : BrowserMessageFilter(EncryptedMediaMsgStart) {}
-
-EncryptedMediaMessageFilterAndroid::~EncryptedMediaMessageFilterAndroid() {}
-
-bool EncryptedMediaMessageFilterAndroid::OnMessageReceived(
- const IPC::Message& message, bool* message_was_ok) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_EX(
- EncryptedMediaMessageFilterAndroid, message, *message_was_ok)
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_GetSupportedKeySystems,
- OnGetSupportedKeySystems)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP_EX()
- return handled;
-}
-
-void EncryptedMediaMessageFilterAndroid::OverrideThreadForMessage(
- const IPC::Message& message, BrowserThread::ID* thread) {
- // Move the IPC handling to FILE thread as it is not very cheap.
- if (message.type() == ChromeViewHostMsg_GetSupportedKeySystems::ID)
- *thread = BrowserThread::FILE;
-}
-
-void EncryptedMediaMessageFilterAndroid::OnGetSupportedKeySystems(
- const SupportedKeySystemRequest& request,
- SupportedKeySystemResponse* response) {
- if (!response) {
- NOTREACHED() << "NULL response pointer provided.";
- return;
- }
-
- if (request.key_system.size() > kMaxKeySystemLength) {
- NOTREACHED() << "Invalid key system: " << request.key_system;
- return;
- }
-
- if (!MediaDrmBridge::IsKeySystemSupported(request.key_system))
- return;
-
- DCHECK(request.codecs & content::EME_CODEC_ALL) << "unrecognized codec";
- response->key_system = request.key_system;
- // TODO(qinmin): check composition is supported or not.
- response->compositing_codecs = GetSupportedCodecs(request, true);
- response->non_compositing_codecs = GetSupportedCodecs(request, false);
-}
-
-} // namespace chrome
diff --git a/chrome/browser/media/encrypted_media_message_filter_android.h b/chrome/browser/media/encrypted_media_message_filter_android.h
deleted file mode 100644
index 9d426ae..0000000
--- a/chrome/browser/media/encrypted_media_message_filter_android.h
+++ /dev/null
@@ -1,43 +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_BROWSER_MEDIA_ENCRYPTED_MEDIA_MESSAGE_FILTER_ANDROID_H_
-#define CHROME_BROWSER_MEDIA_ENCRYPTED_MEDIA_MESSAGE_FILTER_ANDROID_H_
-
-#include "base/basictypes.h"
-#include "content/public/browser/browser_message_filter.h"
-
-struct SupportedKeySystemRequest;
-struct SupportedKeySystemResponse;
-
-namespace chrome {
-
-// Message filter for EME on android. It is responsible for getting the
-// SupportedKeySystems information and passing it back to renderer.
-class EncryptedMediaMessageFilterAndroid
- : public content::BrowserMessageFilter {
- public:
- EncryptedMediaMessageFilterAndroid();
-
- private:
- virtual ~EncryptedMediaMessageFilterAndroid();
-
- // BrowserMessageFilter implementation.
- virtual bool OnMessageReceived(const IPC::Message& message,
- bool* message_was_ok) OVERRIDE;
- virtual void OverrideThreadForMessage(
- const IPC::Message& message,
- content::BrowserThread::ID* thread) OVERRIDE;
-
- // Retrieve the supported key systems.
- void OnGetSupportedKeySystems(
- const SupportedKeySystemRequest& request,
- SupportedKeySystemResponse* response);
-
- DISALLOW_COPY_AND_ASSIGN(EncryptedMediaMessageFilterAndroid);
-};
-
-} // namespace chrome
-
-#endif // CHROME_BROWSER_MEDIA_ENCRYPTED_MEDIA_MESSAGE_FILTER_ANDROID_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 92e76a3..d04f617 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1062,8 +1062,6 @@
'browser/media/desktop_media_picker.h',
'browser/media/desktop_streams_registry.cc',
'browser/media/desktop_streams_registry.h',
- 'browser/media/encrypted_media_message_filter_android.cc',
- 'browser/media/encrypted_media_message_filter_android.h',
'browser/media/media_capture_devices_dispatcher.cc',
'browser/media/media_capture_devices_dispatcher.h',
'browser/media/media_device_id_salt.cc',
@@ -3140,6 +3138,7 @@
}],
['OS=="android"', {
'dependencies': [
+ '../components/components.gyp:cdm_browser',
'../components/components.gyp:web_contents_delegate_android',
'chrome_browser_jni_headers',
],
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 57157b9..eab0246 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -111,7 +111,6 @@
'common/custom_handlers/protocol_handler.cc',
'common/custom_handlers/protocol_handler.h',
'common/descriptors_android.h',
- 'common/encrypted_media_messages_android.h',
'common/extensions/api/bluetooth/bluetooth_manifest_data.cc',
'common/extensions/api/bluetooth/bluetooth_manifest_data.h',
'common/extensions/api/bluetooth/bluetooth_manifest_handler.cc',
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index 98bd094..9d6ef22 100644
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -15,6 +15,7 @@
'chrome_resources.gyp:chrome_strings',
'../third_party/re2/re2.gyp:re2',
'../components/components.gyp:autofill_content_renderer',
+ '../components/components.gyp:cdm_renderer',
'../components/components.gyp:startup_metric_utils',
'../components/components.gyp:plugins_renderer',
'../components/components.gyp:translate_core_common',
diff --git a/chrome/common/common_message_generator.h b/chrome/common/common_message_generator.h
index 3fd05f6..462077e 100644
--- a/chrome/common/common_message_generator.h
+++ b/chrome/common/common_message_generator.h
@@ -27,7 +27,3 @@
#if defined(ENABLE_WEBRTC)
#include "chrome/common/media/webrtc_logging_messages.h"
#endif
-
-#if defined(OS_ANDROID)
-#include "chrome/common/encrypted_media_messages_android.h"
-#endif
diff --git a/chrome/common/encrypted_media_messages_android.h b/chrome/common/encrypted_media_messages_android.h
deleted file mode 100644
index 034fb3b..0000000
--- a/chrome/common/encrypted_media_messages_android.h
+++ /dev/null
@@ -1,36 +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.
-
-// IPC messages for EME on android.
-// Multiply-included message file, hence no include guard.
-
-#include <vector>
-
-#include "content/public/common/eme_codec.h"
-#include "ipc/ipc_message_macros.h"
-
-#define IPC_MESSAGE_START EncryptedMediaMsgStart
-
-IPC_STRUCT_BEGIN(SupportedKeySystemRequest)
- IPC_STRUCT_MEMBER(std::string, key_system)
- IPC_STRUCT_MEMBER(content::SupportedCodecs, codecs, content::EME_CODEC_NONE)
-IPC_STRUCT_END()
-
-IPC_STRUCT_BEGIN(SupportedKeySystemResponse)
- IPC_STRUCT_MEMBER(std::string, key_system)
- IPC_STRUCT_MEMBER(content::SupportedCodecs,
- compositing_codecs,
- content::EME_CODEC_NONE)
- IPC_STRUCT_MEMBER(content::SupportedCodecs,
- non_compositing_codecs,
- content::EME_CODEC_NONE)
-IPC_STRUCT_END()
-
-// Messages sent from the renderer to the browser.
-
-// Synchronously get a list of supported EME key systems.
-IPC_SYNC_MESSAGE_CONTROL1_1(
- ChromeViewHostMsg_GetSupportedKeySystems,
- SupportedKeySystemRequest /* key system information request */,
- SupportedKeySystemResponse /* key system information response */)
diff --git a/chrome/renderer/DEPS b/chrome/renderer/DEPS
index d65e9df..b607af8 100644
--- a/chrome/renderer/DEPS
+++ b/chrome/renderer/DEPS
@@ -3,6 +3,7 @@ include_rules = [
"+components/autofill/content/common",
"+components/autofill/content/renderer",
"+components/autofill/core/common",
+ "+components/cdm/renderer",
"+components/nacl/renderer",
"+components/plugins/renderer",
"+components/signin/core/common",
diff --git a/chrome/renderer/media/chrome_key_systems.cc b/chrome/renderer/media/chrome_key_systems.cc
index 71937fd..818d401 100644
--- a/chrome/renderer/media/chrome_key_systems.cc
+++ b/chrome/renderer/media/chrome_key_systems.cc
@@ -12,6 +12,7 @@
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/render_messages.h"
+#include "components/cdm/renderer/widevine_key_systems.h"
#include "content/public/renderer/render_thread.h"
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
@@ -23,10 +24,6 @@
#include "base/version.h"
#endif
-#if defined(OS_ANDROID)
-#include "chrome/common/encrypted_media_messages_android.h"
-#endif
-
using content::KeySystemInfo;
using content::SupportedCodecs;
@@ -99,76 +96,12 @@ static void AddExternalClearKey(
info.key_system = kExternalClearKeyCrashKeySystem;
concrete_key_systems->push_back(info);
}
-#endif // defined(ENABLE_PEPPER_CDMS)
-
#if defined(WIDEVINE_CDM_AVAILABLE)
-enum WidevineCdmType {
- WIDEVINE,
- WIDEVINE_HR,
-#if defined(OS_ANDROID)
- WIDEVINE_HR_NON_COMPOSITING,
-#endif
-};
-
-#if !defined(OS_ANDROID)
-static bool IsWidevineHrSupported() {
- // TODO(jrummell): Need to call CheckPlatformState() but it is
- // asynchronous, and needs to be done in the browser.
- return false;
-}
-#endif
-
-// Return |name|'s parent key system.
-static std::string GetDirectParentName(std::string name) {
- int last_period = name.find_last_of('.');
- DCHECK_GT(last_period, 0);
- return name.substr(0, last_period);
-}
-
-static void AddWidevineWithCodecs(
- WidevineCdmType widevine_cdm_type,
- SupportedCodecs supported_codecs,
- std::vector<KeySystemInfo>* concrete_key_systems) {
- KeySystemInfo info(kWidevineKeySystem);
-
- switch (widevine_cdm_type) {
- case WIDEVINE:
- // For standard Widevine, add parent name.
- info.parent_key_system = GetDirectParentName(kWidevineKeySystem);
- break;
- case WIDEVINE_HR:
- info.key_system.append(".hr");
- break;
-#if defined(OS_ANDROID)
- case WIDEVINE_HR_NON_COMPOSITING:
- info.key_system.append(".hrnoncompositing");
- break;
-#endif
- default:
- NOTREACHED();
- }
-
- // TODO(xhwang): A container or an initDataType may be supported even though
- // there are no codecs supported in that container. Fix this when we support
- // initDataType.
- info.supported_codecs = supported_codecs;
-
-#if defined(ENABLE_PEPPER_CDMS)
- info.pepper_type = kWidevineCdmPluginMimeType;
-#endif // defined(ENABLE_PEPPER_CDMS)
-
- concrete_key_systems->push_back(info);
-}
-
-#if defined(ENABLE_PEPPER_CDMS)
-// When the adapter is registered, a name-value pair is inserted in
-// additional_param_* that lists the supported codecs. The name is "codecs" and
-// the value is a comma-delimited list of codecs.
// This function finds "codecs" and parses the value into the vector |codecs|.
// Converts the codec strings to UTF-8 since we only expect ASCII strings and
// this simplifies the rest of the code in this file.
-void GetSupportedCodecs(
+void GetSupportedCodecsForPepperCdm(
const std::vector<base::string16>& additional_param_names,
const std::vector<base::string16>& additional_param_values,
std::vector<std::string>* codecs) {
@@ -212,7 +145,9 @@ static void AddPepperBasedWidevine(
}
std::vector<std::string> codecs;
- GetSupportedCodecs(additional_param_names, additional_param_values, &codecs);
+ GetSupportedCodecsForPepperCdm(additional_param_names,
+ additional_param_values,
+ &codecs);
SupportedCodecs supported_codecs = content::EME_CODEC_NONE;
for (size_t i = 0; i < codecs.size(); ++i) {
@@ -230,52 +165,23 @@ static void AddPepperBasedWidevine(
#endif // defined(USE_PROPRIETARY_CODECS)
}
- AddWidevineWithCodecs(WIDEVINE, supported_codecs, concrete_key_systems);
-
- if (IsWidevineHrSupported())
- AddWidevineWithCodecs(WIDEVINE_HR, supported_codecs, concrete_key_systems);
-}
-#elif defined(OS_ANDROID)
-static void AddAndroidWidevine(
- std::vector<KeySystemInfo>* concrete_key_systems) {
- SupportedKeySystemRequest request;
- SupportedKeySystemResponse response;
-
- request.key_system = kWidevineKeySystem;
- request.codecs = content::EME_CODEC_WEBM_ALL | content::EME_CODEC_MP4_ALL;
- content::RenderThread::Get()->Send(
- new ChromeViewHostMsg_GetSupportedKeySystems(request, &response));
- DCHECK(response.compositing_codecs & content::EME_CODEC_ALL)
- << "unrecognized codec";
- DCHECK(response.non_compositing_codecs & content::EME_CODEC_ALL)
- << "unrecognized codec";
- if (response.compositing_codecs != content::EME_CODEC_NONE) {
- AddWidevineWithCodecs(
- WIDEVINE,
- static_cast<SupportedCodecs>(response.compositing_codecs),
- concrete_key_systems);
- }
-
- if (response.non_compositing_codecs != content::EME_CODEC_NONE) {
- AddWidevineWithCodecs(
- WIDEVINE_HR_NON_COMPOSITING,
- static_cast<SupportedCodecs>(response.non_compositing_codecs),
- concrete_key_systems);
- }
+ cdm::AddWidevineWithCodecs(cdm::WIDEVINE,
+ supported_codecs,
+ concrete_key_systems);
}
-#endif // defined(ENABLE_PEPPER_CDMS)
#endif // defined(WIDEVINE_CDM_AVAILABLE)
+#endif // defined(ENABLE_PEPPER_CDMS)
void AddChromeKeySystems(std::vector<KeySystemInfo>* key_systems_info) {
#if defined(ENABLE_PEPPER_CDMS)
AddExternalClearKey(key_systems_info);
-#endif
#if defined(WIDEVINE_CDM_AVAILABLE)
-#if defined(ENABLE_PEPPER_CDMS)
AddPepperBasedWidevine(key_systems_info);
-#elif defined(OS_ANDROID)
- AddAndroidWidevine(key_systems_info);
-#endif
-#endif
+#endif // defined(WIDEVINE_CDM_AVAILABLE)
+#endif // defined(ENABLE_PEPPER_CDMS)
+
+#if defined(OS_ANDROID)
+ cdm::AddAndroidWidevine(key_systems_info);
+#endif // defined(OS_ANDROID)
}