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/ScriptPromise.h" | 7 #include "bindings/core/v8/ScriptPromise.h" |
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 "bindings/core/v8/V8ThrowException.h" | 10 #include "bindings/core/v8/V8ThrowException.h" |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 317 |
318 // 2. If supportedConfigurations is empty, return a promise rejected with | 318 // 2. If supportedConfigurations is empty, return a promise rejected with |
319 // a newly created TypeError. | 319 // a newly created TypeError. |
320 if (!supportedConfigurations.size()) { | 320 if (!supportedConfigurations.size()) { |
321 return ScriptPromise::reject( | 321 return ScriptPromise::reject( |
322 scriptState, V8ThrowException::createTypeError( | 322 scriptState, V8ThrowException::createTypeError( |
323 scriptState->isolate(), | 323 scriptState->isolate(), |
324 "The supportedConfigurations parameter is empty.")); | 324 "The supportedConfigurations parameter is empty.")); |
325 } | 325 } |
326 | 326 |
327 // Note: This method should only be exposed to secure contexts as indicated | 327 // 3. Let document be the calling context's Document. |
328 // by the [SecureContext] IDL attribute. Since that will break some existing | |
329 // sites, we simply keep track of sites that aren't secure and output a | |
330 // deprecation message. | |
331 ExecutionContext* executionContext = scriptState->getExecutionContext(); | 328 ExecutionContext* executionContext = scriptState->getExecutionContext(); |
332 if (executionContext->isSecureContext()) { | |
333 UseCounter::count(executionContext, UseCounter::EncryptedMediaSecureOrigin); | |
334 } else { | |
335 Deprecation::countDeprecation(executionContext, | |
336 UseCounter::EncryptedMediaInsecureOrigin); | |
337 // TODO(ddorwin): Implement the following: | |
338 // Reject promise with a new DOMException whose name is NotSupportedError. | |
339 } | |
340 | |
341 // 3. Let document be the calling context's Document. | |
342 Document* document = toDocument(executionContext); | 329 Document* document = toDocument(executionContext); |
343 if (!document->page()) { | 330 if (!document->page()) { |
344 return ScriptPromise::rejectWithDOMException( | 331 return ScriptPromise::rejectWithDOMException( |
345 scriptState, | 332 scriptState, |
346 DOMException::create( | 333 DOMException::create( |
347 InvalidStateError, | 334 InvalidStateError, |
348 "The context provided is not associated with a page.")); | 335 "The context provided is not associated with a page.")); |
349 } | 336 } |
350 | 337 |
351 // 4. Let origin be the origin of document. | 338 // 4. Let origin be the origin of document. |
(...skipping 11 matching lines...) Expand all Loading... |
363 WebEncryptedMediaClient* mediaClient = | 350 WebEncryptedMediaClient* mediaClient = |
364 controller->encryptedMediaClient(executionContext); | 351 controller->encryptedMediaClient(executionContext); |
365 mediaClient->requestMediaKeySystemAccess( | 352 mediaClient->requestMediaKeySystemAccess( |
366 WebEncryptedMediaRequest(initializer)); | 353 WebEncryptedMediaRequest(initializer)); |
367 | 354 |
368 // 7. Return promise. | 355 // 7. Return promise. |
369 return promise; | 356 return promise; |
370 } | 357 } |
371 | 358 |
372 } // namespace blink | 359 } // namespace blink |
OLD | NEW |