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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "media/base/key_systems.h" | 10 #include "media/base/key_systems.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 return; | 153 return; |
154 } | 154 } |
155 | 155 |
156 std::string key_system = base::UTF16ToASCII(request.keySystem()); | 156 std::string key_system = base::UTF16ToASCII(request.keySystem()); |
157 if (!IsConcreteSupportedKeySystem(key_system)) { | 157 if (!IsConcreteSupportedKeySystem(key_system)) { |
158 request.requestNotSupported("Unsupported keySystem"); | 158 request.requestNotSupported("Unsupported keySystem"); |
159 return; | 159 return; |
160 } | 160 } |
161 | 161 |
162 // 7.2 Let implementation be the implementation of keySystem. | 162 // 7.2 Let implementation be the implementation of keySystem. |
163 // 7.3 Follow the steps for the first matching condition from the following | 163 // 7.3 For each value in supportedConfigurations, run the GetSupported |
164 // list: | 164 // Configuration algorithm and if successful, resolve promise with access |
165 // - If supportedConfigurations was not provided, run the Is Key System | 165 // and abort these steps. |
166 // Supported? algorithm and if successful, resolve promise with access | |
167 // and abort these steps. | |
168 // TODO(sandersd): Remove pending the resolution of | |
169 // https://github.com/w3c/encrypted-media/issues/1. | |
170 const blink::WebVector<blink::WebMediaKeySystemConfiguration>& | 166 const blink::WebVector<blink::WebMediaKeySystemConfiguration>& |
171 configurations = request.supportedConfigurations(); | 167 configurations = request.supportedConfigurations(); |
| 168 |
| 169 // TODO(sandersd): Remove once Blink requires the configurations parameter for |
| 170 // requestMediaKeySystemAccess(). |
172 if (configurations.isEmpty()) { | 171 if (configurations.isEmpty()) { |
173 request.requestSucceeded(WebContentDecryptionModuleAccessImpl::Create( | 172 request.requestSucceeded(WebContentDecryptionModuleAccessImpl::Create( |
174 request.keySystem(), request.securityOrigin(), cdm_factory_.get())); | 173 request.keySystem(), blink::WebMediaKeySystemConfiguration(), |
| 174 request.securityOrigin(), cdm_factory_.get())); |
175 return; | 175 return; |
176 } | 176 } |
177 | 177 |
178 // - Otherwise, for each value in supportedConfigurations, run the | |
179 // GetSuppored Configuration algorithm and if successful, resolve | |
180 // promise with access and abort these steps. | |
181 for (size_t i = 0; i < configurations.size(); i++) { | 178 for (size_t i = 0; i < configurations.size(); i++) { |
182 const blink::WebMediaKeySystemConfiguration& candidate = configurations[i]; | 179 const blink::WebMediaKeySystemConfiguration& candidate = configurations[i]; |
183 blink::WebMediaKeySystemConfiguration accumulated_configuration; | 180 blink::WebMediaKeySystemConfiguration accumulated_configuration; |
184 if (GetSupportedConfiguration(key_system, candidate, | 181 if (GetSupportedConfiguration(key_system, candidate, |
185 request.securityOrigin(), | 182 request.securityOrigin(), |
186 &accumulated_configuration)) { | 183 &accumulated_configuration)) { |
187 // TODO(sandersd): Pass the accumulated configuration along. | |
188 // http://crbug.com/447059. | |
189 request.requestSucceeded(WebContentDecryptionModuleAccessImpl::Create( | 184 request.requestSucceeded(WebContentDecryptionModuleAccessImpl::Create( |
190 request.keySystem(), request.securityOrigin(), cdm_factory_.get())); | 185 request.keySystem(), accumulated_configuration, |
| 186 request.securityOrigin(), cdm_factory_.get())); |
191 return; | 187 return; |
192 } | 188 } |
193 } | 189 } |
194 | 190 |
195 // 7.4 Reject promise with a new DOMException whose name is NotSupportedError. | 191 // 7.4 Reject promise with a new DOMException whose name is NotSupportedError. |
196 request.requestNotSupported( | 192 request.requestNotSupported( |
197 "None of the requested configurations were supported."); | 193 "None of the requested configurations were supported."); |
198 } | 194 } |
199 | 195 |
200 } // namespace media | 196 } // namespace media |
OLD | NEW |