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

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

Issue 1124863005: Restrict use of hardware-secure codecs based on the RendererPreference. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@setsecurity
Patch Set: Rename secure_codec -> secure_surface in some cases. 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 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 "webencryptedmediaclient_impl.h" 5 #include "webencryptedmediaclient_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 KEY_SYSTEM_SUPPORT_STATUS_COUNT + 1, 71 KEY_SYSTEM_SUPPORT_STATUS_COUNT + 1,
72 base::Histogram::kUmaTargetedHistogramFlag)->Add(status); 72 base::Histogram::kUmaTargetedHistogramFlag)->Add(status);
73 } 73 }
74 74
75 const std::string uma_name_; 75 const std::string uma_name_;
76 bool is_request_reported_; 76 bool is_request_reported_;
77 bool is_support_reported_; 77 bool is_support_reported_;
78 }; 78 };
79 79
80 WebEncryptedMediaClientImpl::WebEncryptedMediaClientImpl( 80 WebEncryptedMediaClientImpl::WebEncryptedMediaClientImpl(
81 #if defined(OS_ANDROID)
82 base::Callback<bool(void)> allow_secure_surfaces_cb,
83 #endif // defined(OS_ANDROID)
81 CdmFactory* cdm_factory, 84 CdmFactory* cdm_factory,
82 MediaPermission* media_permission) 85 MediaPermission* media_permission)
83 : cdm_factory_(cdm_factory), 86 : cdm_factory_(cdm_factory),
84 key_system_config_selector_(KeySystems::GetInstance(), media_permission), 87 key_system_config_selector_(KeySystems::GetInstance(), media_permission),
85 weak_factory_(this) { 88 weak_factory_(this) {
86 DCHECK(cdm_factory_); 89 DCHECK(cdm_factory_);
90 #if defined(OS_ANDROID)
91 allow_secure_surfaces_cb_ = allow_secure_surfaces_cb;
92 #endif // defined(OS_ANDROID)
87 } 93 }
88 94
89 WebEncryptedMediaClientImpl::~WebEncryptedMediaClientImpl() { 95 WebEncryptedMediaClientImpl::~WebEncryptedMediaClientImpl() {
90 } 96 }
91 97
92 void WebEncryptedMediaClientImpl::requestMediaKeySystemAccess( 98 void WebEncryptedMediaClientImpl::requestMediaKeySystemAccess(
93 blink::WebEncryptedMediaRequest request) { 99 blink::WebEncryptedMediaRequest request) {
94 GetReporter(request.keySystem())->ReportRequested(); 100 GetReporter(request.keySystem())->ReportRequested();
95 key_system_config_selector_.SelectConfig( 101 key_system_config_selector_.SelectConfig(
96 request.keySystem(), request.supportedConfigurations(), 102 request.keySystem(),
97 request.securityOrigin(), 103 #if defined(OS_ANDROID)
104 allow_secure_surfaces_cb_.Run(),
105 #endif // defined(OS_ANDROID)
106 request.supportedConfigurations(), request.securityOrigin(),
98 base::Bind(&WebEncryptedMediaClientImpl::OnRequestSucceeded, 107 base::Bind(&WebEncryptedMediaClientImpl::OnRequestSucceeded,
99 weak_factory_.GetWeakPtr(), request), 108 weak_factory_.GetWeakPtr(), request),
100 base::Bind(&WebEncryptedMediaClientImpl::OnRequestNotSupported, 109 base::Bind(&WebEncryptedMediaClientImpl::OnRequestNotSupported,
101 weak_factory_.GetWeakPtr(), request)); 110 weak_factory_.GetWeakPtr(), request));
102 } 111 }
103 112
104 void WebEncryptedMediaClientImpl::CreateCdm( 113 void WebEncryptedMediaClientImpl::CreateCdm(
105 const blink::WebString& key_system, 114 const blink::WebString& key_system,
106 bool allow_distinctive_identifier, 115 bool allow_distinctive_identifier,
107 bool allow_persistent_state, 116 bool allow_persistent_state,
108 const blink::WebSecurityOrigin& security_origin, 117 const blink::WebSecurityOrigin& security_origin,
109 blink::WebContentDecryptionModuleResult result) { 118 blink::WebContentDecryptionModuleResult result) {
110 WebContentDecryptionModuleImpl::Create( 119 WebContentDecryptionModuleImpl::Create(
111 cdm_factory_, key_system, allow_distinctive_identifier, 120 cdm_factory_, key_system, allow_distinctive_identifier,
112 allow_persistent_state, security_origin, result); 121 allow_persistent_state, security_origin, result);
113 } 122 }
114 123
115 void WebEncryptedMediaClientImpl::OnRequestSucceeded( 124 void WebEncryptedMediaClientImpl::OnRequestSucceeded(
116 blink::WebEncryptedMediaRequest request, 125 blink::WebEncryptedMediaRequest request,
117 const blink::WebMediaKeySystemConfiguration& accumulated_configuration) { 126 const blink::WebMediaKeySystemConfiguration& accumulated_configuration,
127 #if defined(OS_ANDROID)
128 const bool require_secure_surfaces,
ddorwin 2015/05/06 02:17:12 no const
sandersd (OOO until July 31) 2015/05/08 00:37:42 Done.
129 #endif // defined(OS_ANDROID)
130 ) {
131 if (!request.allow_seure_surfaces)
132 DCHECK(!require_secure_surfaces);
118 GetReporter(request.keySystem())->ReportSupported(); 133 GetReporter(request.keySystem())->ReportSupported();
134 // TODO(sandersd): Pass |require_secure_surfaces| along and use it to
ddorwin 2015/05/06 02:17:12 Ideally, we would pass along something generic, su
sandersd (OOO until July 31) 2015/05/08 00:37:42 This is in the same category as |allow_persistent_
ddorwin 2015/05/08 03:18:31 We can infer those from the accumulated_configurat
sandersd (OOO until July 31) 2015/05/08 18:04:45 Yes, I am considering passing all three of those b
135 // configure the CDM security level on Android.
119 request.requestSucceeded(WebContentDecryptionModuleAccessImpl::Create( 136 request.requestSucceeded(WebContentDecryptionModuleAccessImpl::Create(
120 request.keySystem(), accumulated_configuration, request.securityOrigin(), 137 request.keySystem(), accumulated_configuration, request.securityOrigin(),
121 weak_factory_.GetWeakPtr())); 138 weak_factory_.GetWeakPtr()));
122 } 139 }
123 140
124 void WebEncryptedMediaClientImpl::OnRequestNotSupported( 141 void WebEncryptedMediaClientImpl::OnRequestNotSupported(
125 blink::WebEncryptedMediaRequest request, 142 blink::WebEncryptedMediaRequest request,
126 const blink::WebString& error_message) { 143 const blink::WebString& error_message) {
127 request.requestNotSupported(error_message); 144 request.requestNotSupported(error_message);
128 } 145 }
(...skipping 10 matching lines...) Expand all
139 std::string uma_name = GetKeySystemNameForUMA(key_system_ascii); 156 std::string uma_name = GetKeySystemNameForUMA(key_system_ascii);
140 Reporter* reporter = reporters_.get(uma_name); 157 Reporter* reporter = reporters_.get(uma_name);
141 if (!reporter) { 158 if (!reporter) {
142 reporter = new Reporter(uma_name); 159 reporter = new Reporter(uma_name);
143 reporters_.add(uma_name, make_scoped_ptr(reporter)); 160 reporters_.add(uma_name, make_scoped_ptr(reporter));
144 } 161 }
145 return reporter; 162 return reporter;
146 } 163 }
147 164
148 } // namespace media 165 } // namespace media
OLDNEW
« media/blink/key_system_config_selector.cc ('K') | « media/blink/webencryptedmediaclient_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698