Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webcontentdecryptionmodulesession_impl.h" | 5 #include "webcontentdecryptionmodulesession_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "media/base/cdm_key_information.h" | 13 #include "media/base/cdm_key_information.h" |
| 14 #include "media/base/cdm_promise.h" | 14 #include "media/base/cdm_promise.h" |
| 15 #include "media/base/key_systems.h" | |
| 15 #include "media/base/media_keys.h" | 16 #include "media/base/media_keys.h" |
| 16 #include "media/blink/cdm_result_promise.h" | 17 #include "media/blink/cdm_result_promise.h" |
| 17 #include "media/blink/cdm_session_adapter.h" | 18 #include "media/blink/cdm_session_adapter.h" |
| 18 #include "media/blink/new_session_cdm_result_promise.h" | 19 #include "media/blink/new_session_cdm_result_promise.h" |
| 19 #include "third_party/WebKit/public/platform/WebData.h" | 20 #include "third_party/WebKit/public/platform/WebData.h" |
| 20 #include "third_party/WebKit/public/platform/WebEncryptedMediaKeyInformation.h" | 21 #include "third_party/WebKit/public/platform/WebEncryptedMediaKeyInformation.h" |
| 21 #include "third_party/WebKit/public/platform/WebString.h" | 22 #include "third_party/WebKit/public/platform/WebString.h" |
| 22 #include "third_party/WebKit/public/platform/WebURL.h" | 23 #include "third_party/WebKit/public/platform/WebURL.h" |
| 23 #include "third_party/WebKit/public/platform/WebVector.h" | 24 #include "third_party/WebKit/public/platform/WebVector.h" |
| 24 | 25 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 } | 90 } |
| 90 | 91 |
| 91 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { | 92 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { |
| 92 return blink::WebString::fromUTF8(session_id_); | 93 return blink::WebString::fromUTF8(session_id_); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void WebContentDecryptionModuleSessionImpl::initializeNewSession( | 96 void WebContentDecryptionModuleSessionImpl::initializeNewSession( |
| 96 const blink::WebString& init_data_type, | 97 const blink::WebString& init_data_type, |
| 97 const uint8* init_data, | 98 const uint8* init_data, |
| 98 size_t init_data_length) { | 99 size_t init_data_length) { |
| 99 // TODO(jrummell): Remove once blink updated. | 100 // TODO(jrummell): Remove once blink updated. |
|
ddorwin
2015/02/04 23:42:23
Done? Ditto for two below.
jrummell
2015/02/05 01:01:28
I was going to do some cleanups in a separate CL.
| |
| 100 NOTREACHED(); | 101 NOTREACHED(); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void WebContentDecryptionModuleSessionImpl::update(const uint8* response, | 104 void WebContentDecryptionModuleSessionImpl::update(const uint8* response, |
| 104 size_t response_length) { | 105 size_t response_length) { |
| 105 // TODO(jrummell): Remove once blink updated. | 106 // TODO(jrummell): Remove once blink updated. |
| 106 NOTREACHED(); | 107 NOTREACHED(); |
| 107 } | 108 } |
| 108 | 109 |
| 109 void WebContentDecryptionModuleSessionImpl::release() { | 110 void WebContentDecryptionModuleSessionImpl::release() { |
| 110 // TODO(jrummell): Remove once blink updated. | 111 // TODO(jrummell): Remove once blink updated. |
| 111 NOTREACHED(); | 112 NOTREACHED(); |
| 112 } | 113 } |
| 113 | 114 |
| 114 void WebContentDecryptionModuleSessionImpl::initializeNewSession( | 115 void WebContentDecryptionModuleSessionImpl::initializeNewSession( |
| 115 const blink::WebString& init_data_type, | 116 const blink::WebString& init_data_type, |
| 116 const uint8* init_data, | 117 const uint8* init_data, |
| 117 size_t init_data_length, | 118 size_t init_data_length, |
| 118 const blink::WebString& session_type, | 119 const blink::WebString& session_type, |
| 119 blink::WebContentDecryptionModuleResult result) { | 120 blink::WebContentDecryptionModuleResult result) { |
| 120 DCHECK(session_id_.empty()); | 121 DCHECK(session_id_.empty()); |
| 121 | 122 |
| 122 // TODO(ddorwin): Guard against this in supported types check and remove this. | 123 // TODO(ddorwin): Guard against this in supported types check and remove this. |
| 123 // Chromium only supports ASCII MIME types. | 124 // Chromium only supports ASCII MIME types. |
| 124 if (!base::IsStringASCII(init_data_type)) { | 125 if (!base::IsStringASCII(init_data_type)) { |
| 125 NOTREACHED(); | 126 NOTREACHED(); |
|
ddorwin
2015/02/04 23:42:23
Do we have LTs that test non-ascii handling?
I th
jrummell
2015/02/05 01:01:28
No LTs since we typically don't mess with InitData
ddorwin
2015/02/05 01:09:31
SG, but what is the plan to avoid hitting the NOTR
jrummell
2015/02/05 20:42:14
Where step 5 is on the blink side I may need to ch
| |
| 126 std::string message = "The initialization data type " + | 127 std::string message = "The initialization data type " + |
| 127 init_data_type.utf8() + | 128 init_data_type.utf8() + |
| 128 " is not supported by the key system."; | 129 " is not supported by the key system."; |
| 129 result.completeWithError( | 130 result.completeWithError( |
| 130 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, | 131 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, |
| 131 blink::WebString::fromUTF8(message)); | 132 blink::WebString::fromUTF8(message)); |
| 132 return; | 133 return; |
| 133 } | 134 } |
| 134 | 135 |
| 135 std::string init_data_type_as_ascii = base::UTF16ToASCII(init_data_type); | 136 std::string init_data_type_as_ascii = base::UTF16ToASCII(init_data_type); |
| 136 DLOG_IF(WARNING, init_data_type_as_ascii.find('/') != std::string::npos) | 137 DLOG_IF(WARNING, init_data_type_as_ascii.find('/') != std::string::npos) |
| 137 << "init_data_type '" << init_data_type_as_ascii | 138 << "init_data_type '" << init_data_type_as_ascii |
| 138 << "' may be a MIME type"; | 139 << "' may be a MIME type"; |
| 139 | 140 |
| 141 // Step 5 from https://w3c.github.io/encrypted-media/#generateRequest. | |
| 142 // 5. If the Key System implementation represented by this object's cdm | |
| 143 // implementation value does not support initDataType as an Initialization | |
| 144 // Data Type, return a promise rejected with a new DOMException whose name | |
| 145 // is NotSupportedError. String comparison is case-sensitive. | |
| 146 if (!IsSupportedKeySystemWithInitDataType(adapter_->GetKeySystem(), | |
| 147 init_data_type_as_ascii)) { | |
| 148 std::string message = "The initialization data type " + | |
| 149 init_data_type_as_ascii + | |
| 150 " is not supported by the key system."; | |
| 151 result.completeWithError( | |
| 152 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, | |
| 153 blink::WebString::fromUTF8(message)); | |
| 154 return; | |
| 155 } | |
| 156 | |
| 140 MediaKeys::SessionType session_type_enum; | 157 MediaKeys::SessionType session_type_enum; |
| 141 if (session_type == kPersistentLicenseSessionType) { | 158 if (session_type == kPersistentLicenseSessionType) { |
| 142 session_type_enum = MediaKeys::PERSISTENT_LICENSE_SESSION; | 159 session_type_enum = MediaKeys::PERSISTENT_LICENSE_SESSION; |
| 143 } else if (session_type == kPersistentReleaseMessageSessionType) { | 160 } else if (session_type == kPersistentReleaseMessageSessionType) { |
| 144 session_type_enum = MediaKeys::PERSISTENT_RELEASE_MESSAGE_SESSION; | 161 session_type_enum = MediaKeys::PERSISTENT_RELEASE_MESSAGE_SESSION; |
| 145 } else { | 162 } else { |
| 146 DCHECK(session_type == kTemporarySessionType); | 163 DCHECK(session_type == kTemporarySessionType); |
| 147 session_type_enum = MediaKeys::TEMPORARY_SESSION; | 164 session_type_enum = MediaKeys::TEMPORARY_SESSION; |
| 148 } | 165 } |
| 149 | 166 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 return blink::WebContentDecryptionModuleResult::SessionNotFound; | 273 return blink::WebContentDecryptionModuleResult::SessionNotFound; |
| 257 | 274 |
| 258 DCHECK(session_id_.empty()) << "Session ID may not be changed once set."; | 275 DCHECK(session_id_.empty()) << "Session ID may not be changed once set."; |
| 259 session_id_ = session_id; | 276 session_id_ = session_id; |
| 260 return adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr()) | 277 return adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr()) |
| 261 ? blink::WebContentDecryptionModuleResult::NewSession | 278 ? blink::WebContentDecryptionModuleResult::NewSession |
| 262 : blink::WebContentDecryptionModuleResult::SessionAlreadyExists; | 279 : blink::WebContentDecryptionModuleResult::SessionAlreadyExists; |
| 263 } | 280 } |
| 264 | 281 |
| 265 } // namespace media | 282 } // namespace media |
| OLD | NEW |