| 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 // Interface for objects providing content setting rules. | 5 // Interface for objects providing content setting rules. |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ | 7 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ |
| 8 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ | 8 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ |
| 9 #pragma once | 9 #pragma once |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // there shouldn't be any UI shown to modify this setting. | 43 // there shouldn't be any UI shown to modify this setting. |
| 44 virtual bool DefaultSettingIsManaged( | 44 virtual bool DefaultSettingIsManaged( |
| 45 ContentSettingsType content_type) const = 0; | 45 ContentSettingsType content_type) const = 0; |
| 46 | 46 |
| 47 virtual void ShutdownOnUIThread() = 0; | 47 virtual void ShutdownOnUIThread() = 0; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class ProviderInterface { | 50 class ProviderInterface { |
| 51 public: | 51 public: |
| 52 struct Rule { | 52 struct Rule { |
| 53 typedef bool (*SortFunction)( |
| 54 const ProviderInterface::Rule&, |
| 55 const ProviderInterface::Rule&); |
| 53 Rule(); | 56 Rule(); |
| 54 Rule(const ContentSettingsPattern& primary_pattern, | 57 Rule(const ContentSettingsPattern& primary_pattern, |
| 55 const ContentSettingsPattern& secondary_pattern, | 58 const ContentSettingsPattern& secondary_pattern, |
| 56 ContentSetting setting); | 59 ContentSetting setting); |
| 57 | 60 |
| 58 ContentSettingsPattern primary_pattern; | 61 ContentSettingsPattern primary_pattern; |
| 59 ContentSettingsPattern secondary_pattern; | 62 ContentSettingsPattern secondary_pattern; |
| 60 ContentSetting content_setting; | 63 ContentSetting content_setting; |
| 64 |
| 65 static bool LexicographicalSort( |
| 66 const ProviderInterface::Rule& a, |
| 67 const ProviderInterface::Rule& b); |
| 68 |
| 69 static bool PatternPrecedenceSort( |
| 70 const ProviderInterface::Rule& a, |
| 71 const ProviderInterface::Rule& b); |
| 61 }; | 72 }; |
| 62 | 73 |
| 63 typedef std::vector<Rule> Rules; | 74 typedef std::vector<Rule> Rules; |
| 64 | 75 |
| 65 virtual ~ProviderInterface() {} | 76 virtual ~ProviderInterface() {} |
| 66 | 77 |
| 67 // Returns a single ContentSetting which applies to a given |primary_url|, | 78 // Returns a single ContentSetting which applies to a given |primary_url|, |
| 68 // |secondary_url| pair or CONTENT_SETTING_DEFAULT, if no rule applies. For | 79 // |secondary_url| pair or CONTENT_SETTING_DEFAULT, if no rule applies. For |
| 69 // ContentSettingsTypes that require a resource identifier to be specified, | 80 // ContentSettingsTypes that require a resource identifier to be specified, |
| 70 // the |resource_identifier| must be non-empty. | 81 // the |resource_identifier| must be non-empty. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // Detaches the Provider from all Profile-related objects like PrefService. | 143 // Detaches the Provider from all Profile-related objects like PrefService. |
| 133 // This methods needs to be called before destroying the Profile. | 144 // This methods needs to be called before destroying the Profile. |
| 134 // Afterwards, none of the methods above that should only be called on the UI | 145 // Afterwards, none of the methods above that should only be called on the UI |
| 135 // thread should be called anymore. | 146 // thread should be called anymore. |
| 136 virtual void ShutdownOnUIThread() = 0; | 147 virtual void ShutdownOnUIThread() = 0; |
| 137 }; | 148 }; |
| 138 | 149 |
| 139 } // namespace content_settings | 150 } // namespace content_settings |
| 140 | 151 |
| 141 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ | 152 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PROVIDER_H_ |
| OLD | NEW |