diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/encryptedmedia')
8 files changed, 54 insertions, 77 deletions
diff --git a/chromium/third_party/blink/renderer/modules/encryptedmedia/DEPS b/chromium/third_party/blink/renderer/modules/encryptedmedia/DEPS index 85333ee093c..8673eb6b8ce 100644 --- a/chromium/third_party/blink/renderer/modules/encryptedmedia/DEPS +++ b/chromium/third_party/blink/renderer/modules/encryptedmedia/DEPS @@ -1,5 +1,6 @@ include_rules = [ "-third_party/blink/renderer/modules", + "+media/base/content_decryption_module.h", "+media/base/eme_constants.h", "+services/metrics/public/cpp/ukm_builders.h", "+services/metrics/public/cpp/ukm_recorder.h", diff --git a/chromium/third_party/blink/renderer/modules/encryptedmedia/idls.gni b/chromium/third_party/blink/renderer/modules/encryptedmedia/idls.gni deleted file mode 100644 index fa457ba6dec..00000000000 --- a/chromium/third_party/blink/renderer/modules/encryptedmedia/idls.gni +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2020 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. - -modules_idl_files = [ - "media_encrypted_event.idl", - "media_key_message_event.idl", - "media_key_session.idl", - "media_key_status_map.idl", - "media_key_system_access.idl", - "media_keys.idl", -] - -modules_dictionary_idl_files = [ - "media_encrypted_event_init.idl", - "media_key_message_event_init.idl", - "media_key_system_configuration.idl", - "media_key_system_media_capability.idl", - "media_keys_policy.idl", -] - -modules_dependency_idl_files = [ - "html_media_element_encrypted_media.idl", - "media_keys_get_status_for_policy.idl", - "navigator_request_media_key_system_access.idl", -] diff --git a/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_session.cc b/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_session.cc index 89cb7a68fc7..e7cdac56962 100644 --- a/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_session.cc +++ b/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_session.cc @@ -28,6 +28,7 @@ #include <cmath> #include <limits> +#include "media/base/content_decryption_module.h" #include "media/base/eme_constants.h" #include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/public/platform/web_content_decryption_module.h" @@ -55,6 +56,7 @@ #include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/instrumentation/instance_counters.h" #include "third_party/blink/renderer/platform/network/mime/content_type.h" +#include "third_party/blink/renderer/platform/runtime_enabled_features.h" #include "third_party/blink/renderer/platform/timer.h" #include "third_party/blink/renderer/platform/wtf/std_lib_extras.h" #include "third_party/blink/renderer/platform/wtf/text/ascii_ctype.h" @@ -107,6 +109,22 @@ static bool IsPersistentSessionType(WebEncryptedMediaSessionType session_type) { return false; } +V8MediaKeySessionClosedReason::Enum ConvertSessionClosedReason( + media::CdmSessionClosedReason reason) { + switch (reason) { + case media::CdmSessionClosedReason::kInternalError: + return V8MediaKeySessionClosedReason::Enum::kInternalError; + case media::CdmSessionClosedReason::kClose: + return V8MediaKeySessionClosedReason::Enum::kClosedByApplication; + case media::CdmSessionClosedReason::kReleaseAcknowledged: + return V8MediaKeySessionClosedReason::Enum::kReleaseAcknowledged; + case media::CdmSessionClosedReason::kHardwareContextReset: + return V8MediaKeySessionClosedReason::Enum::kHardwareContextReset; + case media::CdmSessionClosedReason::kResourceEvicted: + return V8MediaKeySessionClosedReason::Enum::kResourceEvicted; + } +} + static ScriptPromise CreateRejectedPromiseNotCallable( ExceptionState& exception_state) { exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError, @@ -846,7 +864,7 @@ void MediaKeySession::ActionTimerFired(TimerBase*) { } // Queue a task to fire a simple event named keymessage at the new object. -void MediaKeySession::OnSessionMessage(MessageType message_type, +void MediaKeySession::OnSessionMessage(media::CdmMessageType message_type, const unsigned char* message, size_t message_length) { DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << __func__ << "(" << this << ")"; @@ -864,20 +882,16 @@ void MediaKeySession::OnSessionMessage(MessageType message_type, MediaKeyMessageEventInit* init = MediaKeyMessageEventInit::Create(); switch (message_type) { - case WebContentDecryptionModuleSession::Client::MessageType:: - kLicenseRequest: + case media::CdmMessageType::LICENSE_REQUEST: init->setMessageType("license-request"); break; - case WebContentDecryptionModuleSession::Client::MessageType:: - kLicenseRenewal: + case media::CdmMessageType::LICENSE_RENEWAL: init->setMessageType("license-renewal"); break; - case WebContentDecryptionModuleSession::Client::MessageType:: - kLicenseRelease: + case media::CdmMessageType::LICENSE_RELEASE: init->setMessageType("license-release"); break; - case WebContentDecryptionModuleSession::Client::MessageType:: - kIndividualizationRequest: + case media::CdmMessageType::INDIVIDUALIZATION_REQUEST: init->setMessageType("individualization-request"); break; } @@ -890,7 +904,7 @@ void MediaKeySession::OnSessionMessage(MessageType message_type, async_event_queue_->EnqueueEvent(FROM_HERE, *event); } -void MediaKeySession::OnSessionClosed() { +void MediaKeySession::OnSessionClosed(media::CdmSessionClosedReason reason) { // Note that this is the event from the CDM when this session is actually // closed. The CDM can close a session at any time. Normally it would happen // as the result of a close() call, but also happens when update() has been @@ -916,7 +930,12 @@ void MediaKeySession::OnSessionClosed() { OnSessionExpirationUpdate(std::numeric_limits<double>::quiet_NaN()); // 7. Resolve promise. - closed_promise_->ResolveWithUndefined(); + if (RuntimeEnabledFeatures::EncryptedMediaSessionClosedReasonEnabled()) { + closed_promise_->Resolve( + V8MediaKeySessionClosedReason(ConvertSessionClosedReason(reason))); + } else { + closed_promise_->ResolveWithUndefined(); + } // Stop the CDM from firing any more events for this session. session_.reset(); diff --git a/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_session.h b/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_session.h index 192e4d43e4e..2dfa7d8347c 100644 --- a/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_session.h +++ b/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_session.h @@ -27,10 +27,13 @@ #define THIRD_PARTY_BLINK_RENDERER_MODULES_ENCRYPTEDMEDIA_MEDIA_KEY_SESSION_H_ #include <memory> + +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/platform/web_content_decryption_module_session.h" #include "third_party/blink/public/platform/web_encrypted_media_types.h" #include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_property.h" +#include "third_party/blink/renderer/bindings/modules/v8/v8_media_key_session_closed_reason.h" #include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h" #include "third_party/blink/renderer/core/typed_arrays/dom_array_piece.h" #include "third_party/blink/renderer/modules/encryptedmedia/media_key_status_map.h" @@ -40,6 +43,7 @@ namespace media { enum class EmeInitDataType; +enum class CdmSessionClosedReason; } namespace blink { @@ -130,10 +134,10 @@ class MediaKeySession final void RemoveTask(ContentDecryptionModuleResult*); // WebContentDecryptionModuleSession::Client - void OnSessionMessage(MessageType, + void OnSessionMessage(media::CdmMessageType message_type, const unsigned char* message, size_t message_length) override; - void OnSessionClosed() override; + void OnSessionClosed(media::CdmSessionClosedReason reason) override; void OnSessionExpirationUpdate(double updated_expiry_time_in_ms) override; void OnSessionKeysChange(const WebVector<WebEncryptedMediaKeyInformation>&, bool has_additional_usable_key) override; @@ -156,7 +160,10 @@ class MediaKeySession final bool is_closing_or_closed_; // Keep track of the closed promise. - typedef ScriptPromiseProperty<ToV8UndefinedGenerator, Member<DOMException>> + // absl::optional<> is needed because V8MediaKeySessionClosedReason's default + // constructor is private. + typedef ScriptPromiseProperty<absl::optional<V8MediaKeySessionClosedReason>, + Member<DOMException>> ClosedPromise; Member<ClosedPromise> closed_promise_; diff --git a/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_session.idl b/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_session.idl index 58481d00b49..adc751e92bb 100644 --- a/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_session.idl +++ b/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_session.idl @@ -25,6 +25,14 @@ // https://w3c.github.io/encrypted-media/#mediakeysession-interface +enum MediaKeySessionClosedReason { + "internal-error", + "closed-by-application", + "release-acknowledged", + "hardware-context-reset", + "resource-evicted" +}; + [ Exposed=Window, ActiveScriptWrappable, @@ -33,7 +41,10 @@ // session properties readonly attribute DOMString sessionId; readonly attribute unrestricted double expiration; - [CallWith=ScriptState] readonly attribute Promise<void> closed; + // When runtime feature EncryptedMediaSessionClosedReason is enabled, the + // promise is resolved with "MediaKeySessionClosedReason". Otherwise, it's + // resolved with "undefined". + [CallWith=ScriptState] readonly attribute Promise<MediaKeySessionClosedReason> closed; readonly attribute MediaKeyStatusMap keyStatuses; attribute EventHandler onkeystatuseschange; attribute EventHandler onmessage; diff --git a/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_status_map.cc b/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_status_map.cc index c982d02e9e4..cd284235e72 100644 --- a/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_status_map.cc +++ b/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_status_map.cc @@ -8,7 +8,6 @@ #include <limits> #include "third_party/blink/public/platform/web_data.h" -#include "third_party/blink/renderer/bindings/core/v8/array_buffer_or_array_buffer_view.h" #include "third_party/blink/renderer/bindings/core/v8/v8_union_arraybuffer_arraybufferview.h" #include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h" #include "third_party/blink/renderer/core/typed_arrays/dom_array_piece.h" @@ -66,21 +65,13 @@ class MediaKeyStatusMap::MapEntry final // Represents an Iterator that loops through the set of MapEntrys. class MapIterationSource final -#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) : public PairIterable<Member<V8BufferSource>, String>::IterationSource -#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) - : public PairIterable<ArrayBufferOrArrayBufferView, String>::IterationSource -#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) { public: MapIterationSource(MediaKeyStatusMap* map) : map_(map), current_(0) {} bool Next(ScriptState* script_state, -#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) Member<V8BufferSource>& key, -#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) - ArrayBufferOrArrayBufferView& key, -#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) String& value, ExceptionState&) override { // This simply advances an index and returns the next value if any, @@ -89,24 +80,15 @@ class MapIterationSource final return false; const auto& entry = map_->at(current_++); -#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) key = MakeGarbageCollected<V8BufferSource>(entry.KeyId()); -#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) - key.SetArrayBuffer(entry.KeyId()); -#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) value = entry.Status(); return true; } void Trace(Visitor* visitor) const override { visitor->Trace(map_); -#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) PairIterable<Member<V8BufferSource>, String>::IterationSource::Trace( visitor); -#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) - PairIterable<ArrayBufferOrArrayBufferView, String>::IterationSource::Trace( - visitor); -#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) } private: @@ -148,22 +130,14 @@ uint32_t MediaKeyStatusMap::IndexOf(const DOMArrayPiece& key) const { } bool MediaKeyStatusMap::has( -#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) const V8BufferSource* key_id -#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) - const ArrayBufferOrArrayBufferView& key_id -#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) ) { uint32_t index = IndexOf(key_id); return index < entries_.size(); } ScriptValue MediaKeyStatusMap::get(ScriptState* script_state, -#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) const V8BufferSource* key_id -#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) - const ArrayBufferOrArrayBufferView& key_id -#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) ) { uint32_t index = IndexOf(key_id); if (index >= entries_.size()) { diff --git a/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_status_map.h b/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_status_map.h index 6210c87d423..c9e152b795b 100644 --- a/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_status_map.h +++ b/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_status_map.h @@ -23,11 +23,7 @@ class WebData; // if the event loop runs. class MediaKeyStatusMap final : public ScriptWrappable, -#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) public PairIterable<Member<V8BufferSource>, String> -#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) - public PairIterable<ArrayBufferOrArrayBufferView, String> -#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) { DEFINE_WRAPPERTYPEINFO(); @@ -49,13 +45,8 @@ class MediaKeyStatusMap final // IDL attributes / methods uint32_t size() const { return entries_.size(); } -#if defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) bool has(const V8BufferSource* key_id); ScriptValue get(ScriptState*, const V8BufferSource* key_id); -#else // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) - bool has(const ArrayBufferOrArrayBufferView& key_id); - ScriptValue get(ScriptState*, const ArrayBufferOrArrayBufferView& key_id); -#endif // defined(USE_BLINK_V8_BINDING_NEW_IDL_UNION) void Trace(Visitor*) const override; diff --git a/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_system_media_capability.idl b/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_system_media_capability.idl index f475a843f5b..5d8c31f2a71 100644 --- a/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_system_media_capability.idl +++ b/chromium/third_party/blink/renderer/modules/encryptedmedia/media_key_system_media_capability.idl @@ -7,5 +7,5 @@ dictionary MediaKeySystemMediaCapability { DOMString contentType = ""; DOMString robustness = ""; - [RuntimeEnabled=EncryptedMediaEncryptionSchemeQuery] DOMString? encryptionScheme = null; + DOMString? encryptionScheme = null; }; |