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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 rule.primary_pattern.ToString()); | 264 rule.primary_pattern.ToString()); |
265 setting_dict->SetString(keys::kSecondaryPatternKey, | 265 setting_dict->SetString(keys::kSecondaryPatternKey, |
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 |
275 keys::kContentSettingKey, | 275 std::string setting_string = |
276 helpers::ContentSettingToString(content_setting)); | 276 content_settings::ContentSettingToString(content_setting); |
| 277 DCHECK(!setting_string.empty()); |
| 278 |
| 279 setting_dict->SetString(keys::kContentSettingKey, setting_string); |
277 settings->Append(setting_dict); | 280 settings->Append(setting_dict); |
278 } | 281 } |
279 } | 282 } |
280 return settings; | 283 return settings; |
281 } | 284 } |
282 | 285 |
283 void ContentSettingsStore::SetExtensionContentSettingFromList( | 286 void ContentSettingsStore::SetExtensionContentSettingFromList( |
284 const std::string& extension_id, | 287 const std::string& extension_id, |
285 const base::ListValue* list, | 288 const base::ListValue* list, |
286 ExtensionPrefsScope scope) { | 289 ExtensionPrefsScope scope) { |
(...skipping 20 matching lines...) Expand all Loading... |
307 dict->GetString(keys::kContentSettingsTypeKey, &content_settings_type_str); | 310 dict->GetString(keys::kContentSettingsTypeKey, &content_settings_type_str); |
308 ContentSettingsType content_settings_type = | 311 ContentSettingsType content_settings_type = |
309 helpers::StringToContentSettingsType(content_settings_type_str); | 312 helpers::StringToContentSettingsType(content_settings_type_str); |
310 DCHECK_NE(CONTENT_SETTINGS_TYPE_DEFAULT, content_settings_type); | 313 DCHECK_NE(CONTENT_SETTINGS_TYPE_DEFAULT, content_settings_type); |
311 | 314 |
312 std::string resource_identifier; | 315 std::string resource_identifier; |
313 dict->GetString(keys::kResourceIdentifierKey, &resource_identifier); | 316 dict->GetString(keys::kResourceIdentifierKey, &resource_identifier); |
314 | 317 |
315 std::string content_setting_string; | 318 std::string content_setting_string; |
316 dict->GetString(keys::kContentSettingKey, &content_setting_string); | 319 dict->GetString(keys::kContentSettingKey, &content_setting_string); |
317 ContentSetting setting = CONTENT_SETTING_DEFAULT; | 320 ContentSetting setting; |
318 bool result = | 321 bool result = content_settings::ContentSettingFromString( |
319 helpers::StringToContentSetting(content_setting_string, &setting); | 322 content_setting_string, &setting); |
320 DCHECK(result); | 323 DCHECK(result); |
321 | 324 |
322 SetExtensionContentSetting(extension_id, | 325 SetExtensionContentSetting(extension_id, |
323 primary_pattern, | 326 primary_pattern, |
324 secondary_pattern, | 327 secondary_pattern, |
325 content_settings_type, | 328 content_settings_type, |
326 resource_identifier, | 329 resource_identifier, |
327 setting, | 330 setting, |
328 scope); | 331 scope); |
329 } | 332 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 ContentSettingsStore::FindEntry(const std::string& ext_id) const { | 371 ContentSettingsStore::FindEntry(const std::string& ext_id) const { |
369 ExtensionEntryMap::const_iterator i; | 372 ExtensionEntryMap::const_iterator i; |
370 for (i = entries_.begin(); i != entries_.end(); ++i) { | 373 for (i = entries_.begin(); i != entries_.end(); ++i) { |
371 if (i->second->id == ext_id) | 374 if (i->second->id == ext_id) |
372 return i; | 375 return i; |
373 } | 376 } |
374 return entries_.end(); | 377 return entries_.end(); |
375 } | 378 } |
376 | 379 |
377 } // namespace extensions | 380 } // namespace extensions |
OLD | NEW |