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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 PendingAction(ContentDecryptionModuleResult* result, PassRefPtr<DOMArrayBuff er> data) | 73 PendingAction(ContentDecryptionModuleResult* result, PassRefPtr<DOMArrayBuff er> data) |
74 : m_result(result) | 74 : m_result(result) |
75 , m_data(data) | 75 , m_data(data) |
76 { | 76 { |
77 } | 77 } |
78 | 78 |
79 const Member<ContentDecryptionModuleResult> m_result; | 79 const Member<ContentDecryptionModuleResult> m_result; |
80 const RefPtr<DOMArrayBuffer> m_data; | 80 const RefPtr<DOMArrayBuffer> m_data; |
81 }; | 81 }; |
82 | 82 |
83 MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, PassOwn Ptr<WebContentDecryptionModule> cdm) | 83 MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, const b link::WebMediaKeySystemConfiguration& configuration, PassOwnPtr<WebContentDecryp tionModule> cdm) |
84 : ContextLifecycleObserver(context) | 84 : ContextLifecycleObserver(context) |
85 , m_keySystem(keySystem) | 85 , m_keySystem(keySystem) |
86 , m_configuration(configuration) | |
86 , m_cdm(cdm) | 87 , m_cdm(cdm) |
87 , m_timer(this, &MediaKeys::timerFired) | 88 , m_timer(this, &MediaKeys::timerFired) |
88 { | 89 { |
89 WTF_LOG(Media, "MediaKeys(%p)::MediaKeys", this); | 90 WTF_LOG(Media, "MediaKeys(%p)::MediaKeys", this); |
90 | 91 |
91 // Step 4.4 of MediaKeys::create(): | 92 // Step 4.4 of MediaKeys::create(): |
92 // 4.4.1 Set the keySystem attribute to keySystem. | 93 // 4.4.1 Set the keySystem attribute to keySystem. |
93 ASSERT(!m_keySystem.isEmpty()); | 94 ASSERT(!m_keySystem.isEmpty()); |
94 } | 95 } |
95 | 96 |
96 MediaKeys::~MediaKeys() | 97 MediaKeys::~MediaKeys() |
97 { | 98 { |
98 WTF_LOG(Media, "MediaKeys(%p)::~MediaKeys", this); | 99 WTF_LOG(Media, "MediaKeys(%p)::~MediaKeys", this); |
99 } | 100 } |
100 | 101 |
101 MediaKeySession* MediaKeys::createSession(ScriptState* scriptState, const String & sessionType, ExceptionState& exceptionState) | 102 MediaKeySession* MediaKeys::createSession(ScriptState* scriptState, const String & sessionType, ExceptionState& exceptionState) |
102 { | 103 { |
103 WTF_LOG(Media, "MediaKeys(%p)::createSession", this); | 104 WTF_LOG(Media, "MediaKeys(%p)::createSession", this); |
104 | 105 |
105 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-createsession>: | 106 // From http://w3c.github.io/encrypted-media/#createSession |
106 // The createSession(sessionType) method returns a new MediaKeySession | 107 |
107 // object. It must run the following steps: | 108 // When this method is invoked, the user agent must run the following steps: |
108 // 1. If sessionType is not supported by the content decryption module | 109 // 1. If this object's persistent state allowed value is false and |
109 // corresponding to the keySystem, throw a DOMException whose name is | 110 // sessionType is not "temporary", throw a new DOMException whose name is |
110 // "NotSupportedError". | 111 // NotSupportedError. |
ddorwin
2015/02/20 03:42:00
Something like:
\n
(Chromium ensures the returned
sandersd (OOO until July 31)
2015/02/20 03:47:17
Done.
| |
111 ASSERT(MediaKeySession::isValidSessionType(sessionType)); | 112 // 2. If the Key System implementation represented by this object's cdm |
112 // FIXME: Check whether sessionType is actually supported by the CDM. | 113 // implementation value does not support sessionType, throw a new |
113 // (http://crbug.com/384152) | 114 // DOMException whose name is NotSupportedError. |
114 // FIXME: Enable "persistent-release-message" session type once support | 115 blink::WebString webSessionType = blink::WebString(sessionType); |
115 // added to CDMs. | 116 bool valid = false; |
ddorwin
2015/02/20 03:42:00
nit: Replace valid with supported (or even found).
sandersd (OOO until July 31)
2015/02/20 03:47:17
Done.
| |
116 if (sessionType == "persistent-release-message") { | 117 for (size_t i = 0; i < m_configuration.sessionTypes.size(); i++) { |
117 exceptionState.throwDOMException(NotSupportedError, "'persistent-release -message' is not supported."); | 118 if (m_configuration.sessionTypes[i] == webSessionType) { |
ddorwin
2015/02/20 03:42:00
Can we just do blink::WebString(sessionType) inlin
sandersd (OOO until July 31)
2015/02/20 03:47:17
Done.
| |
118 return nullptr; | 119 valid = true; |
120 break; | |
121 } | |
119 } | 122 } |
123 if (!valid) | |
124 exceptionState.throwDOMException(NotSupportedError, "Unsupported session type."); | |
120 | 125 |
121 // 2. Let session be a new MediaKeySession object, and initialize it as | 126 // 3. Let session be a new MediaKeySession object, and initialize it as |
122 // follows: | 127 // follows: |
123 // (Initialization is performed in the constructor.) | 128 // (Initialization is performed in the constructor.) |
124 // 3. Return session. | 129 // 4. Return session. |
125 return MediaKeySession::create(scriptState, this, sessionType); | 130 return MediaKeySession::create(scriptState, this, sessionType); |
126 } | 131 } |
127 | 132 |
128 ScriptPromise MediaKeys::setServerCertificate(ScriptState* scriptState, const DO MArrayPiece& serverCertificate) | 133 ScriptPromise MediaKeys::setServerCertificate(ScriptState* scriptState, const DO MArrayPiece& serverCertificate) |
129 { | 134 { |
130 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-setservercertificate: | 135 // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-setservercertificate: |
131 // The setServerCertificate(serverCertificate) method provides a server | 136 // The setServerCertificate(serverCertificate) method provides a server |
132 // certificate to be used to encrypt messages to the license server. | 137 // certificate to be used to encrypt messages to the license server. |
133 // It must run the following steps: | 138 // It must run the following steps: |
134 // 1. If serverCertificate is an empty array, return a promise rejected | 139 // 1. If serverCertificate is an empty array, return a promise rejected |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 | 203 |
199 void MediaKeys::contextDestroyed() | 204 void MediaKeys::contextDestroyed() |
200 { | 205 { |
201 ContextLifecycleObserver::contextDestroyed(); | 206 ContextLifecycleObserver::contextDestroyed(); |
202 | 207 |
203 // We don't need the CDM anymore. | 208 // We don't need the CDM anymore. |
204 m_cdm.clear(); | 209 m_cdm.clear(); |
205 } | 210 } |
206 | 211 |
207 } // namespace blink | 212 } // namespace blink |
OLD | NEW |