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

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

Issue 2678433003: media: Require SecureContext for EME APIs (Closed)
Patch Set: Created 3 years, 10 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/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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 // 2. If supportedConfigurations is empty, return a promise rejected with 343 // 2. If supportedConfigurations is empty, return a promise rejected with
344 // a newly created TypeError. 344 // a newly created TypeError.
345 if (!supportedConfigurations.size()) { 345 if (!supportedConfigurations.size()) {
346 return ScriptPromise::reject( 346 return ScriptPromise::reject(
347 scriptState, V8ThrowException::createTypeError( 347 scriptState, V8ThrowException::createTypeError(
348 scriptState->isolate(), 348 scriptState->isolate(),
349 "The supportedConfigurations parameter is empty.")); 349 "The supportedConfigurations parameter is empty."));
350 } 350 }
351 351
352 // Note: This method should only be exposed to secure contexts as indicated 352 // 3. Let document be the calling context's Document.
353 // by the [SecureContext] IDL attribute. Since that will break some existing
354 // sites, we simply keep track of sites that aren't secure and output a
355 // deprecation message.
356 ExecutionContext* executionContext = scriptState->getExecutionContext(); 353 ExecutionContext* executionContext = scriptState->getExecutionContext();
357 if (executionContext->isSecureContext()) {
358 UseCounter::count(executionContext, UseCounter::EncryptedMediaSecureOrigin);
359 } else {
360 Deprecation::countDeprecation(executionContext,
361 UseCounter::EncryptedMediaInsecureOrigin);
362 // TODO(ddorwin): Implement the following:
363 // Reject promise with a new DOMException whose name is NotSupportedError.
364 }
365
366 // 3. Let document be the calling context's Document.
367 Document* document = toDocument(executionContext); 354 Document* document = toDocument(executionContext);
368 if (!document->page()) { 355 if (!document->page()) {
369 return ScriptPromise::rejectWithDOMException( 356 return ScriptPromise::rejectWithDOMException(
370 scriptState, 357 scriptState,
371 DOMException::create( 358 DOMException::create(
372 InvalidStateError, 359 InvalidStateError,
373 "The context provided is not associated with a page.")); 360 "The context provided is not associated with a page."));
374 } 361 }
375 362
376 // 4. Let origin be the origin of document. 363 // 4. Let origin be the origin of document.
(...skipping 11 matching lines...) Expand all
388 WebEncryptedMediaClient* mediaClient = 375 WebEncryptedMediaClient* mediaClient =
389 controller->encryptedMediaClient(executionContext); 376 controller->encryptedMediaClient(executionContext);
390 mediaClient->requestMediaKeySystemAccess( 377 mediaClient->requestMediaKeySystemAccess(
391 WebEncryptedMediaRequest(initializer)); 378 WebEncryptedMediaRequest(initializer));
392 379
393 // 7. Return promise. 380 // 7. Return promise.
394 return promise; 381 return promise;
395 } 382 }
396 383
397 } // namespace blink 384 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698