| 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 "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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 request.keySystem(), request.supportedConfigurations(), | 98 request.keySystem(), request.supportedConfigurations(), |
| 99 request.securityOrigin(), are_secure_codecs_supported_cb_.Run(), | 99 request.securityOrigin(), are_secure_codecs_supported_cb_.Run(), |
| 100 base::Bind(&WebEncryptedMediaClientImpl::OnRequestSucceeded, | 100 base::Bind(&WebEncryptedMediaClientImpl::OnRequestSucceeded, |
| 101 weak_factory_.GetWeakPtr(), request), | 101 weak_factory_.GetWeakPtr(), request), |
| 102 base::Bind(&WebEncryptedMediaClientImpl::OnRequestNotSupported, | 102 base::Bind(&WebEncryptedMediaClientImpl::OnRequestNotSupported, |
| 103 weak_factory_.GetWeakPtr(), request)); | 103 weak_factory_.GetWeakPtr(), request)); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void WebEncryptedMediaClientImpl::CreateCdm( | 106 void WebEncryptedMediaClientImpl::CreateCdm( |
| 107 const blink::WebString& key_system, | 107 const blink::WebString& key_system, |
| 108 bool allow_distinctive_identifier, | |
| 109 bool allow_persistent_state, | |
| 110 const blink::WebSecurityOrigin& security_origin, | 108 const blink::WebSecurityOrigin& security_origin, |
| 109 const CdmConfig& cdm_config, |
| 111 blink::WebContentDecryptionModuleResult result) { | 110 blink::WebContentDecryptionModuleResult result) { |
| 112 WebContentDecryptionModuleImpl::Create( | 111 WebContentDecryptionModuleImpl::Create( |
| 113 cdm_factory_, key_system, allow_distinctive_identifier, | 112 cdm_factory_, key_system, security_origin, cdm_config, result); |
| 114 allow_persistent_state, security_origin, result); | |
| 115 } | 113 } |
| 116 | 114 |
| 117 void WebEncryptedMediaClientImpl::OnRequestSucceeded( | 115 void WebEncryptedMediaClientImpl::OnRequestSucceeded( |
| 118 blink::WebEncryptedMediaRequest request, | 116 blink::WebEncryptedMediaRequest request, |
| 119 const blink::WebMediaKeySystemConfiguration& accumulated_configuration, | 117 const blink::WebMediaKeySystemConfiguration& accumulated_configuration, |
| 120 bool are_secure_codecs_required) { | 118 const CdmConfig& cdm_config) { |
| 121 GetReporter(request.keySystem())->ReportSupported(); | 119 GetReporter(request.keySystem())->ReportSupported(); |
| 122 // TODO(sandersd): Pass |are_secure_codecs_required| along and use it to | 120 // TODO(sandersd): Pass |are_secure_codecs_required| along and use it to |
| 123 // configure the CDM security level and use of secure surfaces on Android. | 121 // configure the CDM security level and use of secure surfaces on Android. |
| 124 request.requestSucceeded(WebContentDecryptionModuleAccessImpl::Create( | 122 request.requestSucceeded(WebContentDecryptionModuleAccessImpl::Create( |
| 125 request.keySystem(), accumulated_configuration, request.securityOrigin(), | 123 request.keySystem(), request.securityOrigin(), accumulated_configuration, |
| 126 weak_factory_.GetWeakPtr())); | 124 cdm_config, weak_factory_.GetWeakPtr())); |
| 127 } | 125 } |
| 128 | 126 |
| 129 void WebEncryptedMediaClientImpl::OnRequestNotSupported( | 127 void WebEncryptedMediaClientImpl::OnRequestNotSupported( |
| 130 blink::WebEncryptedMediaRequest request, | 128 blink::WebEncryptedMediaRequest request, |
| 131 const blink::WebString& error_message) { | 129 const blink::WebString& error_message) { |
| 132 request.requestNotSupported(error_message); | 130 request.requestNotSupported(error_message); |
| 133 } | 131 } |
| 134 | 132 |
| 135 WebEncryptedMediaClientImpl::Reporter* WebEncryptedMediaClientImpl::GetReporter( | 133 WebEncryptedMediaClientImpl::Reporter* WebEncryptedMediaClientImpl::GetReporter( |
| 136 const blink::WebString& key_system) { | 134 const blink::WebString& key_system) { |
| 137 // Assumes that empty will not be found by GetKeySystemNameForUMA(). | 135 // Assumes that empty will not be found by GetKeySystemNameForUMA(). |
| 138 // TODO(sandersd): Avoid doing ASCII conversion more than once. | 136 // TODO(sandersd): Avoid doing ASCII conversion more than once. |
| 139 std::string key_system_ascii; | 137 std::string key_system_ascii; |
| 140 if (base::IsStringASCII(key_system)) | 138 if (base::IsStringASCII(key_system)) |
| 141 key_system_ascii = base::UTF16ToASCII(key_system); | 139 key_system_ascii = base::UTF16ToASCII(key_system); |
| 142 | 140 |
| 143 // Return a per-frame singleton so that UMA reports will be once-per-frame. | 141 // Return a per-frame singleton so that UMA reports will be once-per-frame. |
| 144 std::string uma_name = GetKeySystemNameForUMA(key_system_ascii); | 142 std::string uma_name = GetKeySystemNameForUMA(key_system_ascii); |
| 145 Reporter* reporter = reporters_.get(uma_name); | 143 Reporter* reporter = reporters_.get(uma_name); |
| 146 if (!reporter) { | 144 if (!reporter) { |
| 147 reporter = new Reporter(uma_name); | 145 reporter = new Reporter(uma_name); |
| 148 reporters_.add(uma_name, make_scoped_ptr(reporter)); | 146 reporters_.add(uma_name, make_scoped_ptr(reporter)); |
| 149 } | 147 } |
| 150 return reporter; | 148 return reporter; |
| 151 } | 149 } |
| 152 | 150 |
| 153 } // namespace media | 151 } // namespace media |
| OLD | NEW |