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

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

Issue 1372353004: Making structure for ContentSettings and its corresponding strings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 2 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 <set> 7 #include <set>
8 8
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 rule.secondary_pattern.ToString()); 266 rule.secondary_pattern.ToString());
267 setting_dict->SetString( 267 setting_dict->SetString(
268 keys::kContentSettingsTypeKey, 268 keys::kContentSettingsTypeKey,
269 helpers::ContentSettingsTypeToString(it->first.content_type)); 269 helpers::ContentSettingsTypeToString(it->first.content_type));
270 setting_dict->SetString(keys::kResourceIdentifierKey, 270 setting_dict->SetString(keys::kResourceIdentifierKey,
271 it->first.resource_identifier); 271 it->first.resource_identifier);
272 ContentSetting content_setting = ValueToContentSetting(rule.value.get()); 272 ContentSetting content_setting = ValueToContentSetting(rule.value.get());
273 DCHECK_NE(CONTENT_SETTING_DEFAULT, content_setting); 273 DCHECK_NE(CONTENT_SETTING_DEFAULT, content_setting);
274 setting_dict->SetString( 274 setting_dict->SetString(
275 keys::kContentSettingKey, 275 keys::kContentSettingKey,
276 helpers::ContentSettingToString(content_setting)); 276 content_settings::ContentSettingToString(content_setting));
277 settings->Append(setting_dict); 277 settings->Append(setting_dict);
278 } 278 }
279 } 279 }
280 return settings; 280 return settings;
281 } 281 }
282 282
283 void ContentSettingsStore::SetExtensionContentSettingFromList( 283 void ContentSettingsStore::SetExtensionContentSettingFromList(
284 const std::string& extension_id, 284 const std::string& extension_id,
285 const base::ListValue* list, 285 const base::ListValue* list,
286 ExtensionPrefsScope scope) { 286 ExtensionPrefsScope scope) {
(...skipping 20 matching lines...) Expand all
307 dict->GetString(keys::kContentSettingsTypeKey, &content_settings_type_str); 307 dict->GetString(keys::kContentSettingsTypeKey, &content_settings_type_str);
308 ContentSettingsType content_settings_type = 308 ContentSettingsType content_settings_type =
309 helpers::StringToContentSettingsType(content_settings_type_str); 309 helpers::StringToContentSettingsType(content_settings_type_str);
310 DCHECK_NE(CONTENT_SETTINGS_TYPE_DEFAULT, content_settings_type); 310 DCHECK_NE(CONTENT_SETTINGS_TYPE_DEFAULT, content_settings_type);
311 311
312 std::string resource_identifier; 312 std::string resource_identifier;
313 dict->GetString(keys::kResourceIdentifierKey, &resource_identifier); 313 dict->GetString(keys::kResourceIdentifierKey, &resource_identifier);
314 314
315 std::string content_setting_string; 315 std::string content_setting_string;
316 dict->GetString(keys::kContentSettingKey, &content_setting_string); 316 dict->GetString(keys::kContentSettingKey, &content_setting_string);
317 ContentSetting setting = CONTENT_SETTING_DEFAULT; 317 ContentSetting setting =
318 bool result = 318 content_settings::ContentSettingFromString(content_setting_string);
319 helpers::StringToContentSetting(content_setting_string, &setting); 319 DCHECK_NE(CONTENT_SETTING_DEFAULT, setting);
320 DCHECK(result);
321 320
322 SetExtensionContentSetting(extension_id, 321 SetExtensionContentSetting(extension_id,
323 primary_pattern, 322 primary_pattern,
324 secondary_pattern, 323 secondary_pattern,
325 content_settings_type, 324 content_settings_type,
326 resource_identifier, 325 resource_identifier,
327 setting, 326 setting,
328 scope); 327 scope);
329 } 328 }
330 } 329 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 ContentSettingsStore::FindEntry(const std::string& ext_id) const { 367 ContentSettingsStore::FindEntry(const std::string& ext_id) const {
369 ExtensionEntryMap::const_iterator i; 368 ExtensionEntryMap::const_iterator i;
370 for (i = entries_.begin(); i != entries_.end(); ++i) { 369 for (i = entries_.begin(); i != entries_.end(); ++i) {
371 if (i->second->id == ext_id) 370 if (i->second->id == ext_id)
372 return i; 371 return i;
373 } 372 }
374 return entries_.end(); 373 return entries_.end();
375 } 374 }
376 375
377 } // namespace extensions 376 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698