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

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

Issue 2342953002: Update EME errors to use TypeError (Closed)
Patch Set: Created 4 years, 3 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/V8Binding.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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess( 249 ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess(
248 ScriptState* scriptState, 250 ScriptState* scriptState,
249 Navigator& navigator, 251 Navigator& navigator,
250 const String& keySystem, 252 const String& keySystem,
251 const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations) 253 const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations)
252 { 254 {
253 DVLOG(3) << __func__; 255 DVLOG(3) << __func__;
254 256
255 // From https://w3c.github.io/encrypted-media/#requestMediaKeySystemAccess 257 // From https://w3c.github.io/encrypted-media/#requestMediaKeySystemAccess
256 // When this method is invoked, the user agent must run the following steps: 258 // When this method is invoked, the user agent must run the following steps:
257 // 1. If keySystem is an empty string, return a promise rejected with a 259 // 1. If keySystem is the empty string, return a promise rejected with a
258 // new DOMException whose name is InvalidAccessError. 260 // newly created TypeError.
259 if (keySystem.isEmpty()) { 261 if (keySystem.isEmpty()) {
260 return ScriptPromise::rejectWithDOMException( 262 return ScriptPromise::reject(
261 scriptState, DOMException::create(InvalidAccessError, "The keySystem parameter is empty.")); 263 scriptState, v8::Exception::TypeError(v8String(scriptState->isolate( ), "The keySystem parameter is empty.")));
262 } 264 }
263 265
264 // 2. If supportedConfigurations was provided and is empty, return a 266 // 2. If supportedConfigurations is empty, return a promise rejected with
265 // promise rejected with a new DOMException whose name is 267 // a newly created TypeError.
266 // InvalidAccessError.
267 if (!supportedConfigurations.size()) { 268 if (!supportedConfigurations.size()) {
268 return ScriptPromise::rejectWithDOMException( 269 return ScriptPromise::reject(
269 scriptState, DOMException::create(InvalidAccessError, "The supported Configurations parameter is empty.")); 270 scriptState, v8::Exception::TypeError(v8String(scriptState->isolate( ), "The supportedConfigurations parameter is empty.")));
270 } 271 }
271 272
272 // 3-4. 'May Document use powerful features?' check. 273 // 3-4. 'May Document use powerful features?' check.
273 ExecutionContext* executionContext = scriptState->getExecutionContext(); 274 ExecutionContext* executionContext = scriptState->getExecutionContext();
274 String errorMessage; 275 String errorMessage;
275 if (executionContext->isSecureContext(errorMessage)) { 276 if (executionContext->isSecureContext(errorMessage)) {
276 UseCounter::count(executionContext, UseCounter::EncryptedMediaSecureOrig in); 277 UseCounter::count(executionContext, UseCounter::EncryptedMediaSecureOrig in);
277 } else { 278 } else {
278 Deprecation::countDeprecation(executionContext, UseCounter::EncryptedMed iaInsecureOrigin); 279 Deprecation::countDeprecation(executionContext, UseCounter::EncryptedMed iaInsecureOrigin);
279 // TODO(ddorwin): Implement the following: 280 // TODO(ddorwin): Implement the following:
(...skipping 17 matching lines...) Expand all
297 // initialize the MediaKeySystemAccess object. 298 // initialize the MediaKeySystemAccess object.
298 MediaKeysController* controller = MediaKeysController::from(document->page() ); 299 MediaKeysController* controller = MediaKeysController::from(document->page() );
299 WebEncryptedMediaClient* mediaClient = controller->encryptedMediaClient(exec utionContext); 300 WebEncryptedMediaClient* mediaClient = controller->encryptedMediaClient(exec utionContext);
300 mediaClient->requestMediaKeySystemAccess(WebEncryptedMediaRequest(initialize r)); 301 mediaClient->requestMediaKeySystemAccess(WebEncryptedMediaRequest(initialize r));
301 302
302 // 8. Return promise. 303 // 8. Return promise.
303 return promise; 304 return promise;
304 } 305 }
305 306
306 } // namespace blink 307 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698