| OLD | NEW |
| 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 "media/blink/webencryptedmediaclient_impl.h" | 5 #include "media/blink/webencryptedmediaclient_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 WebEncryptedMediaClientImpl::~WebEncryptedMediaClientImpl() { | 96 WebEncryptedMediaClientImpl::~WebEncryptedMediaClientImpl() { |
| 97 } | 97 } |
| 98 | 98 |
| 99 void WebEncryptedMediaClientImpl::requestMediaKeySystemAccess( | 99 void WebEncryptedMediaClientImpl::requestMediaKeySystemAccess( |
| 100 blink::WebEncryptedMediaRequest request) { | 100 blink::WebEncryptedMediaRequest request) { |
| 101 GetReporter(request.keySystem())->ReportRequested(); | 101 GetReporter(request.keySystem())->ReportRequested(); |
| 102 | 102 |
| 103 if (GetMediaClient()) { | 103 if (GetMediaClient()) { |
| 104 GURL security_origin( | 104 GURL security_origin( |
| 105 blink::WebStringToGURL(request.securityOrigin().toString())); | 105 blink::WebStringToGURL(request.getSecurityOrigin().toString())); |
| 106 | 106 |
| 107 GetMediaClient()->RecordRapporURL("Media.OriginUrl.EME", security_origin); | 107 GetMediaClient()->RecordRapporURL("Media.OriginUrl.EME", security_origin); |
| 108 | 108 |
| 109 blink::WebString error_message; | 109 blink::WebString error_message; |
| 110 if (!request.securityOrigin().isPotentiallyTrustworthy(error_message)) { | 110 if (!request.getSecurityOrigin().isPotentiallyTrustworthy(error_message)) { |
| 111 GetMediaClient()->RecordRapporURL("Media.OriginUrl.EME.Insecure", | 111 GetMediaClient()->RecordRapporURL("Media.OriginUrl.EME.Insecure", |
| 112 security_origin); | 112 security_origin); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 key_system_config_selector_.SelectConfig( | 116 key_system_config_selector_.SelectConfig( |
| 117 request.keySystem(), request.supportedConfigurations(), | 117 request.keySystem(), request.supportedConfigurations(), |
| 118 request.securityOrigin(), are_secure_codecs_supported_cb_.Run(), | 118 request.getSecurityOrigin(), are_secure_codecs_supported_cb_.Run(), |
| 119 base::Bind(&WebEncryptedMediaClientImpl::OnRequestSucceeded, | 119 base::Bind(&WebEncryptedMediaClientImpl::OnRequestSucceeded, |
| 120 weak_factory_.GetWeakPtr(), request), | 120 weak_factory_.GetWeakPtr(), request), |
| 121 base::Bind(&WebEncryptedMediaClientImpl::OnRequestNotSupported, | 121 base::Bind(&WebEncryptedMediaClientImpl::OnRequestNotSupported, |
| 122 weak_factory_.GetWeakPtr(), request)); | 122 weak_factory_.GetWeakPtr(), request)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void WebEncryptedMediaClientImpl::CreateCdm( | 125 void WebEncryptedMediaClientImpl::CreateCdm( |
| 126 const blink::WebString& key_system, | 126 const blink::WebString& key_system, |
| 127 const blink::WebSecurityOrigin& security_origin, | 127 const blink::WebSecurityOrigin& security_origin, |
| 128 const CdmConfig& cdm_config, | 128 const CdmConfig& cdm_config, |
| 129 scoped_ptr<blink::WebContentDecryptionModuleResult> result) { | 129 scoped_ptr<blink::WebContentDecryptionModuleResult> result) { |
| 130 WebContentDecryptionModuleImpl::Create( | 130 WebContentDecryptionModuleImpl::Create( |
| 131 cdm_factory_, key_system, security_origin, cdm_config, std::move(result)); | 131 cdm_factory_, key_system, security_origin, cdm_config, std::move(result)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void WebEncryptedMediaClientImpl::OnRequestSucceeded( | 134 void WebEncryptedMediaClientImpl::OnRequestSucceeded( |
| 135 blink::WebEncryptedMediaRequest request, | 135 blink::WebEncryptedMediaRequest request, |
| 136 const blink::WebMediaKeySystemConfiguration& accumulated_configuration, | 136 const blink::WebMediaKeySystemConfiguration& accumulated_configuration, |
| 137 const CdmConfig& cdm_config) { | 137 const CdmConfig& cdm_config) { |
| 138 GetReporter(request.keySystem())->ReportSupported(); | 138 GetReporter(request.keySystem())->ReportSupported(); |
| 139 // TODO(sandersd): Pass |are_secure_codecs_required| along and use it to | 139 // TODO(sandersd): Pass |are_secure_codecs_required| along and use it to |
| 140 // configure the CDM security level and use of secure surfaces on Android. | 140 // configure the CDM security level and use of secure surfaces on Android. |
| 141 request.requestSucceeded(WebContentDecryptionModuleAccessImpl::Create( | 141 request.requestSucceeded(WebContentDecryptionModuleAccessImpl::Create( |
| 142 request.keySystem(), request.securityOrigin(), accumulated_configuration, | 142 request.keySystem(), request.getSecurityOrigin(), |
| 143 cdm_config, weak_factory_.GetWeakPtr())); | 143 accumulated_configuration, cdm_config, weak_factory_.GetWeakPtr())); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void WebEncryptedMediaClientImpl::OnRequestNotSupported( | 146 void WebEncryptedMediaClientImpl::OnRequestNotSupported( |
| 147 blink::WebEncryptedMediaRequest request, | 147 blink::WebEncryptedMediaRequest request, |
| 148 const blink::WebString& error_message) { | 148 const blink::WebString& error_message) { |
| 149 request.requestNotSupported(error_message); | 149 request.requestNotSupported(error_message); |
| 150 } | 150 } |
| 151 | 151 |
| 152 WebEncryptedMediaClientImpl::Reporter* WebEncryptedMediaClientImpl::GetReporter( | 152 WebEncryptedMediaClientImpl::Reporter* WebEncryptedMediaClientImpl::GetReporter( |
| 153 const blink::WebString& key_system) { | 153 const blink::WebString& key_system) { |
| 154 // Assumes that empty will not be found by GetKeySystemNameForUMA(). | 154 // Assumes that empty will not be found by GetKeySystemNameForUMA(). |
| 155 // TODO(sandersd): Avoid doing ASCII conversion more than once. | 155 // TODO(sandersd): Avoid doing ASCII conversion more than once. |
| 156 std::string key_system_ascii; | 156 std::string key_system_ascii; |
| 157 if (base::IsStringASCII(key_system)) | 157 if (base::IsStringASCII(key_system)) |
| 158 key_system_ascii = base::UTF16ToASCII(base::StringPiece16(key_system)); | 158 key_system_ascii = base::UTF16ToASCII(base::StringPiece16(key_system)); |
| 159 | 159 |
| 160 // Return a per-frame singleton so that UMA reports will be once-per-frame. | 160 // Return a per-frame singleton so that UMA reports will be once-per-frame. |
| 161 std::string uma_name = GetKeySystemNameForUMA(key_system_ascii); | 161 std::string uma_name = GetKeySystemNameForUMA(key_system_ascii); |
| 162 Reporter* reporter = reporters_.get(uma_name); | 162 Reporter* reporter = reporters_.get(uma_name); |
| 163 if (!reporter) { | 163 if (!reporter) { |
| 164 reporter = new Reporter(uma_name); | 164 reporter = new Reporter(uma_name); |
| 165 reporters_.add(uma_name, make_scoped_ptr(reporter)); | 165 reporters_.add(uma_name, make_scoped_ptr(reporter)); |
| 166 } | 166 } |
| 167 return reporter; | 167 return reporter; |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace media | 170 } // namespace media |
| OLD | NEW |