OLD | NEW |
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 Loading... |
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 21 matching lines...) Expand all Loading... |
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 = CONTENT_SETTING_DEFAULT; |
318 bool result = | 318 bool result = content_settings::ContentSettingFromString( |
319 helpers::StringToContentSetting(content_setting_string, &setting); | 319 content_setting_string, &setting); |
320 DCHECK(result); | 320 DCHECK(result); |
321 | 321 |
322 SetExtensionContentSetting(extension_id, | 322 SetExtensionContentSetting(extension_id, |
323 primary_pattern, | 323 primary_pattern, |
324 secondary_pattern, | 324 secondary_pattern, |
325 content_settings_type, | 325 content_settings_type, |
326 resource_identifier, | 326 resource_identifier, |
327 setting, | 327 setting, |
328 scope); | 328 scope); |
329 } | 329 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 ContentSettingsStore::FindEntry(const std::string& ext_id) const { | 368 ContentSettingsStore::FindEntry(const std::string& ext_id) const { |
369 ExtensionEntryMap::const_iterator i; | 369 ExtensionEntryMap::const_iterator i; |
370 for (i = entries_.begin(); i != entries_.end(); ++i) { | 370 for (i = entries_.begin(); i != entries_.end(); ++i) { |
371 if (i->second->id == ext_id) | 371 if (i->second->id == ext_id) |
372 return i; | 372 return i; |
373 } | 373 } |
374 return entries_.end(); | 374 return entries_.end(); |
375 } | 375 } |
376 | 376 |
377 } // namespace extensions | 377 } // namespace extensions |
OLD | NEW |