| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 base::Callback<bool(void)> are_secure_codecs_supported_cb, |
| 81 CdmFactory* cdm_factory, | 82 CdmFactory* cdm_factory, |
| 82 MediaPermission* media_permission) | 83 MediaPermission* media_permission) |
| 83 : cdm_factory_(cdm_factory), | 84 : are_secure_codecs_supported_cb_(are_secure_codecs_supported_cb), |
| 85 cdm_factory_(cdm_factory), |
| 84 key_system_config_selector_(KeySystems::GetInstance(), media_permission), | 86 key_system_config_selector_(KeySystems::GetInstance(), media_permission), |
| 85 weak_factory_(this) { | 87 weak_factory_(this) { |
| 86 DCHECK(cdm_factory_); | 88 DCHECK(cdm_factory_); |
| 87 } | 89 } |
| 88 | 90 |
| 89 WebEncryptedMediaClientImpl::~WebEncryptedMediaClientImpl() { | 91 WebEncryptedMediaClientImpl::~WebEncryptedMediaClientImpl() { |
| 90 } | 92 } |
| 91 | 93 |
| 92 void WebEncryptedMediaClientImpl::requestMediaKeySystemAccess( | 94 void WebEncryptedMediaClientImpl::requestMediaKeySystemAccess( |
| 93 blink::WebEncryptedMediaRequest request) { | 95 blink::WebEncryptedMediaRequest request) { |
| 94 GetReporter(request.keySystem())->ReportRequested(); | 96 GetReporter(request.keySystem())->ReportRequested(); |
| 95 key_system_config_selector_.SelectConfig( | 97 key_system_config_selector_.SelectConfig( |
| 96 request.keySystem(), request.supportedConfigurations(), | 98 request.keySystem(), request.supportedConfigurations(), |
| 97 request.securityOrigin(), | 99 request.securityOrigin(), are_secure_codecs_supported_cb_.Run(), |
| 98 base::Bind(&WebEncryptedMediaClientImpl::OnRequestSucceeded, | 100 base::Bind(&WebEncryptedMediaClientImpl::OnRequestSucceeded, |
| 99 weak_factory_.GetWeakPtr(), request), | 101 weak_factory_.GetWeakPtr(), request), |
| 100 base::Bind(&WebEncryptedMediaClientImpl::OnRequestNotSupported, | 102 base::Bind(&WebEncryptedMediaClientImpl::OnRequestNotSupported, |
| 101 weak_factory_.GetWeakPtr(), request)); | 103 weak_factory_.GetWeakPtr(), request)); |
| 102 } | 104 } |
| 103 | 105 |
| 104 void WebEncryptedMediaClientImpl::CreateCdm( | 106 void WebEncryptedMediaClientImpl::CreateCdm( |
| 105 const blink::WebString& key_system, | 107 const blink::WebString& key_system, |
| 106 bool allow_distinctive_identifier, | 108 bool allow_distinctive_identifier, |
| 107 bool allow_persistent_state, | 109 bool allow_persistent_state, |
| 108 const blink::WebSecurityOrigin& security_origin, | 110 const blink::WebSecurityOrigin& security_origin, |
| 109 blink::WebContentDecryptionModuleResult result) { | 111 blink::WebContentDecryptionModuleResult result) { |
| 110 WebContentDecryptionModuleImpl::Create( | 112 WebContentDecryptionModuleImpl::Create( |
| 111 cdm_factory_, key_system, allow_distinctive_identifier, | 113 cdm_factory_, key_system, allow_distinctive_identifier, |
| 112 allow_persistent_state, security_origin, result); | 114 allow_persistent_state, security_origin, result); |
| 113 } | 115 } |
| 114 | 116 |
| 115 void WebEncryptedMediaClientImpl::OnRequestSucceeded( | 117 void WebEncryptedMediaClientImpl::OnRequestSucceeded( |
| 116 blink::WebEncryptedMediaRequest request, | 118 blink::WebEncryptedMediaRequest request, |
| 117 const blink::WebMediaKeySystemConfiguration& accumulated_configuration) { | 119 const blink::WebMediaKeySystemConfiguration& accumulated_configuration, |
| 120 bool are_secure_codecs_required) { |
| 118 GetReporter(request.keySystem())->ReportSupported(); | 121 GetReporter(request.keySystem())->ReportSupported(); |
| 122 // 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. |
| 119 request.requestSucceeded(WebContentDecryptionModuleAccessImpl::Create( | 124 request.requestSucceeded(WebContentDecryptionModuleAccessImpl::Create( |
| 120 request.keySystem(), accumulated_configuration, request.securityOrigin(), | 125 request.keySystem(), accumulated_configuration, request.securityOrigin(), |
| 121 weak_factory_.GetWeakPtr())); | 126 weak_factory_.GetWeakPtr())); |
| 122 } | 127 } |
| 123 | 128 |
| 124 void WebEncryptedMediaClientImpl::OnRequestNotSupported( | 129 void WebEncryptedMediaClientImpl::OnRequestNotSupported( |
| 125 blink::WebEncryptedMediaRequest request, | 130 blink::WebEncryptedMediaRequest request, |
| 126 const blink::WebString& error_message) { | 131 const blink::WebString& error_message) { |
| 127 request.requestNotSupported(error_message); | 132 request.requestNotSupported(error_message); |
| 128 } | 133 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 139 std::string uma_name = GetKeySystemNameForUMA(key_system_ascii); | 144 std::string uma_name = GetKeySystemNameForUMA(key_system_ascii); |
| 140 Reporter* reporter = reporters_.get(uma_name); | 145 Reporter* reporter = reporters_.get(uma_name); |
| 141 if (!reporter) { | 146 if (!reporter) { |
| 142 reporter = new Reporter(uma_name); | 147 reporter = new Reporter(uma_name); |
| 143 reporters_.add(uma_name, make_scoped_ptr(reporter)); | 148 reporters_.add(uma_name, make_scoped_ptr(reporter)); |
| 144 } | 149 } |
| 145 return reporter; | 150 return reporter; |
| 146 } | 151 } |
| 147 | 152 |
| 148 } // namespace media | 153 } // namespace media |
| OLD | NEW |