Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: chrome/browser/chromeos/platform_keys/key_permissions.cc

Issue 2816513002: Revert of Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/chromeos/platform_keys/key_permissions.h" 5 #include "chrome/browser/chromeos/platform_keys/key_permissions.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 void KeyPermissions::PermissionsForExtension::KeyEntriesFromState( 240 void KeyPermissions::PermissionsForExtension::KeyEntriesFromState(
241 const base::Value& state) { 241 const base::Value& state) {
242 state_store_entries_.clear(); 242 state_store_entries_.clear();
243 243
244 const base::ListValue* entries = nullptr; 244 const base::ListValue* entries = nullptr;
245 if (!state.GetAsList(&entries)) { 245 if (!state.GetAsList(&entries)) {
246 LOG(ERROR) << "Found a state store of wrong type."; 246 LOG(ERROR) << "Found a state store of wrong type.";
247 return; 247 return;
248 } 248 }
249 for (const auto& entry : *entries) { 249 for (const auto& entry : *entries) {
250 if (!entry) {
251 LOG(ERROR) << "Found invalid NULL entry in PlatformKeys state store.";
252 continue;
253 }
254
250 std::string spki_b64; 255 std::string spki_b64;
251 const base::DictionaryValue* dict_entry = nullptr; 256 const base::DictionaryValue* dict_entry = nullptr;
252 if (entry.GetAsString(&spki_b64)) { 257 if (entry->GetAsString(&spki_b64)) {
253 // This handles the case that the store contained a plain list of base64 258 // This handles the case that the store contained a plain list of base64
254 // and DER-encoded SPKIs from an older version of ChromeOS. 259 // and DER-encoded SPKIs from an older version of ChromeOS.
255 KeyEntry new_entry(spki_b64); 260 KeyEntry new_entry(spki_b64);
256 new_entry.sign_once = true; 261 new_entry.sign_once = true;
257 state_store_entries_.push_back(new_entry); 262 state_store_entries_.push_back(new_entry);
258 } else if (entry.GetAsDictionary(&dict_entry)) { 263 } else if (entry->GetAsDictionary(&dict_entry)) {
259 dict_entry->GetStringWithoutPathExpansion(kStateStoreSPKI, &spki_b64); 264 dict_entry->GetStringWithoutPathExpansion(kStateStoreSPKI, &spki_b64);
260 KeyEntry new_entry(spki_b64); 265 KeyEntry new_entry(spki_b64);
261 dict_entry->GetBooleanWithoutPathExpansion(kStateStoreSignOnce, 266 dict_entry->GetBooleanWithoutPathExpansion(kStateStoreSignOnce,
262 &new_entry.sign_once); 267 &new_entry.sign_once);
263 dict_entry->GetBooleanWithoutPathExpansion(kStateStoreSignUnlimited, 268 dict_entry->GetBooleanWithoutPathExpansion(kStateStoreSignUnlimited,
264 &new_entry.sign_unlimited); 269 &new_entry.sign_unlimited);
265 state_store_entries_.push_back(new_entry); 270 state_store_entries_.push_back(new_entry);
266 } else { 271 } else {
267 LOG(ERROR) << "Found invalid entry of type " << entry.GetType() 272 LOG(ERROR) << "Found invalid entry of type " << entry->GetType()
268 << " in PlatformKeys state store."; 273 << " in PlatformKeys state store.";
269 continue; 274 continue;
270 } 275 }
271 } 276 }
272 } 277 }
273 278
274 std::unique_ptr<base::Value> 279 std::unique_ptr<base::Value>
275 KeyPermissions::PermissionsForExtension::KeyEntriesToState() { 280 KeyPermissions::PermissionsForExtension::KeyEntriesToState() {
276 std::unique_ptr<base::ListValue> new_state(new base::ListValue); 281 std::unique_ptr<base::ListValue> new_state(new base::ListValue);
277 for (const KeyEntry& entry : state_store_entries_) { 282 for (const KeyEntry& entry : state_store_entries_) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 const base::DictionaryValue* platform_keys = 393 const base::DictionaryValue* platform_keys =
389 profile_prefs_->GetDictionary(prefs::kPlatformKeys); 394 profile_prefs_->GetDictionary(prefs::kPlatformKeys);
390 395
391 const base::DictionaryValue* key_entry = nullptr; 396 const base::DictionaryValue* key_entry = nullptr;
392 platform_keys->GetDictionaryWithoutPathExpansion(public_key_spki_der_b64, 397 platform_keys->GetDictionaryWithoutPathExpansion(public_key_spki_der_b64,
393 &key_entry); 398 &key_entry);
394 return key_entry; 399 return key_entry;
395 } 400 }
396 401
397 } // namespace chromeos 402 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698