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

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

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership Created 4 years, 6 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 if (!map) 253 if (!map)
254 return NULL; 254 return NULL;
255 base::ListValue* settings = new base::ListValue(); 255 base::ListValue* settings = new base::ListValue();
256 OriginIdentifierValueMap::EntryMap::const_iterator it; 256 OriginIdentifierValueMap::EntryMap::const_iterator it;
257 for (it = map->begin(); it != map->end(); ++it) { 257 for (it = map->begin(); it != map->end(); ++it) {
258 std::unique_ptr<RuleIterator> rule_iterator(map->GetRuleIterator( 258 std::unique_ptr<RuleIterator> rule_iterator(map->GetRuleIterator(
259 it->first.content_type, it->first.resource_identifier, 259 it->first.content_type, it->first.resource_identifier,
260 NULL)); // We already hold the lock. 260 NULL)); // We already hold the lock.
261 while (rule_iterator->HasNext()) { 261 while (rule_iterator->HasNext()) {
262 const Rule& rule = rule_iterator->Next(); 262 const Rule& rule = rule_iterator->Next();
263 base::DictionaryValue* setting_dict = new base::DictionaryValue(); 263 std::unique_ptr<base::DictionaryValue> setting_dict(
264 new base::DictionaryValue());
264 setting_dict->SetString(keys::kPrimaryPatternKey, 265 setting_dict->SetString(keys::kPrimaryPatternKey,
265 rule.primary_pattern.ToString()); 266 rule.primary_pattern.ToString());
266 setting_dict->SetString(keys::kSecondaryPatternKey, 267 setting_dict->SetString(keys::kSecondaryPatternKey,
267 rule.secondary_pattern.ToString()); 268 rule.secondary_pattern.ToString());
268 setting_dict->SetString( 269 setting_dict->SetString(
269 keys::kContentSettingsTypeKey, 270 keys::kContentSettingsTypeKey,
270 helpers::ContentSettingsTypeToString(it->first.content_type)); 271 helpers::ContentSettingsTypeToString(it->first.content_type));
271 setting_dict->SetString(keys::kResourceIdentifierKey, 272 setting_dict->SetString(keys::kResourceIdentifierKey,
272 it->first.resource_identifier); 273 it->first.resource_identifier);
273 ContentSetting content_setting = ValueToContentSetting(rule.value.get()); 274 ContentSetting content_setting = ValueToContentSetting(rule.value.get());
274 DCHECK_NE(CONTENT_SETTING_DEFAULT, content_setting); 275 DCHECK_NE(CONTENT_SETTING_DEFAULT, content_setting);
275 276
276 std::string setting_string = 277 std::string setting_string =
277 content_settings::ContentSettingToString(content_setting); 278 content_settings::ContentSettingToString(content_setting);
278 DCHECK(!setting_string.empty()); 279 DCHECK(!setting_string.empty());
279 280
280 setting_dict->SetString(keys::kContentSettingKey, setting_string); 281 setting_dict->SetString(keys::kContentSettingKey, setting_string);
281 settings->Append(setting_dict); 282 settings->Append(std::move(setting_dict));
282 } 283 }
283 } 284 }
284 return settings; 285 return settings;
285 } 286 }
286 287
287 void ContentSettingsStore::SetExtensionContentSettingFromList( 288 void ContentSettingsStore::SetExtensionContentSettingFromList(
288 const std::string& extension_id, 289 const std::string& extension_id,
289 const base::ListValue* list, 290 const base::ListValue* list,
290 ExtensionPrefsScope scope) { 291 ExtensionPrefsScope scope) {
291 for (const auto& value : *list) { 292 for (const auto& value : *list) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 ContentSettingsStore::FindEntry(const std::string& ext_id) const { 372 ContentSettingsStore::FindEntry(const std::string& ext_id) const {
372 ExtensionEntryMap::const_iterator i; 373 ExtensionEntryMap::const_iterator i;
373 for (i = entries_.begin(); i != entries_.end(); ++i) { 374 for (i = entries_.begin(); i != entries_.end(); ++i) {
374 if (i->second->id == ext_id) 375 if (i->second->id == ext_id)
375 return i; 376 return i;
376 } 377 }
377 return entries_.end(); 378 return entries_.end();
378 } 379 }
379 380
380 } // namespace extensions 381 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698