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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 DEFINE_GC_INFO(MediaKeys); | 42 DEFINE_GC_INFO(MediaKeys); |
43 | 43 |
44 PassRefPtrWillBeRawPtr<MediaKeys> MediaKeys::create(ExecutionContext* context, c
onst String& keySystem, ExceptionState& exceptionState) | 44 PassRefPtrWillBeRawPtr<MediaKeys> MediaKeys::create(ExecutionContext* context, c
onst String& keySystem, ExceptionState& exceptionState) |
45 { | 45 { |
46 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e
ncrypted-media.html#dom-media-keys-constructor>: | 46 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e
ncrypted-media.html#dom-media-keys-constructor>: |
47 // The MediaKeys(keySystem) constructor must run the following steps: | 47 // The MediaKeys(keySystem) constructor must run the following steps: |
48 | 48 |
49 // 1. If keySystem is null or an empty string, throw an InvalidAccessError e
xception and abort these steps. | 49 // 1. If keySystem is null or an empty string, throw an InvalidAccessError e
xception and abort these steps. |
50 if (keySystem.isEmpty()) { | 50 if (keySystem.isEmpty()) { |
51 exceptionState.throwDOMException(InvalidAccessError, "The key system pro
vided is invalid."); | 51 exceptionState.throwDOMException(InvalidAccessError, "The key system pro
vided is invalid."); |
52 return 0; | 52 return nullptr; |
53 } | 53 } |
54 | 54 |
55 // 2. If keySystem is not one of the user agent's supported Key Systems, thr
ow a NotSupportedError and abort these steps. | 55 // 2. If keySystem is not one of the user agent's supported Key Systems, thr
ow a NotSupportedError and abort these steps. |
56 if (!ContentDecryptionModule::supportsKeySystem(keySystem)) { | 56 if (!ContentDecryptionModule::supportsKeySystem(keySystem)) { |
57 exceptionState.throwDOMException(NotSupportedError, "The '" + keySystem
+ "' key system is not supported."); | 57 exceptionState.throwDOMException(NotSupportedError, "The '" + keySystem
+ "' key system is not supported."); |
58 return 0; | 58 return nullptr; |
59 } | 59 } |
60 | 60 |
61 // 3. Let cdm be the content decryption module corresponding to keySystem. | 61 // 3. Let cdm be the content decryption module corresponding to keySystem. |
62 // 4. Load cdm if necessary. | 62 // 4. Load cdm if necessary. |
63 OwnPtr<ContentDecryptionModule> cdm = ContentDecryptionModule::create(keySys
tem); | 63 OwnPtr<ContentDecryptionModule> cdm = ContentDecryptionModule::create(keySys
tem); |
64 if (!cdm) { | 64 if (!cdm) { |
65 exceptionState.throwDOMException(NotSupportedError, "A content decryptio
n module could not be loaded for the '" + keySystem + "' key system."); | 65 exceptionState.throwDOMException(NotSupportedError, "A content decryptio
n module could not be loaded for the '" + keySystem + "' key system."); |
66 return 0; | 66 return nullptr; |
67 } | 67 } |
68 | 68 |
69 // 5. Create a new MediaKeys object. | 69 // 5. Create a new MediaKeys object. |
70 // 5.1 Let the keySystem attribute be keySystem. | 70 // 5.1 Let the keySystem attribute be keySystem. |
71 // 6. Return the new object to the caller. | 71 // 6. Return the new object to the caller. |
72 return adoptRefWillBeNoop(new MediaKeys(context, keySystem, cdm.release())); | 72 return adoptRefWillBeNoop(new MediaKeys(context, keySystem, cdm.release())); |
73 } | 73 } |
74 | 74 |
75 MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, PassOwn
Ptr<ContentDecryptionModule> cdm) | 75 MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, PassOwn
Ptr<ContentDecryptionModule> cdm) |
76 : ContextLifecycleObserver(context) | 76 : ContextLifecycleObserver(context) |
(...skipping 14 matching lines...) Expand all Loading... |
91 PassRefPtrWillBeRawPtr<MediaKeySession> MediaKeys::createSession(ExecutionContex
t* context, const String& contentType, Uint8Array* initData, ExceptionState& exc
eptionState) | 91 PassRefPtrWillBeRawPtr<MediaKeySession> MediaKeys::createSession(ExecutionContex
t* context, const String& contentType, Uint8Array* initData, ExceptionState& exc
eptionState) |
92 { | 92 { |
93 WTF_LOG(Media, "MediaKeys::createSession"); | 93 WTF_LOG(Media, "MediaKeys::createSession"); |
94 | 94 |
95 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e
ncrypted-media.html#dom-createsession>: | 95 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e
ncrypted-media.html#dom-createsession>: |
96 // The createSession(type, initData) method must run the following steps: | 96 // The createSession(type, initData) method must run the following steps: |
97 // Note: The contents of initData are container-specific Initialization Data
. | 97 // Note: The contents of initData are container-specific Initialization Data
. |
98 | 98 |
99 if (contentType.isEmpty()) { | 99 if (contentType.isEmpty()) { |
100 exceptionState.throwDOMException(InvalidAccessError, "The contentType pr
ovided ('" + contentType + "') is empty."); | 100 exceptionState.throwDOMException(InvalidAccessError, "The contentType pr
ovided ('" + contentType + "') is empty."); |
101 return 0; | 101 return nullptr; |
102 } | 102 } |
103 | 103 |
104 if (!initData || !initData->length()) { | 104 if (!initData || !initData->length()) { |
105 exceptionState.throwDOMException(InvalidAccessError, "The initData provi
ded is null or empty."); | 105 exceptionState.throwDOMException(InvalidAccessError, "The initData provi
ded is null or empty."); |
106 return 0; | 106 return nullptr; |
107 } | 107 } |
108 | 108 |
109 // 1. If type contains a MIME type that is not supported or is not supported
by the keySystem, | 109 // 1. If type contains a MIME type that is not supported or is not supported
by the keySystem, |
110 // throw a NOT_SUPPORTED_ERR exception and abort these steps. | 110 // throw a NOT_SUPPORTED_ERR exception and abort these steps. |
111 if (!m_cdm->supportsMIMEType(contentType)) { | 111 if (!m_cdm->supportsMIMEType(contentType)) { |
112 exceptionState.throwDOMException(NotSupportedError, "The type provided (
'" + contentType + "') is unsupported."); | 112 exceptionState.throwDOMException(NotSupportedError, "The type provided (
'" + contentType + "') is unsupported."); |
113 return 0; | 113 return nullptr; |
114 } | 114 } |
115 | 115 |
116 // 2. Create a new MediaKeySession object. | 116 // 2. Create a new MediaKeySession object. |
117 RefPtrWillBeRawPtr<MediaKeySession> session = MediaKeySession::create(contex
t, m_cdm.get(), m_weakFactory.createWeakPtr()); | 117 RefPtrWillBeRawPtr<MediaKeySession> session = MediaKeySession::create(contex
t, m_cdm.get(), m_weakFactory.createWeakPtr()); |
118 // 2.1 Let the keySystem attribute be keySystem. | 118 // 2.1 Let the keySystem attribute be keySystem. |
119 ASSERT(!session->keySystem().isEmpty()); | 119 ASSERT(!session->keySystem().isEmpty()); |
120 // FIXME: 2.2 Let the state of the session be CREATED. | 120 // FIXME: 2.2 Let the state of the session be CREATED. |
121 | 121 |
122 // 3. Add the new object to an internal list of session objects (not needed)
. | 122 // 3. Add the new object to an internal list of session objects (not needed)
. |
123 | 123 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 167 |
168 void MediaKeys::contextDestroyed() | 168 void MediaKeys::contextDestroyed() |
169 { | 169 { |
170 ContextLifecycleObserver::contextDestroyed(); | 170 ContextLifecycleObserver::contextDestroyed(); |
171 | 171 |
172 // We don't need the CDM anymore. | 172 // We don't need the CDM anymore. |
173 m_cdm.clear(); | 173 m_cdm.clear(); |
174 } | 174 } |
175 | 175 |
176 } | 176 } |
OLD | NEW |