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

Side by Side Diff: media/blink/webcontentdecryptionmoduleaccess_impl.cc

Issue 1131753003: Plumb |use_secure_codecs| through to BrowserCdmFactoryAndroid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "media/blink/webcontentdecryptionmoduleaccess_impl.h" 5 #include "media/blink/webcontentdecryptionmoduleaccess_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
11 #include "media/blink/webencryptedmediaclient_impl.h" 11 #include "media/blink/webencryptedmediaclient_impl.h"
12 12
13 namespace media { 13 namespace media {
14 14
15 // The caller owns the created cdm (passed back using |result|). 15 // The caller owns the created cdm (passed back using |result|).
16 static void CreateCdm(const base::WeakPtr<WebEncryptedMediaClientImpl>& client, 16 static void CreateCdm(const base::WeakPtr<WebEncryptedMediaClientImpl>& client,
17 const blink::WebString& key_system, 17 const blink::WebString& key_system,
18 bool allow_distinctive_identifier,
19 bool allow_persistent_state,
20 const blink::WebSecurityOrigin& security_origin, 18 const blink::WebSecurityOrigin& security_origin,
19 const CdmConfig& cdm_config,
21 blink::WebContentDecryptionModuleResult result) { 20 blink::WebContentDecryptionModuleResult result) {
22 // If |client| is gone (due to the frame getting destroyed), it is 21 // If |client| is gone (due to the frame getting destroyed), it is
23 // impossible to create the CDM, so fail. 22 // impossible to create the CDM, so fail.
24 if (!client) { 23 if (!client) {
25 result.completeWithError( 24 result.completeWithError(
26 blink::WebContentDecryptionModuleExceptionInvalidStateError, 0, 25 blink::WebContentDecryptionModuleExceptionInvalidStateError, 0,
27 "Failed to create CDM."); 26 "Failed to create CDM.");
28 return; 27 return;
29 } 28 }
30 29
31 client->CreateCdm(key_system, allow_distinctive_identifier, 30 client->CreateCdm(key_system, security_origin, cdm_config, result);
32 allow_persistent_state, security_origin, result);
33 } 31 }
34 32
35 WebContentDecryptionModuleAccessImpl* 33 WebContentDecryptionModuleAccessImpl*
36 WebContentDecryptionModuleAccessImpl::Create( 34 WebContentDecryptionModuleAccessImpl::Create(
37 const blink::WebString& key_system, 35 const blink::WebString& key_system,
36 const blink::WebSecurityOrigin& security_origin,
38 const blink::WebMediaKeySystemConfiguration& configuration, 37 const blink::WebMediaKeySystemConfiguration& configuration,
39 const blink::WebSecurityOrigin& security_origin, 38 const CdmConfig& cdm_config,
40 const base::WeakPtr<WebEncryptedMediaClientImpl>& client) { 39 const base::WeakPtr<WebEncryptedMediaClientImpl>& client) {
41 return new WebContentDecryptionModuleAccessImpl(key_system, configuration, 40 return new WebContentDecryptionModuleAccessImpl(
42 security_origin, client); 41 key_system, security_origin, configuration, cdm_config, client);
43 } 42 }
44 43
45 WebContentDecryptionModuleAccessImpl::WebContentDecryptionModuleAccessImpl( 44 WebContentDecryptionModuleAccessImpl::WebContentDecryptionModuleAccessImpl(
46 const blink::WebString& key_system, 45 const blink::WebString& key_system,
46 const blink::WebSecurityOrigin& security_origin,
47 const blink::WebMediaKeySystemConfiguration& configuration, 47 const blink::WebMediaKeySystemConfiguration& configuration,
48 const blink::WebSecurityOrigin& security_origin, 48 const CdmConfig& cdm_config,
49 const base::WeakPtr<WebEncryptedMediaClientImpl>& client) 49 const base::WeakPtr<WebEncryptedMediaClientImpl>& client)
50 : key_system_(key_system), 50 : key_system_(key_system),
51 security_origin_(security_origin),
51 configuration_(configuration), 52 configuration_(configuration),
52 security_origin_(security_origin), 53 cdm_config_(cdm_config),
53 client_(client) { 54 client_(client) {
54 } 55 }
55 56
56 WebContentDecryptionModuleAccessImpl::~WebContentDecryptionModuleAccessImpl() { 57 WebContentDecryptionModuleAccessImpl::~WebContentDecryptionModuleAccessImpl() {
57 } 58 }
58 59
59 blink::WebMediaKeySystemConfiguration 60 blink::WebMediaKeySystemConfiguration
60 WebContentDecryptionModuleAccessImpl::getConfiguration() { 61 WebContentDecryptionModuleAccessImpl::getConfiguration() {
61 return configuration_; 62 return configuration_;
62 } 63 }
63 64
64 void WebContentDecryptionModuleAccessImpl::createContentDecryptionModule( 65 void WebContentDecryptionModuleAccessImpl::createContentDecryptionModule(
65 blink::WebContentDecryptionModuleResult result) { 66 blink::WebContentDecryptionModuleResult result) {
66 // Convert the accumulated configuration requirements to bools. Accumulated
67 // configurations never have optional requirements.
68 DCHECK(configuration_.distinctiveIdentifier !=
69 blink::WebMediaKeySystemConfiguration::Requirement::Optional);
70 DCHECK(configuration_.persistentState !=
71 blink::WebMediaKeySystemConfiguration::Requirement::Optional);
72 bool allow_distinctive_identifier =
73 (configuration_.distinctiveIdentifier ==
74 blink::WebMediaKeySystemConfiguration::Requirement::Required);
75 bool allow_persistent_state =
76 (configuration_.persistentState ==
77 blink::WebMediaKeySystemConfiguration::Requirement::Required);
78
79 // This method needs to run asynchronously, as it may need to load the CDM. 67 // This method needs to run asynchronously, as it may need to load the CDM.
80 // As this object's lifetime is controlled by MediaKeySystemAccess on the 68 // As this object's lifetime is controlled by MediaKeySystemAccess on the
81 // blink side, copy all values needed by CreateCdm() in case the blink object 69 // blink side, copy all values needed by CreateCdm() in case the blink object
82 // gets garbage-collected. 70 // gets garbage-collected.
83 base::ThreadTaskRunnerHandle::Get()->PostTask( 71 base::ThreadTaskRunnerHandle::Get()->PostTask(
84 FROM_HERE, 72 FROM_HERE,
85 base::Bind(&CreateCdm, client_, key_system_, allow_distinctive_identifier, 73 base::Bind(&CreateCdm, client_, key_system_, security_origin_,
86 allow_persistent_state, security_origin_, result)); 74 cdm_config_, result));
87 } 75 }
88 76
89 } // namespace media 77 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698