| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_content_settings_store.h" | 5 #include "chrome/browser/extensions/extension_content_settings_store.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/browser/content_settings/content_settings_rule.h" | 8 #include "chrome/browser/content_settings/content_settings_rule.h" |
| 9 #include "chrome/browser/content_settings/content_settings_utils.h" | 9 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 ContentSetting GetContentSettingFromStore( | 46 ContentSetting GetContentSettingFromStore( |
| 47 const ExtensionContentSettingsStore* store, | 47 const ExtensionContentSettingsStore* store, |
| 48 const GURL& primary_url, const GURL& secondary_url, | 48 const GURL& primary_url, const GURL& secondary_url, |
| 49 ContentSettingsType content_type, | 49 ContentSettingsType content_type, |
| 50 const std::string& resource_identifier, | 50 const std::string& resource_identifier, |
| 51 bool incognito) { | 51 bool incognito) { |
| 52 scoped_ptr<content_settings::RuleIterator> rule_iterator ( | 52 scoped_ptr<content_settings::RuleIterator> rule_iterator ( |
| 53 store->GetRuleIterator(content_type, resource_identifier, incognito)); | 53 store->GetRuleIterator(content_type, resource_identifier, incognito)); |
| 54 return content_settings::GetContentSetting( | 54 scoped_ptr<base::Value> setting( |
| 55 rule_iterator.get(), primary_url, secondary_url); | 55 content_settings::GetContentSettingValueAndPatterns( |
| 56 rule_iterator.get(), primary_url, secondary_url, NULL, NULL)); |
| 57 return content_settings::ValueToContentSetting(setting.get()); |
| 56 } | 58 } |
| 57 | 59 |
| 58 void GetSettingsForOneTypeFromStore( | 60 void GetSettingsForOneTypeFromStore( |
| 59 const ExtensionContentSettingsStore* store, | 61 const ExtensionContentSettingsStore* store, |
| 60 ContentSettingsType content_type, | 62 ContentSettingsType content_type, |
| 61 const std::string& resource_identifier, | 63 const std::string& resource_identifier, |
| 62 bool incognito, | 64 bool incognito, |
| 63 std::vector<content_settings::Rule>* rules) { | 65 std::vector<content_settings::Rule>* rules) { |
| 64 rules->clear(); | 66 rules->clear(); |
| 65 scoped_ptr<content_settings::RuleIterator> rule_iterator( | 67 scoped_ptr<content_settings::RuleIterator> rule_iterator( |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 ASSERT_EQ(1u, rules.size()); | 242 ASSERT_EQ(1u, rules.size()); |
| 241 CheckRule(rules[0], pattern_2, pattern_2, CONTENT_SETTING_BLOCK); | 243 CheckRule(rules[0], pattern_2, pattern_2, CONTENT_SETTING_BLOCK); |
| 242 | 244 |
| 243 // Uninstall second extension. | 245 // Uninstall second extension. |
| 244 store()->UnregisterExtension(ext_id_2); | 246 store()->UnregisterExtension(ext_id_2); |
| 245 | 247 |
| 246 GetSettingsForOneTypeFromStore( | 248 GetSettingsForOneTypeFromStore( |
| 247 store(), CONTENT_SETTINGS_TYPE_COOKIES, "", incognito, &rules); | 249 store(), CONTENT_SETTINGS_TYPE_COOKIES, "", incognito, &rules); |
| 248 ASSERT_EQ(0u, rules.size()); | 250 ASSERT_EQ(0u, rules.size()); |
| 249 } | 251 } |
| OLD | NEW |