OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/cdm/json_web_key.h" | 5 #include "media/cdm/json_web_key.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 bool ExtractKeysFromJWKSet(const std::string& jwk_set, | 165 bool ExtractKeysFromJWKSet(const std::string& jwk_set, |
166 KeyIdAndKeyPairs* keys, | 166 KeyIdAndKeyPairs* keys, |
167 MediaKeys::SessionType* session_type) { | 167 MediaKeys::SessionType* session_type) { |
168 if (!base::IsStringASCII(jwk_set)) { | 168 if (!base::IsStringASCII(jwk_set)) { |
169 DVLOG(1) << "Non ASCII JWK Set: " << jwk_set; | 169 DVLOG(1) << "Non ASCII JWK Set: " << jwk_set; |
170 return false; | 170 return false; |
171 } | 171 } |
172 | 172 |
173 std::unique_ptr<base::Value> root(base::JSONReader().ReadToValue(jwk_set)); | 173 std::unique_ptr<base::Value> root(base::JSONReader().ReadToValue(jwk_set)); |
174 if (!root.get() || root->GetType() != base::Value::TYPE_DICTIONARY) { | 174 if (!root.get() || root->GetType() != base::Value::Type::DICTIONARY) { |
175 DVLOG(1) << "Not valid JSON: " << jwk_set << ", root: " << root.get(); | 175 DVLOG(1) << "Not valid JSON: " << jwk_set << ", root: " << root.get(); |
176 return false; | 176 return false; |
177 } | 177 } |
178 | 178 |
179 // Locate the set from the dictionary. | 179 // Locate the set from the dictionary. |
180 base::DictionaryValue* dictionary = | 180 base::DictionaryValue* dictionary = |
181 static_cast<base::DictionaryValue*>(root.get()); | 181 static_cast<base::DictionaryValue*>(root.get()); |
182 base::ListValue* list_val = NULL; | 182 base::ListValue* list_val = NULL; |
183 if (!dictionary->GetList(kKeysTag, &list_val)) { | 183 if (!dictionary->GetList(kKeysTag, &list_val)) { |
184 DVLOG(1) << "Missing '" << kKeysTag | 184 DVLOG(1) << "Missing '" << kKeysTag |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 bool ExtractKeyIdsFromKeyIdsInitData(const std::string& input, | 233 bool ExtractKeyIdsFromKeyIdsInitData(const std::string& input, |
234 KeyIdList* key_ids, | 234 KeyIdList* key_ids, |
235 std::string* error_message) { | 235 std::string* error_message) { |
236 if (!base::IsStringASCII(input)) { | 236 if (!base::IsStringASCII(input)) { |
237 error_message->assign("Non ASCII: "); | 237 error_message->assign("Non ASCII: "); |
238 error_message->append(ShortenTo64Characters(input)); | 238 error_message->append(ShortenTo64Characters(input)); |
239 return false; | 239 return false; |
240 } | 240 } |
241 | 241 |
242 std::unique_ptr<base::Value> root(base::JSONReader().ReadToValue(input)); | 242 std::unique_ptr<base::Value> root(base::JSONReader().ReadToValue(input)); |
243 if (!root.get() || root->GetType() != base::Value::TYPE_DICTIONARY) { | 243 if (!root.get() || root->GetType() != base::Value::Type::DICTIONARY) { |
244 error_message->assign("Not valid JSON: "); | 244 error_message->assign("Not valid JSON: "); |
245 error_message->append(ShortenTo64Characters(input)); | 245 error_message->append(ShortenTo64Characters(input)); |
246 return false; | 246 return false; |
247 } | 247 } |
248 | 248 |
249 // Locate the set from the dictionary. | 249 // Locate the set from the dictionary. |
250 base::DictionaryValue* dictionary = | 250 base::DictionaryValue* dictionary = |
251 static_cast<base::DictionaryValue*>(root.get()); | 251 static_cast<base::DictionaryValue*>(root.get()); |
252 base::ListValue* list_val = NULL; | 252 base::ListValue* list_val = NULL; |
253 if (!dictionary->GetList(kKeyIdsTag, &list_val)) { | 253 if (!dictionary->GetList(kKeyIdsTag, &list_val)) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 const std::string license_as_str( | 368 const std::string license_as_str( |
369 reinterpret_cast<const char*>(!license.empty() ? &license[0] : NULL), | 369 reinterpret_cast<const char*>(!license.empty() ? &license[0] : NULL), |
370 license.size()); | 370 license.size()); |
371 if (!base::IsStringASCII(license_as_str)) { | 371 if (!base::IsStringASCII(license_as_str)) { |
372 DVLOG(1) << "Non ASCII license: " << license_as_str; | 372 DVLOG(1) << "Non ASCII license: " << license_as_str; |
373 return false; | 373 return false; |
374 } | 374 } |
375 | 375 |
376 std::unique_ptr<base::Value> root( | 376 std::unique_ptr<base::Value> root( |
377 base::JSONReader().ReadToValue(license_as_str)); | 377 base::JSONReader().ReadToValue(license_as_str)); |
378 if (!root.get() || root->GetType() != base::Value::TYPE_DICTIONARY) { | 378 if (!root.get() || root->GetType() != base::Value::Type::DICTIONARY) { |
379 DVLOG(1) << "Not valid JSON: " << license_as_str; | 379 DVLOG(1) << "Not valid JSON: " << license_as_str; |
380 return false; | 380 return false; |
381 } | 381 } |
382 | 382 |
383 // Locate the set from the dictionary. | 383 // Locate the set from the dictionary. |
384 base::DictionaryValue* dictionary = | 384 base::DictionaryValue* dictionary = |
385 static_cast<base::DictionaryValue*>(root.get()); | 385 static_cast<base::DictionaryValue*>(root.get()); |
386 base::ListValue* list_val = NULL; | 386 base::ListValue* list_val = NULL; |
387 if (!dictionary->GetList(kKeyIdsTag, &list_val)) { | 387 if (!dictionary->GetList(kKeyIdsTag, &list_val)) { |
388 DVLOG(1) << "Missing '" << kKeyIdsTag << "' parameter or not a list"; | 388 DVLOG(1) << "Missing '" << kKeyIdsTag << "' parameter or not a list"; |
(...skipping 20 matching lines...) Expand all Loading... |
409 DVLOG(1) << "Invalid '" << kKeyIdsTag << "' value: " << encoded_key; | 409 DVLOG(1) << "Invalid '" << kKeyIdsTag << "' value: " << encoded_key; |
410 return false; | 410 return false; |
411 } | 411 } |
412 | 412 |
413 std::vector<uint8_t> result(decoded_string.begin(), decoded_string.end()); | 413 std::vector<uint8_t> result(decoded_string.begin(), decoded_string.end()); |
414 first_key->swap(result); | 414 first_key->swap(result); |
415 return true; | 415 return true; |
416 } | 416 } |
417 | 417 |
418 } // namespace media | 418 } // namespace media |
OLD | NEW |