| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 // 3. Let document be the calling context's Document. | 320 // 3. Let document be the calling context's Document. |
| 321 // (Done at the begining of this function.) | 321 // (Done at the begining of this function.) |
| 322 if (!document->GetPage()) { | 322 if (!document->GetPage()) { |
| 323 return ScriptPromise::RejectWithDOMException( | 323 return ScriptPromise::RejectWithDOMException( |
| 324 script_state, | 324 script_state, |
| 325 DOMException::Create( | 325 DOMException::Create( |
| 326 kInvalidStateError, | 326 kInvalidStateError, |
| 327 "The context provided is not associated with a page.")); | 327 "The context provided is not associated with a page.")); |
| 328 } | 328 } |
| 329 | 329 |
| 330 UseCounter::Count(*document, WebFeature::kRequestMediaKeySystemAccess); |
| 331 UseCounter::CountCrossOriginIframe( |
| 332 *document, WebFeature::kRequestMediaKeySystemAccessIframe); |
| 333 |
| 330 // 4. Let origin be the origin of document. | 334 // 4. Let origin be the origin of document. |
| 331 // (Passed with the execution context.) | 335 // (Passed with the execution context.) |
| 332 | 336 |
| 333 // 5. Let promise be a new promise. | 337 // 5. Let promise be a new promise. |
| 334 MediaKeySystemAccessInitializer* initializer = | 338 MediaKeySystemAccessInitializer* initializer = |
| 335 new MediaKeySystemAccessInitializer(script_state, key_system, | 339 new MediaKeySystemAccessInitializer(script_state, key_system, |
| 336 supported_configurations); | 340 supported_configurations); |
| 337 ScriptPromise promise = initializer->Promise(); | 341 ScriptPromise promise = initializer->Promise(); |
| 338 | 342 |
| 339 // 6. Asynchronously determine support, and if allowed, create and | 343 // 6. Asynchronously determine support, and if allowed, create and |
| 340 // initialize the MediaKeySystemAccess object. | 344 // initialize the MediaKeySystemAccess object. |
| 341 MediaKeysController* controller = | 345 MediaKeysController* controller = |
| 342 MediaKeysController::From(document->GetPage()); | 346 MediaKeysController::From(document->GetPage()); |
| 343 WebEncryptedMediaClient* media_client = | 347 WebEncryptedMediaClient* media_client = |
| 344 controller->EncryptedMediaClient(execution_context); | 348 controller->EncryptedMediaClient(execution_context); |
| 345 media_client->RequestMediaKeySystemAccess( | 349 media_client->RequestMediaKeySystemAccess( |
| 346 WebEncryptedMediaRequest(initializer)); | 350 WebEncryptedMediaRequest(initializer)); |
| 347 | 351 |
| 348 // 7. Return promise. | 352 // 7. Return promise. |
| 349 return promise; | 353 return promise; |
| 350 } | 354 } |
| 351 | 355 |
| 352 } // namespace blink | 356 } // namespace blink |
| OLD | NEW |