OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "public/platform/WebContentDecryptionModuleSession.h" | 48 #include "public/platform/WebContentDecryptionModuleSession.h" |
49 #include "public/platform/WebEncryptedMediaKeyInformation.h" | 49 #include "public/platform/WebEncryptedMediaKeyInformation.h" |
50 #include "public/platform/WebString.h" | 50 #include "public/platform/WebString.h" |
51 #include "public/platform/WebURL.h" | 51 #include "public/platform/WebURL.h" |
52 #include "wtf/ASCIICType.h" | 52 #include "wtf/ASCIICType.h" |
53 #include <cmath> | 53 #include <cmath> |
54 #include <limits> | 54 #include <limits> |
55 | 55 |
56 namespace { | 56 namespace { |
57 | 57 |
58 // The list of possible values for |sessionType|. | |
59 const char kTemporary[] = "temporary"; | |
60 const char kPersistentLicense[] = "persistent-license"; | |
61 const char kPersistentReleaseMessage[] = "persistent-release-message"; | |
62 | |
63 // The list of possible values for |messageType|. | |
64 const char kLicenseRequest[] = "license-request"; | |
65 const char kLicenseRenewal[] = "license-renewal"; | |
66 const char kLicenseRelease[] = "license-release"; | |
67 | |
68 // Minimum and maximum length for session ids. | 58 // Minimum and maximum length for session ids. |
69 enum { | 59 enum { |
70 MinSessionIdLength = 1, | 60 MinSessionIdLength = 1, |
71 MaxSessionIdLength = 512 | 61 MaxSessionIdLength = 512 |
72 }; | 62 }; |
73 | 63 |
74 } // namespace | 64 } // namespace |
75 | 65 |
76 namespace blink { | 66 namespace blink { |
77 | 67 |
78 // Checks that |sessionId| looks correct and returns whether all checks pass. | 68 // Checks that |sessionId| looks correct and returns whether all checks pass. |
79 static bool isValidSessionId(const String& sessionId) | 69 static bool isValidSessionId(const String& sessionId) |
80 { | 70 { |
81 if ((sessionId.length() < MinSessionIdLength) || (sessionId.length() > MaxSe
ssionIdLength)) | 71 if ((sessionId.length() < MinSessionIdLength) || (sessionId.length() > MaxSe
ssionIdLength)) |
82 return false; | 72 return false; |
83 | 73 |
84 if (!sessionId.containsOnlyASCII()) | 74 if (!sessionId.containsOnlyASCII()) |
85 return false; | 75 return false; |
86 | 76 |
87 // Check that the sessionId only contains alphanumeric characters. | 77 // Check that the sessionId only contains alphanumeric characters. |
88 for (unsigned i = 0; i < sessionId.length(); ++i) { | 78 for (unsigned i = 0; i < sessionId.length(); ++i) { |
89 if (!isASCIIAlphanumeric(sessionId[i])) | 79 if (!isASCIIAlphanumeric(sessionId[i])) |
90 return false; | 80 return false; |
91 } | 81 } |
92 | 82 |
93 return true; | 83 return true; |
94 } | 84 } |
95 | 85 |
96 // Checks that |initDataType| is a registered Initialization Data Type. | |
97 static bool isRegisteredInitDataType(const String& initDataType) | |
98 { | |
99 // List from https://w3c.github.io/encrypted-media/initdata-format-registry.
html | |
100 return initDataType == "cenc" || initDataType == "keyids" || initDataType ==
"webm"; | |
101 } | |
102 | |
103 static String ConvertKeyStatusToString(const WebEncryptedMediaKeyInformation::Ke
yStatus status) | 86 static String ConvertKeyStatusToString(const WebEncryptedMediaKeyInformation::Ke
yStatus status) |
104 { | 87 { |
105 switch (status) { | 88 switch (status) { |
106 case WebEncryptedMediaKeyInformation::KeyStatus::Usable: | 89 case WebEncryptedMediaKeyInformation::KeyStatus::Usable: |
107 return "usable"; | 90 return "usable"; |
108 case WebEncryptedMediaKeyInformation::KeyStatus::Expired: | 91 case WebEncryptedMediaKeyInformation::KeyStatus::Expired: |
109 return "expired"; | 92 return "expired"; |
110 case WebEncryptedMediaKeyInformation::KeyStatus::OutputNotAllowed: | 93 case WebEncryptedMediaKeyInformation::KeyStatus::OutputNotAllowed: |
111 return "output-not-allowed"; | 94 return "output-not-allowed"; |
112 case WebEncryptedMediaKeyInformation::KeyStatus::InternalError: | 95 case WebEncryptedMediaKeyInformation::KeyStatus::InternalError: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 { | 129 { |
147 return m_result; | 130 return m_result; |
148 } | 131 } |
149 | 132 |
150 const PassRefPtr<DOMArrayBuffer> data() const | 133 const PassRefPtr<DOMArrayBuffer> data() const |
151 { | 134 { |
152 ASSERT(m_type == GenerateRequest || m_type == Update); | 135 ASSERT(m_type == GenerateRequest || m_type == Update); |
153 return m_data; | 136 return m_data; |
154 } | 137 } |
155 | 138 |
156 const String& initDataType() const | 139 WebEncryptedMediaInitDataType initDataType() const |
157 { | 140 { |
158 ASSERT(m_type == GenerateRequest); | 141 ASSERT(m_type == GenerateRequest); |
159 return m_stringData; | 142 return m_initDataType; |
160 } | 143 } |
161 | 144 |
162 const String& sessionId() const | 145 const String& sessionId() const |
163 { | 146 { |
164 ASSERT(m_type == Load); | 147 ASSERT(m_type == Load); |
165 return m_stringData; | 148 return m_stringData; |
166 } | 149 } |
167 | 150 |
168 static PendingAction* CreatePendingGenerateRequest(ContentDecryptionModuleRe
sult* result, const String& initDataType, PassRefPtr<DOMArrayBuffer> initData) | 151 static PendingAction* CreatePendingGenerateRequest(ContentDecryptionModuleRe
sult* result, WebEncryptedMediaInitDataType initDataType, PassRefPtr<DOMArrayBuf
fer> initData) |
169 { | 152 { |
170 ASSERT(result); | 153 ASSERT(result); |
171 ASSERT(initData); | 154 ASSERT(initData); |
172 return new PendingAction(GenerateRequest, result, initDataType, initData
); | 155 return new PendingAction(GenerateRequest, result, initDataType, initData
, String()); |
173 } | 156 } |
174 | 157 |
175 static PendingAction* CreatePendingLoadRequest(ContentDecryptionModuleResult
* result, const String& sessionId) | 158 static PendingAction* CreatePendingLoadRequest(ContentDecryptionModuleResult
* result, const String& sessionId) |
176 { | 159 { |
177 ASSERT(result); | 160 ASSERT(result); |
178 return new PendingAction(Load, result, sessionId, PassRefPtr<DOMArrayBuf
fer>()); | 161 return new PendingAction(Load, result, WebEncryptedMediaInitDataType::Un
known, PassRefPtr<DOMArrayBuffer>(), sessionId); |
179 } | 162 } |
180 | 163 |
181 static PendingAction* CreatePendingUpdate(ContentDecryptionModuleResult* res
ult, PassRefPtr<DOMArrayBuffer> data) | 164 static PendingAction* CreatePendingUpdate(ContentDecryptionModuleResult* res
ult, PassRefPtr<DOMArrayBuffer> data) |
182 { | 165 { |
183 ASSERT(result); | 166 ASSERT(result); |
184 ASSERT(data); | 167 ASSERT(data); |
185 return new PendingAction(Update, result, String(), data); | 168 return new PendingAction(Update, result, WebEncryptedMediaInitDataType::
Unknown, data, String()); |
186 } | 169 } |
187 | 170 |
188 static PendingAction* CreatePendingClose(ContentDecryptionModuleResult* resu
lt) | 171 static PendingAction* CreatePendingClose(ContentDecryptionModuleResult* resu
lt) |
189 { | 172 { |
190 ASSERT(result); | 173 ASSERT(result); |
191 return new PendingAction(Close, result, String(), PassRefPtr<DOMArrayBuf
fer>()); | 174 return new PendingAction(Close, result, WebEncryptedMediaInitDataType::U
nknown, PassRefPtr<DOMArrayBuffer>(), String()); |
192 } | 175 } |
193 | 176 |
194 static PendingAction* CreatePendingRemove(ContentDecryptionModuleResult* res
ult) | 177 static PendingAction* CreatePendingRemove(ContentDecryptionModuleResult* res
ult) |
195 { | 178 { |
196 ASSERT(result); | 179 ASSERT(result); |
197 return new PendingAction(Remove, result, String(), PassRefPtr<DOMArrayBu
ffer>()); | 180 return new PendingAction(Remove, result, WebEncryptedMediaInitDataType::
Unknown, PassRefPtr<DOMArrayBuffer>(), String()); |
198 } | 181 } |
199 | 182 |
200 ~PendingAction() | 183 ~PendingAction() |
201 { | 184 { |
202 } | 185 } |
203 | 186 |
204 DEFINE_INLINE_TRACE() | 187 DEFINE_INLINE_TRACE() |
205 { | 188 { |
206 visitor->trace(m_result); | 189 visitor->trace(m_result); |
207 } | 190 } |
208 | 191 |
209 private: | 192 private: |
210 PendingAction(Type type, ContentDecryptionModuleResult* result, const String
& stringData, PassRefPtr<DOMArrayBuffer> data) | 193 PendingAction(Type type, ContentDecryptionModuleResult* result, WebEncrypted
MediaInitDataType initDataType, PassRefPtr<DOMArrayBuffer> data, const String& s
tringData) |
211 : m_type(type) | 194 : m_type(type) |
212 , m_result(result) | 195 , m_result(result) |
| 196 , m_initDataType(initDataType) |
| 197 , m_data(data) |
213 , m_stringData(stringData) | 198 , m_stringData(stringData) |
214 , m_data(data) | |
215 { | 199 { |
216 } | 200 } |
217 | 201 |
218 const Type m_type; | 202 const Type m_type; |
219 const Member<ContentDecryptionModuleResult> m_result; | 203 const Member<ContentDecryptionModuleResult> m_result; |
| 204 const WebEncryptedMediaInitDataType m_initDataType; |
| 205 const RefPtr<DOMArrayBuffer> m_data; |
220 const String m_stringData; | 206 const String m_stringData; |
221 const RefPtr<DOMArrayBuffer> m_data; | |
222 }; | 207 }; |
223 | 208 |
224 // This class wraps the promise resolver used when initializing a new session | 209 // This class wraps the promise resolver used when initializing a new session |
225 // and is passed to Chromium to fullfill the promise. This implementation of | 210 // and is passed to Chromium to fullfill the promise. This implementation of |
226 // completeWithSession() will resolve the promise with void, while | 211 // completeWithSession() will resolve the promise with void, while |
227 // completeWithError() will reject the promise with an exception. complete() | 212 // completeWithError() will reject the promise with an exception. complete() |
228 // is not expected to be called, and will reject the promise. | 213 // is not expected to be called, and will reject the promise. |
229 class NewSessionResultPromise : public ContentDecryptionModuleResultPromise { | 214 class NewSessionResultPromise : public ContentDecryptionModuleResultPromise { |
230 public: | 215 public: |
231 NewSessionResultPromise(ScriptState* scriptState, MediaKeySession* session) | 216 NewSessionResultPromise(ScriptState* scriptState, MediaKeySession* session) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 DEFINE_INLINE_TRACE() | 288 DEFINE_INLINE_TRACE() |
304 { | 289 { |
305 visitor->trace(m_session); | 290 visitor->trace(m_session); |
306 ContentDecryptionModuleResultPromise::trace(visitor); | 291 ContentDecryptionModuleResultPromise::trace(visitor); |
307 } | 292 } |
308 | 293 |
309 private: | 294 private: |
310 Member<MediaKeySession> m_session; | 295 Member<MediaKeySession> m_session; |
311 }; | 296 }; |
312 | 297 |
313 MediaKeySession* MediaKeySession::create(ScriptState* scriptState, MediaKeys* me
diaKeys, const String& sessionType) | 298 MediaKeySession* MediaKeySession::create(ScriptState* scriptState, MediaKeys* me
diaKeys, WebEncryptedMediaSessionType sessionType) |
314 { | 299 { |
315 ASSERT(isValidSessionType(sessionType)); | |
316 RefPtrWillBeRawPtr<MediaKeySession> session = new MediaKeySession(scriptStat
e, mediaKeys, sessionType); | 300 RefPtrWillBeRawPtr<MediaKeySession> session = new MediaKeySession(scriptStat
e, mediaKeys, sessionType); |
317 session->suspendIfNeeded(); | 301 session->suspendIfNeeded(); |
318 return session.get(); | 302 return session.get(); |
319 } | 303 } |
320 | 304 |
321 bool MediaKeySession::isValidSessionType(const String& sessionType) | 305 WebEncryptedMediaInitDataType MediaKeySession::convertInitDataType(const String&
initDataType) |
322 { | 306 { |
323 return (sessionType == kTemporary || sessionType == kPersistentLicense || se
ssionType == kPersistentReleaseMessage); | 307 if (initDataType == "cenc") |
| 308 return WebEncryptedMediaInitDataType::Cenc; |
| 309 if (initDataType == "keyids") |
| 310 return WebEncryptedMediaInitDataType::Keyids; |
| 311 if (initDataType == "webm") |
| 312 return WebEncryptedMediaInitDataType::Webm; |
| 313 |
| 314 // |initDataType| is not restricted in the idl, so anything is possible. |
| 315 return WebEncryptedMediaInitDataType::Unknown; |
324 } | 316 } |
325 | 317 |
326 MediaKeySession::MediaKeySession(ScriptState* scriptState, MediaKeys* mediaKeys,
const String& sessionType) | 318 WebEncryptedMediaSessionType MediaKeySession::convertSessionType(const String& s
essionType) |
| 319 { |
| 320 if (sessionType == "temporary") |
| 321 return WebEncryptedMediaSessionType::Temporary; |
| 322 if (sessionType == "persistent-license") |
| 323 return WebEncryptedMediaSessionType::PersistentLicense; |
| 324 if (sessionType == "persistent-release-message") |
| 325 return WebEncryptedMediaSessionType::PersistentReleaseMessage; |
| 326 |
| 327 ASSERT_NOT_REACHED(); |
| 328 return WebEncryptedMediaSessionType::Unknown; |
| 329 } |
| 330 |
| 331 MediaKeySession::MediaKeySession(ScriptState* scriptState, MediaKeys* mediaKeys,
WebEncryptedMediaSessionType sessionType) |
327 : ActiveDOMObject(scriptState->executionContext()) | 332 : ActiveDOMObject(scriptState->executionContext()) |
328 , m_keySystem(mediaKeys->keySystem()) | 333 , m_keySystem(mediaKeys->keySystem()) |
329 , m_asyncEventQueue(GenericEventQueue::create(this)) | 334 , m_asyncEventQueue(GenericEventQueue::create(this)) |
330 , m_mediaKeys(mediaKeys) | 335 , m_mediaKeys(mediaKeys) |
331 , m_sessionType(sessionType) | 336 , m_sessionType(sessionType) |
332 , m_expiration(std::numeric_limits<double>::quiet_NaN()) | 337 , m_expiration(std::numeric_limits<double>::quiet_NaN()) |
333 , m_keyStatusesMap(new MediaKeyStatusMap()) | 338 , m_keyStatusesMap(new MediaKeyStatusMap()) |
334 , m_isUninitialized(true) | 339 , m_isUninitialized(true) |
335 , m_isCallable(false) | 340 , m_isCallable(false) |
336 , m_isClosed(false) | 341 , m_isClosed(false) |
(...skipping 17 matching lines...) Expand all Loading... |
354 // 3.2 Let the expiration attribute be NaN. | 359 // 3.2 Let the expiration attribute be NaN. |
355 ASSERT(std::isnan(m_expiration)); | 360 ASSERT(std::isnan(m_expiration)); |
356 | 361 |
357 // 3.3 Let the closed attribute be a new promise. | 362 // 3.3 Let the closed attribute be a new promise. |
358 ASSERT(!closed(scriptState).isUndefinedOrNull()); | 363 ASSERT(!closed(scriptState).isUndefinedOrNull()); |
359 | 364 |
360 // 3.4 Let the keyStatuses attribute be empty. | 365 // 3.4 Let the keyStatuses attribute be empty. |
361 ASSERT(m_keyStatusesMap->size() == 0); | 366 ASSERT(m_keyStatusesMap->size() == 0); |
362 | 367 |
363 // 3.5 Let the session type be sessionType. | 368 // 3.5 Let the session type be sessionType. |
364 ASSERT(isValidSessionType(m_sessionType)); | 369 ASSERT(m_sessionType != WebEncryptedMediaSessionType::Unknown); |
365 | 370 |
366 // 3.6 Let uninitialized be true. | 371 // 3.6 Let uninitialized be true. |
367 ASSERT(m_isUninitialized); | 372 ASSERT(m_isUninitialized); |
368 | 373 |
369 // 3.7 Let callable be false. | 374 // 3.7 Let callable be false. |
370 ASSERT(!m_isCallable); | 375 ASSERT(!m_isCallable); |
371 | 376 |
372 // 3.8 Let the use distinctive identifier value be this object's | 377 // 3.8 Let the use distinctive identifier value be this object's |
373 // use distinctive identifier. | 378 // use distinctive identifier. |
374 // FIXME: Implement this (http://crbug.com/448922). | 379 // FIXME: Implement this (http://crbug.com/448922). |
(...skipping 22 matching lines...) Expand all Loading... |
397 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) | 402 ScriptPromise MediaKeySession::closed(ScriptState* scriptState) |
398 { | 403 { |
399 return m_closedPromise->promise(scriptState->world()); | 404 return m_closedPromise->promise(scriptState->world()); |
400 } | 405 } |
401 | 406 |
402 MediaKeyStatusMap* MediaKeySession::keyStatuses() | 407 MediaKeyStatusMap* MediaKeySession::keyStatuses() |
403 { | 408 { |
404 return m_keyStatusesMap; | 409 return m_keyStatusesMap; |
405 } | 410 } |
406 | 411 |
407 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S
tring& initDataType, const DOMArrayPiece& initData) | 412 ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S
tring& initDataTypeString, const DOMArrayPiece& initData) |
408 { | 413 { |
409 WTF_LOG(Media, "MediaKeySession(%p)::generateRequest %s", this, initDataType
.ascii().data()); | 414 WTF_LOG(Media, "MediaKeySession(%p)::generateRequest %s", this, initDataType
String.ascii().data()); |
410 | 415 |
411 // From https://w3c.github.io/encrypted-media/#generateRequest: | 416 // From https://w3c.github.io/encrypted-media/#generateRequest: |
412 // Generates a request based on the initData. When this method is invoked, | 417 // Generates a request based on the initData. When this method is invoked, |
413 // the user agent must run the following steps: | 418 // the user agent must run the following steps: |
414 | 419 |
415 // 1. If this object's uninitialized value is false, return a promise | 420 // 1. If this object's uninitialized value is false, return a promise |
416 // rejected with a new DOMException whose name is "InvalidStateError". | 421 // rejected with a new DOMException whose name is "InvalidStateError". |
417 if (!m_isUninitialized) | 422 if (!m_isUninitialized) |
418 return CreateRejectedPromiseAlreadyInitialized(scriptState); | 423 return CreateRejectedPromiseAlreadyInitialized(scriptState); |
419 | 424 |
420 // 2. Let this object's uninitialized be false. | 425 // 2. Let this object's uninitialized be false. |
421 m_isUninitialized = false; | 426 m_isUninitialized = false; |
422 | 427 |
423 // 3. If initDataType is an empty string, return a promise rejected with a | 428 // 3. If initDataType is an empty string, return a promise rejected with a |
424 // new DOMException whose name is "InvalidAccessError". | 429 // new DOMException whose name is "InvalidAccessError". |
425 if (initDataType.isEmpty()) { | 430 if (initDataTypeString.isEmpty()) { |
426 return ScriptPromise::rejectWithDOMException( | 431 return ScriptPromise::rejectWithDOMException( |
427 scriptState, DOMException::create(InvalidAccessError, "The initDataT
ype parameter is empty.")); | 432 scriptState, DOMException::create(InvalidAccessError, "The initDataT
ype parameter is empty.")); |
428 } | 433 } |
429 | 434 |
430 // 4. If initData is an empty array, return a promise rejected with a new | 435 // 4. If initData is an empty array, return a promise rejected with a new |
431 // DOMException whose name is"InvalidAccessError". | 436 // DOMException whose name is"InvalidAccessError". |
432 if (!initData.byteLength()) { | 437 if (!initData.byteLength()) { |
433 return ScriptPromise::rejectWithDOMException( | 438 return ScriptPromise::rejectWithDOMException( |
434 scriptState, DOMException::create(InvalidAccessError, "The initData
parameter is empty.")); | 439 scriptState, DOMException::create(InvalidAccessError, "The initData
parameter is empty.")); |
435 } | 440 } |
436 | 441 |
437 // 5. If the Key System implementation represented by this object's cdm | 442 // 5. If the Key System implementation represented by this object's cdm |
438 // implementation value does not support initDataType as an | 443 // implementation value does not support initDataType as an |
439 // Initialization Data Type, return a promise rejected with a new | 444 // Initialization Data Type, return a promise rejected with a new |
440 // DOMException whose name is NotSupportedError. String comparison | 445 // DOMException whose name is NotSupportedError. String comparison |
441 // is case-sensitive. | 446 // is case-sensitive. |
442 // (blink side doesn't know what the CDM supports, so the proper check | 447 // (blink side doesn't know what the CDM supports, so the proper check |
443 // will be done on the Chromium side. However, we can verify that | 448 // will be done on the Chromium side. However, we can verify that |
444 // |initDataType| is one of the registered values.) | 449 // |initDataType| is one of the registered values.) |
445 if (!isRegisteredInitDataType(initDataType)) { | 450 WebEncryptedMediaInitDataType initDataType = convertInitDataType(initDataTyp
eString); |
| 451 if (initDataType == WebEncryptedMediaInitDataType::Unknown) { |
446 return ScriptPromise::rejectWithDOMException( | 452 return ScriptPromise::rejectWithDOMException( |
447 scriptState, DOMException::create(NotSupportedError, "The initializa
tion data type '" + initDataType + "' is not a registered Initialization Data Ty
pe.")); | 453 scriptState, DOMException::create(NotSupportedError, "The initializa
tion data type '" + initDataTypeString + "' is not supported.")); |
448 } | 454 } |
449 | 455 |
450 // 6. Let init data be a copy of the contents of the initData parameter. | 456 // 6. Let init data be a copy of the contents of the initData parameter. |
451 RefPtr<DOMArrayBuffer> initDataBuffer = DOMArrayBuffer::create(initData.data
(), initData.byteLength()); | 457 RefPtr<DOMArrayBuffer> initDataBuffer = DOMArrayBuffer::create(initData.data
(), initData.byteLength()); |
452 | 458 |
453 // 7. Let session type be this object's session type. | 459 // 7. Let session type be this object's session type. |
454 // (Done in constructor.) | 460 // (Done in constructor.) |
455 | 461 |
456 // 8. Let promise be a new promise. | 462 // 8. Let promise be a new promise. |
457 NewSessionResultPromise* result = new NewSessionResultPromise(scriptState, t
his); | 463 NewSessionResultPromise* result = new NewSessionResultPromise(scriptState, t
his); |
(...skipping 28 matching lines...) Expand all Loading... |
486 // 3. If sessionId is an empty string, return a promise rejected with a | 492 // 3. If sessionId is an empty string, return a promise rejected with a |
487 // new DOMException whose name is "InvalidAccessError". | 493 // new DOMException whose name is "InvalidAccessError". |
488 if (sessionId.isEmpty()) { | 494 if (sessionId.isEmpty()) { |
489 return ScriptPromise::rejectWithDOMException( | 495 return ScriptPromise::rejectWithDOMException( |
490 scriptState, DOMException::create(InvalidAccessError, "The sessionId
parameter is empty.")); | 496 scriptState, DOMException::create(InvalidAccessError, "The sessionId
parameter is empty.")); |
491 } | 497 } |
492 | 498 |
493 // 4. If this object's session type is not "persistent-license" or | 499 // 4. If this object's session type is not "persistent-license" or |
494 // "persistent-release-message", return a promise rejected with a | 500 // "persistent-release-message", return a promise rejected with a |
495 // new DOMException whose name is InvalidAccessError. | 501 // new DOMException whose name is InvalidAccessError. |
496 if (m_sessionType != kPersistentLicense && m_sessionType != kPersistentRelea
seMessage) { | 502 if (m_sessionType != WebEncryptedMediaSessionType::PersistentLicense && m_se
ssionType != WebEncryptedMediaSessionType::PersistentReleaseMessage) { |
497 return ScriptPromise::rejectWithDOMException( | 503 return ScriptPromise::rejectWithDOMException( |
498 scriptState, DOMException::create(InvalidAccessError, "The session t
ype is not persistent.")); | 504 scriptState, DOMException::create(InvalidAccessError, "The session t
ype is not persistent.")); |
499 } | 505 } |
500 | 506 |
501 // 5. If the Key System implementation represented by this object's cdm | 507 // 5. If the Key System implementation represented by this object's cdm |
502 // implementation value does not support loading previous sessions, | 508 // implementation value does not support loading previous sessions, |
503 // return a promise rejected with a new DOMException whose name is | 509 // return a promise rejected with a new DOMException whose name is |
504 // NotSupportedError. | 510 // NotSupportedError. |
505 // FIXME: Implement this (http://crbug.com/448922). | 511 // FIXME: Implement this (http://crbug.com/448922). |
506 | 512 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 // method is invoked, the user agent must run the following steps: | 607 // method is invoked, the user agent must run the following steps: |
602 | 608 |
603 // 1. If this object's callable value is false, return a promise rejected | 609 // 1. If this object's callable value is false, return a promise rejected |
604 // with a new DOMException whose name is "InvalidStateError". | 610 // with a new DOMException whose name is "InvalidStateError". |
605 if (!m_isCallable) | 611 if (!m_isCallable) |
606 return CreateRejectedPromiseNotCallable(scriptState); | 612 return CreateRejectedPromiseNotCallable(scriptState); |
607 | 613 |
608 // 2. If this object's session type is not "persistent-license" or | 614 // 2. If this object's session type is not "persistent-license" or |
609 // "persistent-release-message", return a promise rejected with a | 615 // "persistent-release-message", return a promise rejected with a |
610 // new DOMException whose name is InvalidAccessError. | 616 // new DOMException whose name is InvalidAccessError. |
611 if (m_sessionType != kPersistentLicense && m_sessionType != kPersistentRelea
seMessage) { | 617 if (m_sessionType != WebEncryptedMediaSessionType::PersistentLicense && m_se
ssionType != WebEncryptedMediaSessionType::PersistentReleaseMessage) { |
612 return ScriptPromise::rejectWithDOMException( | 618 return ScriptPromise::rejectWithDOMException( |
613 scriptState, DOMException::create(InvalidAccessError, "The session t
ype is not persistent.")); | 619 scriptState, DOMException::create(InvalidAccessError, "The session t
ype is not persistent.")); |
614 } | 620 } |
615 | 621 |
616 // 3. If the Session Close algorithm has been run on this object, return a | 622 // 3. If the Session Close algorithm has been run on this object, return a |
617 // promise rejected with a new DOMException whose name is | 623 // promise rejected with a new DOMException whose name is |
618 // "InvalidStateError". | 624 // "InvalidStateError". |
619 if (m_isClosed) { | 625 if (m_isClosed) { |
620 return ScriptPromise::rejectWithDOMException( | 626 return ScriptPromise::rejectWithDOMException( |
621 scriptState, DOMException::create(InvalidStateError, "The session is
already closed.")); | 627 scriptState, DOMException::create(InvalidStateError, "The session is
already closed.")); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 // The following steps are run: | 804 // The following steps are run: |
799 // 1. Let the session be the specified MediaKeySession object. | 805 // 1. Let the session be the specified MediaKeySession object. |
800 // 2. Queue a task to fire a simple event named message at the session. | 806 // 2. Queue a task to fire a simple event named message at the session. |
801 // The event is of type MediaKeyMessageEvent and has: | 807 // The event is of type MediaKeyMessageEvent and has: |
802 // -> messageType = the specified message type | 808 // -> messageType = the specified message type |
803 // -> message = the specified message | 809 // -> message = the specified message |
804 | 810 |
805 MediaKeyMessageEventInit init; | 811 MediaKeyMessageEventInit init; |
806 switch (messageType) { | 812 switch (messageType) { |
807 case WebContentDecryptionModuleSession::Client::MessageType::LicenseRequest: | 813 case WebContentDecryptionModuleSession::Client::MessageType::LicenseRequest: |
808 init.setMessageType(kLicenseRequest); | 814 init.setMessageType("license-request"); |
809 break; | 815 break; |
810 case WebContentDecryptionModuleSession::Client::MessageType::LicenseRenewal: | 816 case WebContentDecryptionModuleSession::Client::MessageType::LicenseRenewal: |
811 init.setMessageType(kLicenseRenewal); | 817 init.setMessageType("license-renewal"); |
812 break; | 818 break; |
813 case WebContentDecryptionModuleSession::Client::MessageType::LicenseRelease: | 819 case WebContentDecryptionModuleSession::Client::MessageType::LicenseRelease: |
814 init.setMessageType(kLicenseRelease); | 820 init.setMessageType("license-release"); |
815 break; | 821 break; |
816 } | 822 } |
817 init.setMessage(DOMArrayBuffer::create(static_cast<const void*>(message), me
ssageLength)); | 823 init.setMessage(DOMArrayBuffer::create(static_cast<const void*>(message), me
ssageLength)); |
818 | 824 |
819 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat
e(EventTypeNames::message, init); | 825 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat
e(EventTypeNames::message, init); |
820 event->setTarget(this); | 826 event->setTarget(this); |
821 m_asyncEventQueue->enqueueEvent(event.release()); | 827 m_asyncEventQueue->enqueueEvent(event.release()); |
822 } | 828 } |
823 | 829 |
824 void MediaKeySession::close() | 830 void MediaKeySession::close() |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 visitor->trace(m_asyncEventQueue); | 945 visitor->trace(m_asyncEventQueue); |
940 visitor->trace(m_pendingActions); | 946 visitor->trace(m_pendingActions); |
941 visitor->trace(m_mediaKeys); | 947 visitor->trace(m_mediaKeys); |
942 visitor->trace(m_keyStatusesMap); | 948 visitor->trace(m_keyStatusesMap); |
943 visitor->trace(m_closedPromise); | 949 visitor->trace(m_closedPromise); |
944 RefCountedGarbageCollectedEventTargetWithInlineData<MediaKeySession>::trace(
visitor); | 950 RefCountedGarbageCollectedEventTargetWithInlineData<MediaKeySession>::trace(
visitor); |
945 ActiveDOMObject::trace(visitor); | 951 ActiveDOMObject::trace(visitor); |
946 } | 952 } |
947 | 953 |
948 } // namespace blink | 954 } // namespace blink |
OLD | NEW |