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 "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 DVLOG(1) << "Invalid '" << kKeyTag << "' value: " << encoded_key; | 114 DVLOG(1) << "Invalid '" << kKeyTag << "' value: " << encoded_key; |
115 return false; | 115 return false; |
116 } | 116 } |
117 | 117 |
118 // Add the decoded key ID and the decoded key to the list. | 118 // Add the decoded key ID and the decoded key to the list. |
119 *jwk_key = std::make_pair(raw_key_id, raw_key); | 119 *jwk_key = std::make_pair(raw_key_id, raw_key); |
120 return true; | 120 return true; |
121 } | 121 } |
122 | 122 |
123 bool ExtractKeysFromJWKSet(const std::string& jwk_set, KeyIdAndKeyPairs* keys) { | 123 bool ExtractKeysFromJWKSet(const std::string& jwk_set, KeyIdAndKeyPairs* keys) { |
124 if (!IsStringASCII(jwk_set)) | 124 if (!base::IsStringASCII(jwk_set)) |
125 return false; | 125 return false; |
126 | 126 |
127 scoped_ptr<base::Value> root(base::JSONReader().ReadToValue(jwk_set)); | 127 scoped_ptr<base::Value> root(base::JSONReader().ReadToValue(jwk_set)); |
128 if (!root.get() || root->GetType() != base::Value::TYPE_DICTIONARY) | 128 if (!root.get() || root->GetType() != base::Value::TYPE_DICTIONARY) |
129 return false; | 129 return false; |
130 | 130 |
131 // Locate the set from the dictionary. | 131 // Locate the set from the dictionary. |
132 base::DictionaryValue* dictionary = | 132 base::DictionaryValue* dictionary = |
133 static_cast<base::DictionaryValue*>(root.get()); | 133 static_cast<base::DictionaryValue*>(root.get()); |
134 base::ListValue* list_val = NULL; | 134 base::ListValue* list_val = NULL; |
(...skipping 20 matching lines...) Expand all Loading... |
155 } | 155 } |
156 local_keys.push_back(key_pair); | 156 local_keys.push_back(key_pair); |
157 } | 157 } |
158 | 158 |
159 // Successfully processed all JWKs in the set. | 159 // Successfully processed all JWKs in the set. |
160 keys->swap(local_keys); | 160 keys->swap(local_keys); |
161 return true; | 161 return true; |
162 } | 162 } |
163 | 163 |
164 } // namespace media | 164 } // namespace media |
OLD | NEW |