| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/debug/alias.h" | 12 #include "base/debug/alias.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/extensions/api/content_settings/content_settings_api_co
nstants.h" | 17 #include "chrome/browser/extensions/api/content_settings/content_settings_api_co
nstants.h" |
| 18 #include "chrome/browser/extensions/api/content_settings/content_settings_helper
s.h" | 18 #include "chrome/browser/extensions/api/content_settings/content_settings_helper
s.h" |
| 19 #include "components/content_settings/core/browser/content_settings_origin_ident
ifier_value_map.h" | 19 #include "components/content_settings/core/browser/content_settings_origin_ident
ifier_value_map.h" |
| 20 #include "components/content_settings/core/browser/content_settings_rule.h" | 20 #include "components/content_settings/core/browser/content_settings_rule.h" |
| 21 #include "components/content_settings/core/browser/content_settings_utils.h" | 21 #include "components/content_settings/core/browser/content_settings_utils.h" |
| 22 #include "components/content_settings/core/common/content_settings_utils.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 | 24 |
| 24 using content::BrowserThread; | 25 using content::BrowserThread; |
| 25 using content_settings::ConcatenationIterator; | 26 using content_settings::ConcatenationIterator; |
| 26 using content_settings::Rule; | 27 using content_settings::Rule; |
| 27 using content_settings::RuleIterator; | 28 using content_settings::RuleIterator; |
| 28 using content_settings::OriginIdentifierValueMap; | 29 using content_settings::OriginIdentifierValueMap; |
| 29 using content_settings::ResourceIdentifier; | 30 using content_settings::ResourceIdentifier; |
| 30 using content_settings::ValueToContentSetting; | |
| 31 | 31 |
| 32 namespace extensions { | 32 namespace extensions { |
| 33 | 33 |
| 34 namespace helpers = content_settings_helpers; | 34 namespace helpers = content_settings_helpers; |
| 35 namespace keys = content_settings_api_constants; | 35 namespace keys = content_settings_api_constants; |
| 36 | 36 |
| 37 struct ContentSettingsStore::ExtensionEntry { | 37 struct ContentSettingsStore::ExtensionEntry { |
| 38 // Extension id. | 38 // Extension id. |
| 39 std::string id; | 39 std::string id; |
| 40 // Installation time. | 40 // Installation time. |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 new base::DictionaryValue()); | 269 new base::DictionaryValue()); |
| 270 setting_dict->SetString(keys::kPrimaryPatternKey, | 270 setting_dict->SetString(keys::kPrimaryPatternKey, |
| 271 rule.primary_pattern.ToString()); | 271 rule.primary_pattern.ToString()); |
| 272 setting_dict->SetString(keys::kSecondaryPatternKey, | 272 setting_dict->SetString(keys::kSecondaryPatternKey, |
| 273 rule.secondary_pattern.ToString()); | 273 rule.secondary_pattern.ToString()); |
| 274 setting_dict->SetString( | 274 setting_dict->SetString( |
| 275 keys::kContentSettingsTypeKey, | 275 keys::kContentSettingsTypeKey, |
| 276 helpers::ContentSettingsTypeToString(key.content_type)); | 276 helpers::ContentSettingsTypeToString(key.content_type)); |
| 277 setting_dict->SetString(keys::kResourceIdentifierKey, | 277 setting_dict->SetString(keys::kResourceIdentifierKey, |
| 278 key.resource_identifier); | 278 key.resource_identifier); |
| 279 ContentSetting content_setting = ValueToContentSetting(rule.value.get()); | 279 ContentSetting content_setting = |
| 280 content_settings::ValueToContentSetting(rule.value.get()); |
| 280 DCHECK_NE(CONTENT_SETTING_DEFAULT, content_setting); | 281 DCHECK_NE(CONTENT_SETTING_DEFAULT, content_setting); |
| 281 | 282 |
| 282 std::string setting_string = | 283 std::string setting_string = |
| 283 content_settings::ContentSettingToString(content_setting); | 284 content_settings::ContentSettingToString(content_setting); |
| 284 DCHECK(!setting_string.empty()); | 285 DCHECK(!setting_string.empty()); |
| 285 | 286 |
| 286 setting_dict->SetString(keys::kContentSettingKey, setting_string); | 287 setting_dict->SetString(keys::kContentSettingKey, setting_string); |
| 287 settings->Append(std::move(setting_dict)); | 288 settings->Append(std::move(setting_dict)); |
| 288 } | 289 } |
| 289 } | 290 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 385 |
| 385 ContentSettingsStore::ExtensionEntries::iterator | 386 ContentSettingsStore::ExtensionEntries::iterator |
| 386 ContentSettingsStore::FindIterator(const std::string& ext_id) { | 387 ContentSettingsStore::FindIterator(const std::string& ext_id) { |
| 387 return std::find_if(entries_.begin(), entries_.end(), | 388 return std::find_if(entries_.begin(), entries_.end(), |
| 388 [ext_id](const std::unique_ptr<ExtensionEntry>& entry) { | 389 [ext_id](const std::unique_ptr<ExtensionEntry>& entry) { |
| 389 return entry->id == ext_id; | 390 return entry->id == ext_id; |
| 390 }); | 391 }); |
| 391 } | 392 } |
| 392 | 393 |
| 393 } // namespace extensions | 394 } // namespace extensions |
| OLD | NEW |