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 "modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.h" | 5 #include "modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 class MediaKeySystemAccessInitializer final : public EncryptedMediaRequest { | 84 class MediaKeySystemAccessInitializer final : public EncryptedMediaRequest { |
85 WTF_MAKE_NONCOPYABLE(MediaKeySystemAccessInitializer); | 85 WTF_MAKE_NONCOPYABLE(MediaKeySystemAccessInitializer); |
86 | 86 |
87 public: | 87 public: |
88 MediaKeySystemAccessInitializer(ScriptState*, const String& keySystem, const
HeapVector<MediaKeySystemConfiguration>& supportedConfigurations); | 88 MediaKeySystemAccessInitializer(ScriptState*, const String& keySystem, const
HeapVector<MediaKeySystemConfiguration>& supportedConfigurations); |
89 ~MediaKeySystemAccessInitializer() override { } | 89 ~MediaKeySystemAccessInitializer() override { } |
90 | 90 |
91 // EncryptedMediaRequest implementation. | 91 // EncryptedMediaRequest implementation. |
92 WebString keySystem() const override { return m_keySystem; } | 92 WebString keySystem() const override { return m_keySystem; } |
93 const WebVector<WebMediaKeySystemConfiguration>& supportedConfigurations() c
onst override { return m_supportedConfigurations; } | 93 const WebVector<WebMediaKeySystemConfiguration>& supportedConfigurations() c
onst override { return m_supportedConfigurations; } |
94 SecurityOrigin* securityOrigin() const override { return m_resolver->executi
onContext()->securityOrigin(); } | 94 SecurityOrigin* getSecurityOrigin() const override { return m_resolver->getE
xecutionContext()->getSecurityOrigin(); } |
95 void requestSucceeded(WebContentDecryptionModuleAccess*) override; | 95 void requestSucceeded(WebContentDecryptionModuleAccess*) override; |
96 void requestNotSupported(const WebString& errorMessage) override; | 96 void requestNotSupported(const WebString& errorMessage) override; |
97 | 97 |
98 ScriptPromise promise() { return m_resolver->promise(); } | 98 ScriptPromise promise() { return m_resolver->promise(); } |
99 | 99 |
100 DEFINE_INLINE_VIRTUAL_TRACE() | 100 DEFINE_INLINE_VIRTUAL_TRACE() |
101 { | 101 { |
102 visitor->trace(m_resolver); | 102 visitor->trace(m_resolver); |
103 EncryptedMediaRequest::trace(visitor); | 103 EncryptedMediaRequest::trace(visitor); |
104 } | 104 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 if (hasEmptyRobustness) | 189 if (hasEmptyRobustness) |
190 break; | 190 break; |
191 } | 191 } |
192 | 192 |
193 if (hasVideoCapabilities) { | 193 if (hasVideoCapabilities) { |
194 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, emptyRobustnessHis
togram, new EnumerationHistogram("Media.EME.Widevine.VideoCapability.HasEmptyRob
ustness", 2)); | 194 DEFINE_THREAD_SAFE_STATIC_LOCAL(EnumerationHistogram, emptyRobustnessHis
togram, new EnumerationHistogram("Media.EME.Widevine.VideoCapability.HasEmptyRob
ustness", 2)); |
195 emptyRobustnessHistogram.count(hasEmptyRobustness); | 195 emptyRobustnessHistogram.count(hasEmptyRobustness); |
196 } | 196 } |
197 | 197 |
198 if (hasEmptyRobustness) { | 198 if (hasEmptyRobustness) { |
199 m_resolver->executionContext()->addConsoleMessage(ConsoleMessage::create
(JSMessageSource, WarningMessageLevel, | 199 m_resolver->getExecutionContext()->addConsoleMessage(ConsoleMessage::cre
ate(JSMessageSource, WarningMessageLevel, |
200 "It is recommended that a robustness level be specified. Not specify
ing the robustness level could " | 200 "It is recommended that a robustness level be specified. Not specify
ing the robustness level could " |
201 "result in unexpected behavior in the future, potentially including
failure to play.")); | 201 "result in unexpected behavior in the future, potentially including
failure to play.")); |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 } // namespace | 205 } // namespace |
206 | 206 |
207 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess( | 207 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess( |
208 ScriptState* scriptState, | 208 ScriptState* scriptState, |
209 Navigator& navigator, | 209 Navigator& navigator, |
(...skipping 13 matching lines...) Expand all Loading... |
223 | 223 |
224 // 2. If supportedConfigurations was provided and is empty, return a | 224 // 2. If supportedConfigurations was provided and is empty, return a |
225 // promise rejected with a new DOMException whose name is | 225 // promise rejected with a new DOMException whose name is |
226 // InvalidAccessError. | 226 // InvalidAccessError. |
227 if (!supportedConfigurations.size()) { | 227 if (!supportedConfigurations.size()) { |
228 return ScriptPromise::rejectWithDOMException( | 228 return ScriptPromise::rejectWithDOMException( |
229 scriptState, DOMException::create(InvalidAccessError, "The supported
Configurations parameter is empty.")); | 229 scriptState, DOMException::create(InvalidAccessError, "The supported
Configurations parameter is empty.")); |
230 } | 230 } |
231 | 231 |
232 // 3-4. 'May Document use powerful features?' check. | 232 // 3-4. 'May Document use powerful features?' check. |
233 ExecutionContext* executionContext = scriptState->executionContext(); | 233 ExecutionContext* executionContext = scriptState->getExecutionContext(); |
234 String errorMessage; | 234 String errorMessage; |
235 if (executionContext->isSecureContext(errorMessage)) { | 235 if (executionContext->isSecureContext(errorMessage)) { |
236 UseCounter::count(executionContext, UseCounter::EncryptedMediaSecureOrig
in); | 236 UseCounter::count(executionContext, UseCounter::EncryptedMediaSecureOrig
in); |
237 } else { | 237 } else { |
238 Deprecation::countDeprecation(executionContext, UseCounter::EncryptedMed
iaInsecureOrigin); | 238 Deprecation::countDeprecation(executionContext, UseCounter::EncryptedMed
iaInsecureOrigin); |
239 // TODO(ddorwin): Implement the following: | 239 // TODO(ddorwin): Implement the following: |
240 // Reject promise with a new DOMException whose name is NotSupportedErro
r. | 240 // Reject promise with a new DOMException whose name is NotSupportedErro
r. |
241 } | 241 } |
242 | 242 |
243 // 5. Let origin be the origin of document. | 243 // 5. Let origin be the origin of document. |
(...skipping 13 matching lines...) Expand all Loading... |
257 // initialize the MediaKeySystemAccess object. | 257 // initialize the MediaKeySystemAccess object. |
258 MediaKeysController* controller = MediaKeysController::from(document->page()
); | 258 MediaKeysController* controller = MediaKeysController::from(document->page()
); |
259 WebEncryptedMediaClient* mediaClient = controller->encryptedMediaClient(exec
utionContext); | 259 WebEncryptedMediaClient* mediaClient = controller->encryptedMediaClient(exec
utionContext); |
260 mediaClient->requestMediaKeySystemAccess(WebEncryptedMediaRequest(initialize
r)); | 260 mediaClient->requestMediaKeySystemAccess(WebEncryptedMediaRequest(initialize
r)); |
261 | 261 |
262 // 8. Return promise. | 262 // 8. Return promise. |
263 return promise; | 263 return promise; |
264 } | 264 } |
265 | 265 |
266 } // namespace blink | 266 } // namespace blink |
OLD | NEW |