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

Side by Side Diff: chrome/browser/extensions/api/content_settings/content_settings_store.cc

Issue 2000803003: Use std::unique_ptr for base::DictionaryValue and base::ListValue's internal store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes Created 4 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/api/content_settings/content_settings_store. h" 5 #include "chrome/browser/extensions/api/content_settings/content_settings_store. h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 settings->Append(setting_dict); 281 settings->Append(setting_dict);
282 } 282 }
283 } 283 }
284 return settings; 284 return settings;
285 } 285 }
286 286
287 void ContentSettingsStore::SetExtensionContentSettingFromList( 287 void ContentSettingsStore::SetExtensionContentSettingFromList(
288 const std::string& extension_id, 288 const std::string& extension_id,
289 const base::ListValue* list, 289 const base::ListValue* list,
290 ExtensionPrefsScope scope) { 290 ExtensionPrefsScope scope) {
291 for (base::ListValue::const_iterator it = list->begin(); 291 for (const auto& value : *list) {
292 it != list->end(); ++it) { 292 base::DictionaryValue* dict;
293 if ((*it)->GetType() != base::Value::TYPE_DICTIONARY) { 293 if (!value->GetAsDictionary(&dict)) {
294 NOTREACHED(); 294 NOTREACHED();
295 continue; 295 continue;
296 } 296 }
297 base::DictionaryValue* dict = static_cast<base::DictionaryValue*>(*it);
298 std::string primary_pattern_str; 297 std::string primary_pattern_str;
299 dict->GetString(keys::kPrimaryPatternKey, &primary_pattern_str); 298 dict->GetString(keys::kPrimaryPatternKey, &primary_pattern_str);
300 ContentSettingsPattern primary_pattern = 299 ContentSettingsPattern primary_pattern =
301 ContentSettingsPattern::FromString(primary_pattern_str); 300 ContentSettingsPattern::FromString(primary_pattern_str);
302 DCHECK(primary_pattern.IsValid()); 301 DCHECK(primary_pattern.IsValid());
303 302
304 std::string secondary_pattern_str; 303 std::string secondary_pattern_str;
305 dict->GetString(keys::kSecondaryPatternKey, &secondary_pattern_str); 304 dict->GetString(keys::kSecondaryPatternKey, &secondary_pattern_str);
306 ContentSettingsPattern secondary_pattern = 305 ContentSettingsPattern secondary_pattern =
307 ContentSettingsPattern::FromString(secondary_pattern_str); 306 ContentSettingsPattern::FromString(secondary_pattern_str);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 ContentSettingsStore::FindEntry(const std::string& ext_id) const { 371 ContentSettingsStore::FindEntry(const std::string& ext_id) const {
373 ExtensionEntryMap::const_iterator i; 372 ExtensionEntryMap::const_iterator i;
374 for (i = entries_.begin(); i != entries_.end(); ++i) { 373 for (i = entries_.begin(); i != entries_.end(); ++i) {
375 if (i->second->id == ext_id) 374 if (i->second->id == ext_id)
376 return i; 375 return i;
377 } 376 }
378 return entries_.end(); 377 return entries_.end();
379 } 378 }
380 379
381 } // namespace extensions 380 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698