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

Unified Diff: media/blink/webcontentdecryptionmodulesession_impl.cc

Issue 855773002: Pass keyschange event to blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase for blink changes Created 5 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
« no previous file with comments | « media/blink/webcontentdecryptionmodulesession_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webcontentdecryptionmodulesession_impl.cc
diff --git a/media/blink/webcontentdecryptionmodulesession_impl.cc b/media/blink/webcontentdecryptionmodulesession_impl.cc
index 348ae44f0ea4452aaffda1df448283b5ff2d4a94..05aecdfb0b508b9d48e056c1d1a9eeba0dcefc2f 100644
--- a/media/blink/webcontentdecryptionmodulesession_impl.cc
+++ b/media/blink/webcontentdecryptionmodulesession_impl.cc
@@ -10,13 +10,17 @@
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "media/base/cdm_key_information.h"
#include "media/base/cdm_promise.h"
#include "media/base/media_keys.h"
#include "media/blink/cdm_result_promise.h"
#include "media/blink/cdm_session_adapter.h"
#include "media/blink/new_session_cdm_result_promise.h"
+#include "third_party/WebKit/public/platform/WebData.h"
+#include "third_party/WebKit/public/platform/WebEncryptedMediaKeyInformation.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
+#include "third_party/WebKit/public/platform/WebVector.h"
namespace media {
@@ -48,6 +52,24 @@ convertMessageType(MediaKeys::MessageType message_type) {
LicenseRequest;
}
+static blink::WebEncryptedMediaKeyInformation::KeyStatus convertStatus(
+ media::CdmKeyInformation::KeyStatus status) {
+ switch (status) {
+ case media::CdmKeyInformation::USABLE:
+ return blink::WebEncryptedMediaKeyInformation::KeyStatus::Usable;
+ case media::CdmKeyInformation::INTERNAL_ERROR:
+ return blink::WebEncryptedMediaKeyInformation::KeyStatus::InternalError;
+ case media::CdmKeyInformation::EXPIRED:
+ return blink::WebEncryptedMediaKeyInformation::KeyStatus::Expired;
+ case media::CdmKeyInformation::OUTPUT_NOT_ALLOWED:
+ return blink::WebEncryptedMediaKeyInformation::KeyStatus::
+ OutputNotAllowed;
+ }
+
+ NOTREACHED();
+ return blink::WebEncryptedMediaKeyInformation::KeyStatus::InternalError;
+}
+
WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl(
const scoped_refptr<CdmSessionAdapter>& adapter)
: adapter_(adapter), is_closed_(false), weak_ptr_factory_(this) {
@@ -192,8 +214,20 @@ void WebContentDecryptionModuleSessionImpl::OnSessionMessage(
}
void WebContentDecryptionModuleSessionImpl::OnSessionKeysChange(
- bool has_additional_usable_key) {
- // TODO(jrummell): Update this once Blink client supports this.
+ bool has_additional_usable_key,
+ CdmKeysInfo keys_info) {
+ blink::WebVector<blink::WebEncryptedMediaKeyInformation> keys(
+ keys_info.size());
+ for (size_t i = 0; i < keys_info.size(); ++i) {
+ const auto& key_info = keys_info[i];
+ keys[i].setId(blink::WebData(reinterpret_cast<char*>(&key_info->key_id[0]),
+ key_info->key_id.size()));
+ keys[i].setStatus(convertStatus(key_info->status));
+ keys[i].setSystemCode(key_info->system_code);
+ }
+
+ // Now send the event to blink.
+ client_->keysStatusesChange(keys, has_additional_usable_key);
}
void WebContentDecryptionModuleSessionImpl::OnSessionExpirationUpdate(
« no previous file with comments | « media/blink/webcontentdecryptionmodulesession_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698