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 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 ContentSettingsType content_type); | 127 ContentSettingsType content_type); |
128 | 128 |
129 virtual void ShutdownOnUIThread(); | 129 virtual void ShutdownOnUIThread(); |
130 | 130 |
131 // NotificationObserver implementation. | 131 // NotificationObserver implementation. |
132 virtual void Observe(int type, | 132 virtual void Observe(int type, |
133 const NotificationSource& source, | 133 const NotificationSource& source, |
134 const NotificationDetails& details); | 134 const NotificationDetails& details); |
135 | 135 |
136 private: | 136 private: |
137 void Init(); | |
138 | |
139 // Reads all content settings exceptions from the preference and load them | 137 // Reads all content settings exceptions from the preference and load them |
140 // into the |value_map_|. The |value_map_| is cleared first if |overwrite| is | 138 // into the |value_map_|. The |value_map_| is cleared first if |overwrite| is |
141 // true. | 139 // true. |
142 void ReadContentSettingsFromPref(bool overwrite); | 140 void ReadContentSettingsFromPref(bool overwrite); |
143 | 141 |
144 // Update the preference that stores content settings exceptions and syncs the | 142 // Update the preference that stores content settings exceptions and syncs the |
145 // value to the obsolete preference. | 143 // value to the obsolete preference. |
146 void UpdatePref( | 144 void UpdatePref( |
147 const ContentSettingsPattern& primary_pattern, | 145 const ContentSettingsPattern& primary_pattern, |
148 const ContentSettingsPattern& secondary_pattern, | 146 const ContentSettingsPattern& secondary_pattern, |
149 ContentSettingsType content_type, | 147 ContentSettingsType content_type, |
150 const ResourceIdentifier& resource_identifier, | 148 const ResourceIdentifier& resource_identifier, |
151 ContentSetting setting); | 149 ContentSetting setting); |
152 | 150 |
153 // Update the preference prefs::kContentSettingsPatternPairs, which is used to | 151 // Update the preference prefs::kContentSettingsPatternPairs, which is used to |
154 // persist content settigns exceptions and supposed to replace the preferences | 152 // persist content settings exceptions and supposed to replace the preferences |
155 // prefs::kContentSettingsPatterns. | 153 // prefs::kContentSettingsPatterns and prefs::kGeolocationContentSettings. |
156 void UpdatePatternPairsPref( | 154 void UpdatePatternPairsPref( |
157 const ContentSettingsPattern& primary_pattern, | 155 const ContentSettingsPattern& primary_pattern, |
158 const ContentSettingsPattern& secondary_pattern, | 156 const ContentSettingsPattern& secondary_pattern, |
159 ContentSettingsType content_type, | 157 ContentSettingsType content_type, |
160 const ResourceIdentifier& resource_identifier, | 158 const ResourceIdentifier& resource_identifier, |
161 ContentSetting setting); | 159 ContentSetting setting); |
162 | 160 |
163 // Updates the preferences prefs::kContentSettingsPatterns. This preferences | 161 // Updates the preferences prefs::kContentSettingsPatterns. This preferences |
164 // is obsolete and only used for compatibility reasons. | 162 // is obsolete and only used for compatibility reasons. |
165 void UpdatePatternsPref( | 163 void UpdateObsoletePatternsPref( |
166 const ContentSettingsPattern& primary_pattern, | 164 const ContentSettingsPattern& primary_pattern, |
167 const ContentSettingsPattern& secondary_pattern, | 165 const ContentSettingsPattern& secondary_pattern, |
168 ContentSettingsType content_type, | 166 ContentSettingsType content_type, |
169 const ResourceIdentifier& resource_identifier, | 167 const ResourceIdentifier& resource_identifier, |
170 ContentSetting setting); | 168 ContentSetting setting); |
171 | 169 |
| 170 // Updates the preferences prefs::kGeolocationContentSettings. This preference |
| 171 // is obsolete and only used to keep sync working with older chrome versions |
| 172 // that do not know about the new preference. |
| 173 void UpdateObsoleteGeolocationPref( |
| 174 const ContentSettingsPattern& primary_pattern, |
| 175 const ContentSettingsPattern& secondary_pattern, |
| 176 ContentSetting setting); |
| 177 |
172 // Various migration methods (old cookie, popup and per-host data gets | 178 // Various migration methods (old cookie, popup and per-host data gets |
173 // migrated to the new format). | 179 // migrated to the new format). |
174 void MigrateObsoletePerhostPref(); | 180 void MigrateObsoletePerhostPref(); |
175 void MigrateObsoletePopupsPref(); | 181 void MigrateObsoletePopupsPref(); |
176 void MigrateObsoleteContentSettingsPatternPref(); | 182 void MigrateObsoleteContentSettingsPatternPref(); |
| 183 void MigrateObsoleteGeolocationPref(); |
177 | 184 |
178 // Copies the value of the preference that stores the content settings | 185 // Copies the value of the preference that stores the content settings |
179 // exceptions to the obsolete preference for content settings exceptions. This | 186 // exceptions to the obsolete preference for content settings exceptions. This |
180 // is necessary to allow content settings exceptions beeing synced to older | 187 // is necessary to allow content settings exceptions beeing synced to older |
181 // versions of chrome that only use the obsolete. | 188 // versions of chrome that only use the obsolete preference. |
182 void SyncObsoletePref(); | 189 void SyncObsoletePatternPref(); |
| 190 |
| 191 // Copies the geolocation content settings exceptions from the preference that |
| 192 // stores the content settings exceptions to the obsolete preference for |
| 193 // geolocation content settings exceptions. This is necessary to allow |
| 194 // geolocation content settings exceptions being synced to older versions of |
| 195 // chrome that only use the obsolete preference. |
| 196 void SyncObsoleteGeolocationPref(); |
183 | 197 |
184 static void CanonicalizeContentSettingsExceptions( | 198 static void CanonicalizeContentSettingsExceptions( |
185 base::DictionaryValue* all_settings_dictionary); | 199 base::DictionaryValue* all_settings_dictionary); |
186 | 200 |
187 // Weak; owned by the Profile and reset in ShutdownOnUIThread. | 201 // Weak; owned by the Profile and reset in ShutdownOnUIThread. |
188 PrefService* prefs_; | 202 PrefService* prefs_; |
189 | 203 |
190 bool is_incognito_; | 204 bool is_incognito_; |
191 | 205 |
192 PrefChangeRegistrar pref_change_registrar_; | 206 PrefChangeRegistrar pref_change_registrar_; |
193 | 207 |
194 // Whether we are currently updating preferences, this is used to ignore | 208 // Whether we are currently updating preferences, this is used to ignore |
195 // notifications from the preferences service that we triggered ourself. | 209 // notifications from the preferences service that we triggered ourself. |
196 bool updating_preferences_; | 210 bool updating_preferences_; |
197 | 211 |
198 OriginIdentifierValueMap value_map_; | 212 OriginIdentifierValueMap value_map_; |
199 | 213 |
200 OriginIdentifierValueMap incognito_value_map_; | 214 OriginIdentifierValueMap incognito_value_map_; |
201 | 215 |
202 // Used around accesses to the value map objects to guarantee | 216 // Used around accesses to the value map objects to guarantee |
203 // thread safety. | 217 // thread safety. |
204 mutable base::Lock lock_; | 218 mutable base::Lock lock_; |
205 | 219 |
206 DISALLOW_COPY_AND_ASSIGN(PrefProvider); | 220 DISALLOW_COPY_AND_ASSIGN(PrefProvider); |
207 }; | 221 }; |
208 | 222 |
209 } // namespace content_settings | 223 } // namespace content_settings |
210 | 224 |
211 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ | 225 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ |
OLD | NEW |