| 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 "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" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "url/gurl.h" |
| 12 | 13 |
| 13 using ::testing::Mock; | 14 using ::testing::Mock; |
| 14 | 15 |
| 15 namespace extensions { | 16 namespace extensions { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 void CheckRule(const content_settings::Rule& rule, | 20 void CheckRule(const content_settings::Rule& rule, |
| 20 const ContentSettingsPattern& primary_pattern, | 21 const ContentSettingsPattern& primary_pattern, |
| 21 const ContentSettingsPattern& secondary_pattern, | 22 const ContentSettingsPattern& secondary_pattern, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 44 MOCK_METHOD2(OnContentSettingChanged, | 45 MOCK_METHOD2(OnContentSettingChanged, |
| 45 void(const std::string& extension_id, bool incognito)); | 46 void(const std::string& extension_id, bool incognito)); |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 ContentSetting GetContentSettingFromStore( | 49 ContentSetting GetContentSettingFromStore( |
| 49 const ContentSettingsStore* store, | 50 const ContentSettingsStore* store, |
| 50 const GURL& primary_url, const GURL& secondary_url, | 51 const GURL& primary_url, const GURL& secondary_url, |
| 51 ContentSettingsType content_type, | 52 ContentSettingsType content_type, |
| 52 const std::string& resource_identifier, | 53 const std::string& resource_identifier, |
| 53 bool incognito) { | 54 bool incognito) { |
| 54 scoped_ptr<content_settings::RuleIterator> rule_iterator ( | 55 scoped_ptr<content_settings::RuleIterator> rule_iterator( |
| 55 store->GetRuleIterator(content_type, resource_identifier, incognito)); | 56 store->GetRuleIterator(content_type, resource_identifier, incognito)); |
| 56 scoped_ptr<base::Value> setting( | 57 scoped_ptr<base::Value> setting( |
| 57 content_settings::GetContentSettingValueAndPatterns( | 58 content_settings::GetContentSettingValueAndPatterns( |
| 58 rule_iterator.get(), primary_url, secondary_url, NULL, NULL)); | 59 rule_iterator.get(), primary_url, secondary_url, NULL, NULL)); |
| 59 return content_settings::ValueToContentSetting(setting.get()); | 60 return content_settings::ValueToContentSetting(setting.get()); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void GetSettingsForOneTypeFromStore( | 63 void GetSettingsForOneTypeFromStore( |
| 63 const ContentSettingsStore* store, | 64 const ContentSettingsStore* store, |
| 64 ContentSettingsType content_type, | 65 ContentSettingsType content_type, |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 | 244 |
| 244 // Uninstall second extension. | 245 // Uninstall second extension. |
| 245 store()->UnregisterExtension(ext_id_2); | 246 store()->UnregisterExtension(ext_id_2); |
| 246 | 247 |
| 247 GetSettingsForOneTypeFromStore( | 248 GetSettingsForOneTypeFromStore( |
| 248 store(), CONTENT_SETTINGS_TYPE_COOKIES, std::string(), incognito, &rules); | 249 store(), CONTENT_SETTINGS_TYPE_COOKIES, std::string(), incognito, &rules); |
| 249 ASSERT_EQ(0u, rules.size()); | 250 ASSERT_EQ(0u, rules.size()); |
| 250 } | 251 } |
| 251 | 252 |
| 252 } // namespace extensions | 253 } // namespace extensions |
| OLD | NEW |