Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: third_party/WebKit/Source/modules/encryptedmedia/NavigatorRequestMediaKeySystemAccess.cpp

Issue 2342953002: Update EME errors to use TypeError (Closed)
Patch Set: changes Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "bindings/core/v8/V8ThrowException.h"
9 #include "core/dom/DOMException.h" 11 #include "core/dom/DOMException.h"
10 #include "core/dom/Document.h" 12 #include "core/dom/Document.h"
11 #include "core/dom/ExceptionCode.h" 13 #include "core/dom/ExceptionCode.h"
12 #include "core/frame/Deprecation.h" 14 #include "core/frame/Deprecation.h"
13 #include "core/inspector/ConsoleMessage.h" 15 #include "core/inspector/ConsoleMessage.h"
14 #include "modules/encryptedmedia/EncryptedMediaUtils.h" 16 #include "modules/encryptedmedia/EncryptedMediaUtils.h"
15 #include "modules/encryptedmedia/MediaKeySession.h" 17 #include "modules/encryptedmedia/MediaKeySession.h"
16 #include "modules/encryptedmedia/MediaKeySystemAccess.h" 18 #include "modules/encryptedmedia/MediaKeySystemAccess.h"
17 #include "modules/encryptedmedia/MediaKeysController.h" 19 #include "modules/encryptedmedia/MediaKeysController.h"
18 #include "platform/EncryptedMediaRequest.h" 20 #include "platform/EncryptedMediaRequest.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 307
306 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess( 308 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess(
307 ScriptState* scriptState, 309 ScriptState* scriptState,
308 Navigator& navigator, 310 Navigator& navigator,
309 const String& keySystem, 311 const String& keySystem,
310 const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations) { 312 const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations) {
311 DVLOG(3) << __func__; 313 DVLOG(3) << __func__;
312 314
313 // From https://w3c.github.io/encrypted-media/#requestMediaKeySystemAccess 315 // From https://w3c.github.io/encrypted-media/#requestMediaKeySystemAccess
314 // When this method is invoked, the user agent must run the following steps: 316 // When this method is invoked, the user agent must run the following steps:
315 // 1. If keySystem is an empty string, return a promise rejected with a 317 // 1. If keySystem is the empty string, return a promise rejected with a
316 // new DOMException whose name is InvalidAccessError. 318 // newly created TypeError.
317 if (keySystem.isEmpty()) { 319 if (keySystem.isEmpty()) {
318 return ScriptPromise::rejectWithDOMException( 320 return ScriptPromise::reject(
319 scriptState, DOMException::create(InvalidAccessError, 321 scriptState,
322 V8ThrowException::createTypeError(scriptState->isolate(),
320 "The keySystem parameter is empty.")); 323 "The keySystem parameter is empty."));
321 } 324 }
322 325
323 // 2. If supportedConfigurations was provided and is empty, return a 326 // 2. If supportedConfigurations is empty, return a promise rejected with
324 // promise rejected with a new DOMException whose name is 327 // a newly created TypeError.
325 // InvalidAccessError.
326 if (!supportedConfigurations.size()) { 328 if (!supportedConfigurations.size()) {
327 return ScriptPromise::rejectWithDOMException( 329 return ScriptPromise::reject(
328 scriptState, DOMException::create( 330 scriptState, V8ThrowException::createTypeError(
329 InvalidAccessError, 331 scriptState->isolate(),
330 "The supportedConfigurations parameter is empty.")); 332 "The supportedConfigurations parameter is empty."));
331 } 333 }
332 334
333 // Note: This method should only be exposed to secure contexts as indicated 335 // Note: This method should only be exposed to secure contexts as indicated
334 // by the [SecureContext] IDL attribute. Since that will break some existing 336 // by the [SecureContext] IDL attribute. Since that will break some existing
335 // sites, we simply keep track of sites that aren't secure and output a 337 // sites, we simply keep track of sites that aren't secure and output a
336 // deprecation message. 338 // deprecation message.
337 ExecutionContext* executionContext = scriptState->getExecutionContext(); 339 ExecutionContext* executionContext = scriptState->getExecutionContext();
338 String errorMessage; 340 String errorMessage;
339 if (executionContext->isSecureContext(errorMessage)) { 341 if (executionContext->isSecureContext(errorMessage)) {
(...skipping 30 matching lines...) Expand all
370 WebEncryptedMediaClient* mediaClient = 372 WebEncryptedMediaClient* mediaClient =
371 controller->encryptedMediaClient(executionContext); 373 controller->encryptedMediaClient(executionContext);
372 mediaClient->requestMediaKeySystemAccess( 374 mediaClient->requestMediaKeySystemAccess(
373 WebEncryptedMediaRequest(initializer)); 375 WebEncryptedMediaRequest(initializer));
374 376
375 // 7. Return promise. 377 // 7. Return promise.
376 return promise; 378 return promise;
377 } 379 }
378 380
379 } // namespace blink 381 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698