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 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ |
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 // A content settings provider that takes its settings out of the pref service. | 9 // A content settings provider that takes its settings out of the pref service. |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "chrome/browser/content_settings/content_settings_base_provider.h" | 17 #include "chrome/browser/content_settings/content_settings_origin_identifier_val ue_map.h" |
18 #include "chrome/browser/content_settings/content_settings_provider.h" | 18 #include "chrome/browser/content_settings/content_settings_provider.h" |
19 #include "chrome/browser/content_settings/content_settings_utils.h" | |
19 #include "chrome/browser/prefs/pref_change_registrar.h" | 20 #include "chrome/browser/prefs/pref_change_registrar.h" |
20 #include "content/common/notification_observer.h" | 21 #include "content/common/notification_observer.h" |
21 #include "content/common/notification_registrar.h" | 22 #include "content/common/notification_registrar.h" |
22 | 23 |
23 class ContentSettingsDetails; | 24 class ContentSettingsDetails; |
24 class DictionaryValue; | 25 class DictionaryValue; |
25 class PrefService; | 26 class PrefService; |
26 class Profile; | 27 class Profile; |
27 | 28 |
28 namespace content_settings { | 29 namespace content_settings { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 // notifications from the preferences service that we triggered ourself. | 93 // notifications from the preferences service that we triggered ourself. |
93 bool updating_preferences_; | 94 bool updating_preferences_; |
94 | 95 |
95 bool initializing_; | 96 bool initializing_; |
96 | 97 |
97 DISALLOW_COPY_AND_ASSIGN(PrefDefaultProvider); | 98 DISALLOW_COPY_AND_ASSIGN(PrefDefaultProvider); |
98 }; | 99 }; |
99 | 100 |
100 // Content settings provider that provides content settings from the user | 101 // Content settings provider that provides content settings from the user |
101 // preference. | 102 // preference. |
102 class PrefProvider : public BaseProvider, | 103 class PrefProvider : public ProviderInterface, |
103 public NotificationObserver { | 104 public NotificationObserver { |
104 public: | 105 public: |
105 static void RegisterUserPrefs(PrefService* prefs); | 106 static void RegisterUserPrefs(PrefService* prefs); |
106 | 107 |
107 explicit PrefProvider(Profile* profile); | 108 explicit PrefProvider(Profile* profile); |
108 virtual ~PrefProvider(); | 109 virtual ~PrefProvider(); |
109 | 110 |
111 // ProviderInterface implementations. | |
Bernhard Bauer
2011/05/26 23:14:42
No, this one's not. It should be non-virtual and p
markusheintz_
2011/05/31 11:46:41
Thanks for catching this. This used to override th
| |
112 virtual void Init(); | |
113 | |
110 virtual void SetContentSetting( | 114 virtual void SetContentSetting( |
111 const ContentSettingsPattern& requesting_pattern, | 115 const ContentSettingsPattern& requesting_pattern, |
112 const ContentSettingsPattern& embedding_pattern, | 116 const ContentSettingsPattern& embedding_pattern, |
113 ContentSettingsType content_type, | 117 ContentSettingsType content_type, |
114 const ResourceIdentifier& resource_identifier, | 118 const ResourceIdentifier& resource_identifier, |
115 ContentSetting content_setting); | 119 ContentSetting content_setting); |
116 | 120 |
121 virtual ContentSetting GetContentSetting( | |
122 const GURL& requesting_url, | |
123 const GURL& embedding_url, | |
124 ContentSettingsType content_type, | |
125 const ResourceIdentifier& resource_identifier) const; | |
126 | |
127 virtual void GetAllContentSettingsRules( | |
128 ContentSettingsType content_type, | |
129 const ResourceIdentifier& resource_identifier, | |
130 Rules* content_setting_rules) const; | |
131 | |
117 virtual void ClearAllContentSettingsRules( | 132 virtual void ClearAllContentSettingsRules( |
118 ContentSettingsType content_type); | 133 ContentSettingsType content_type); |
119 | 134 |
120 virtual void ResetToDefaults(); | 135 virtual void ResetToDefaults(); |
121 | 136 |
122 // BaseProvider implementations. | |
123 virtual void Init(); | |
124 | |
125 // NotificationObserver implementation. | 137 // NotificationObserver implementation. |
126 virtual void Observe(NotificationType type, | 138 virtual void Observe(NotificationType type, |
127 const NotificationSource& source, | 139 const NotificationSource& source, |
128 const NotificationDetails& details); | 140 const NotificationDetails& details); |
129 | 141 |
130 private: | 142 private: |
131 void ReadExceptions(bool overwrite); | 143 void ReadExceptions(bool overwrite); |
132 | 144 |
133 // Various migration methods (old cookie, popup and per-host data gets | 145 // Various migration methods (old cookie, popup and per-host data gets |
134 // migrated to the new format). | 146 // migrated to the new format). |
135 void MigrateObsoletePerhostPref(PrefService* prefs); | 147 void MigrateObsoletePerhostPref(PrefService* prefs); |
136 void MigrateObsoletePopupsPref(PrefService* prefs); | 148 void MigrateObsoletePopupsPref(PrefService* prefs); |
137 | 149 |
138 void CanonicalizeContentSettingsExceptions( | 150 void CanonicalizeContentSettingsExceptions( |
139 DictionaryValue* all_settings_dictionary); | 151 DictionaryValue* all_settings_dictionary); |
140 | 152 |
141 void GetSettingsFromDictionary( | |
142 const DictionaryValue* dictionary, | |
143 ContentSettings* settings); | |
144 | |
145 void GetResourceSettingsFromDictionary( | |
146 const DictionaryValue* dictionary, | |
147 ResourceContentSettings* settings); | |
148 | |
149 void NotifyObservers(const ContentSettingsDetails& details); | 153 void NotifyObservers(const ContentSettingsDetails& details); |
150 | 154 |
151 void UnregisterObservers(); | 155 void UnregisterObservers(); |
152 | 156 |
153 Profile* profile_; | 157 Profile* profile_; |
154 | 158 |
159 bool is_incognito_; | |
160 | |
155 PrefChangeRegistrar pref_change_registrar_; | 161 PrefChangeRegistrar pref_change_registrar_; |
156 NotificationRegistrar notification_registrar_; | 162 NotificationRegistrar notification_registrar_; |
157 | 163 |
158 // Whether we are currently updating preferences, this is used to ignore | 164 // Whether we are currently updating preferences, this is used to ignore |
159 // notifications from the preferences service that we triggered ourself. | 165 // notifications from the preferences service that we triggered ourself. |
160 bool updating_preferences_; | 166 bool updating_preferences_; |
161 | 167 |
162 // Do not fire any Notifications as long as we are in the constructor. | 168 // Do not fire any Notifications as long as we are in the constructor. |
163 bool initializing_; | 169 bool initializing_; |
164 | 170 |
171 OriginIdentifierValueMap value_map_; | |
172 | |
173 OriginIdentifierValueMap incognito_value_map_; | |
174 | |
175 // Used around accesses to the value map objects to guarantee | |
176 // thread safety. | |
177 mutable base::Lock lock_; | |
178 | |
165 DISALLOW_COPY_AND_ASSIGN(PrefProvider); | 179 DISALLOW_COPY_AND_ASSIGN(PrefProvider); |
166 }; | 180 }; |
167 | 181 |
168 } // namespace content_settings | 182 } // namespace content_settings |
169 | 183 |
170 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ | 184 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ |
OLD | NEW |