OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
6 #include "modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.h" | 6 #include "modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.h" |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
11 #include "core/dom/Document.h" | 11 #include "core/dom/Document.h" |
12 #include "core/dom/ExceptionCode.h" | 12 #include "core/dom/ExceptionCode.h" |
| 13 #include "core/frame/UseCounter.h" |
13 #include "modules/encryptedmedia/EncryptedMediaUtils.h" | 14 #include "modules/encryptedmedia/EncryptedMediaUtils.h" |
14 #include "modules/encryptedmedia/MediaKeySession.h" | 15 #include "modules/encryptedmedia/MediaKeySession.h" |
15 #include "modules/encryptedmedia/MediaKeySystemAccess.h" | 16 #include "modules/encryptedmedia/MediaKeySystemAccess.h" |
16 #include "modules/encryptedmedia/MediaKeysController.h" | 17 #include "modules/encryptedmedia/MediaKeysController.h" |
17 #include "platform/EncryptedMediaRequest.h" | 18 #include "platform/EncryptedMediaRequest.h" |
18 #include "platform/Logging.h" | 19 #include "platform/Logging.h" |
19 #include "platform/network/ParsedContentType.h" | 20 #include "platform/network/ParsedContentType.h" |
20 #include "public/platform/WebEncryptedMediaClient.h" | 21 #include "public/platform/WebEncryptedMediaClient.h" |
21 #include "public/platform/WebEncryptedMediaRequest.h" | 22 #include "public/platform/WebEncryptedMediaRequest.h" |
22 #include "public/platform/WebMediaKeySystemConfiguration.h" | 23 #include "public/platform/WebMediaKeySystemConfiguration.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 168 |
168 // 2. If supportedConfigurations was provided and is empty, return a | 169 // 2. If supportedConfigurations was provided and is empty, return a |
169 // promise rejected with a new DOMException whose name is | 170 // promise rejected with a new DOMException whose name is |
170 // InvalidAccessError. | 171 // InvalidAccessError. |
171 if (!supportedConfigurations.size()) { | 172 if (!supportedConfigurations.size()) { |
172 return ScriptPromise::rejectWithDOMException( | 173 return ScriptPromise::rejectWithDOMException( |
173 scriptState, DOMException::create(InvalidAccessError, "The supported
Configurations parameter is empty.")); | 174 scriptState, DOMException::create(InvalidAccessError, "The supported
Configurations parameter is empty.")); |
174 } | 175 } |
175 | 176 |
176 // 3-4. 'May Document use powerful features?' check. | 177 // 3-4. 'May Document use powerful features?' check. |
177 // FIXME: Implement 'May Document use powerful features?' check. | 178 ExecutionContext* executionContext = scriptState->executionContext(); |
| 179 String errorMessage; |
| 180 if (executionContext->isPrivilegedContext(errorMessage)) { |
| 181 UseCounter::count(executionContext, UseCounter::EncryptedMediaSecureOrig
in); |
| 182 } else { |
| 183 UseCounter::countDeprecation(executionContext, UseCounter::EncryptedMedi
aInsecureOrigin); |
| 184 // TODO(ddorwin): Implement the following: |
| 185 // Reject promise with a new DOMException whose name is NotSupportedErro
r. |
| 186 } |
| 187 |
178 | 188 |
179 // 5. Let origin be the origin of document. | 189 // 5. Let origin be the origin of document. |
180 // (Passed with the execution context in step 7.) | 190 // (Passed with the execution context in step 7.) |
181 | 191 |
182 // 6. Let promise be a new promise. | 192 // 6. Let promise be a new promise. |
183 Document* document = toDocument(scriptState->executionContext()); | 193 Document* document = toDocument(executionContext); |
184 if (!document->page()) { | 194 if (!document->page()) { |
185 return ScriptPromise::rejectWithDOMException( | 195 return ScriptPromise::rejectWithDOMException( |
186 scriptState, DOMException::create(InvalidStateError, "Document does
not have a page.")); | 196 scriptState, DOMException::create(InvalidStateError, "Document does
not have a page.")); |
187 } | 197 } |
188 | 198 |
189 MediaKeySystemAccessInitializer* initializer = new MediaKeySystemAccessIniti
alizer(scriptState, keySystem, supportedConfigurations); | 199 MediaKeySystemAccessInitializer* initializer = new MediaKeySystemAccessIniti
alizer(scriptState, keySystem, supportedConfigurations); |
190 ScriptPromise promise = initializer->promise(); | 200 ScriptPromise promise = initializer->promise(); |
191 | 201 |
192 // 7. Asynchronously determine support, and if allowed, create and | 202 // 7. Asynchronously determine support, and if allowed, create and |
193 // initialize the MediaKeySystemAccess object. | 203 // initialize the MediaKeySystemAccess object. |
194 MediaKeysController* controller = MediaKeysController::from(document->page()
); | 204 MediaKeysController* controller = MediaKeysController::from(document->page()
); |
195 WebEncryptedMediaClient* mediaClient = controller->encryptedMediaClient(scri
ptState->executionContext()); | 205 WebEncryptedMediaClient* mediaClient = controller->encryptedMediaClient(exec
utionContext); |
196 mediaClient->requestMediaKeySystemAccess(WebEncryptedMediaRequest(initialize
r)); | 206 mediaClient->requestMediaKeySystemAccess(WebEncryptedMediaRequest(initialize
r)); |
197 | 207 |
198 // 8. Return promise. | 208 // 8. Return promise. |
199 return promise; | 209 return promise; |
200 } | 210 } |
201 | 211 |
202 } // namespace blink | 212 } // namespace blink |
OLD | NEW |