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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 // Update the preference that stores content settings exceptions and syncs the | 142 // Update the preference that stores content settings exceptions and syncs the |
143 // value to the obsolete preference. | 143 // value to the obsolete preference. |
144 void UpdatePref( | 144 void UpdatePref( |
145 const ContentSettingsPattern& primary_pattern, | 145 const ContentSettingsPattern& primary_pattern, |
146 const ContentSettingsPattern& secondary_pattern, | 146 const ContentSettingsPattern& secondary_pattern, |
147 ContentSettingsType content_type, | 147 ContentSettingsType content_type, |
148 const ResourceIdentifier& resource_identifier, | 148 const ResourceIdentifier& resource_identifier, |
149 ContentSetting setting); | 149 ContentSetting setting); |
150 | 150 |
151 // Updates the given |pattern_pairs_settings| dictionary value. | 151 // Update the preference prefs::kContentSettingsPatternPairs, which is used to |
152 void UpdatePatternPairsSettings( | 152 // persist content settings exceptions and supposed to replace the preferences |
| 153 // prefs::kContentSettingsPatterns and prefs::kGeolocationContentSettings. |
| 154 void UpdatePatternPairsPref( |
153 const ContentSettingsPattern& primary_pattern, | 155 const ContentSettingsPattern& primary_pattern, |
154 const ContentSettingsPattern& secondary_pattern, | 156 const ContentSettingsPattern& secondary_pattern, |
155 ContentSettingsType content_type, | 157 ContentSettingsType content_type, |
156 const ResourceIdentifier& resource_identifier, | 158 const ResourceIdentifier& resource_identifier, |
157 ContentSetting setting, | 159 ContentSetting setting); |
158 DictionaryValue* pattern_pairs_settings); | |
159 | 160 |
160 // Updates the preferences prefs::kContentSettingsPatterns. This preferences | 161 // Updates the preferences prefs::kContentSettingsPatterns. This preferences |
161 // is obsolete and only used for compatibility reasons. | 162 // is obsolete and only used for compatibility reasons. |
162 void UpdateObsoletePatternsPref( | 163 void UpdateObsoletePatternsPref( |
163 const ContentSettingsPattern& primary_pattern, | 164 const ContentSettingsPattern& primary_pattern, |
164 const ContentSettingsPattern& secondary_pattern, | 165 const ContentSettingsPattern& secondary_pattern, |
165 ContentSettingsType content_type, | 166 ContentSettingsType content_type, |
166 const ResourceIdentifier& resource_identifier, | 167 const ResourceIdentifier& resource_identifier, |
167 ContentSetting setting); | 168 ContentSetting setting); |
168 | 169 |
169 // Updates the preference prefs::kGeolocationContentSettings. This preference | 170 // Updates the preferences prefs::kGeolocationContentSettings. This preference |
170 // is obsolete and only used to keep sync working with older chrome versions | 171 // is obsolete and only used to keep sync working with older chrome versions |
171 // that do not know about the new preference. | 172 // that do not know about the new preference. |
172 void UpdateObsoleteGeolocationPref( | 173 void UpdateObsoleteGeolocationPref( |
173 const ContentSettingsPattern& primary_pattern, | 174 const ContentSettingsPattern& primary_pattern, |
174 const ContentSettingsPattern& secondary_pattern, | 175 const ContentSettingsPattern& secondary_pattern, |
175 ContentSetting setting); | 176 ContentSetting setting); |
176 | 177 |
177 // Updates the obsolete notifications settings in the passed list values | |
178 // |allowed_sites| and |denied_sites|. | |
179 void UpdateObsoleteNotificationsSettings( | |
180 const ContentSettingsPattern& primary_pattern, | |
181 const ContentSettingsPattern& secondary_pattern, | |
182 ContentSetting setting, | |
183 ListValue* allowed_sites, | |
184 ListValue* denied_sites); | |
185 | |
186 // Various migration methods (old cookie, popup and per-host data gets | 178 // Various migration methods (old cookie, popup and per-host data gets |
187 // migrated to the new format). | 179 // migrated to the new format). |
188 void MigrateObsoletePerhostPref(); | 180 void MigrateObsoletePerhostPref(); |
189 void MigrateObsoletePopupsPref(); | 181 void MigrateObsoletePopupsPref(); |
190 void MigrateObsoleteContentSettingsPatternPref(); | 182 void MigrateObsoleteContentSettingsPatternPref(); |
191 void MigrateObsoleteGeolocationPref(); | 183 void MigrateObsoleteGeolocationPref(); |
192 void MigrateObsoleteNotificationsPrefs(); | |
193 | 184 |
194 // Copies the value of the preference that stores the content settings | 185 // Copies the value of the preference that stores the content settings |
195 // exceptions to the obsolete preference for content settings exceptions. This | 186 // exceptions to the obsolete preference for content settings exceptions. This |
196 // is necessary to allow content settings exceptions beeing synced to older | 187 // is necessary to allow content settings exceptions beeing synced to older |
197 // versions of chrome that only use the obsolete preference. | 188 // versions of chrome that only use the obsolete preference. |
198 void SyncObsoletePatternPref(); | 189 void SyncObsoletePatternPref(); |
199 | 190 |
200 // Copies the notifications and geolocation content settings exceptions from | 191 // Copies the geolocation content settings exceptions from the preference that |
201 // the preference that stores the content settings exceptions to the obsolete | 192 // stores the content settings exceptions to the obsolete preference for |
202 // preference for notification and geolocation content settings exceptions. | 193 // geolocation content settings exceptions. This is necessary to allow |
203 // This is necessary to allow notifications and geolocation content settings | 194 // geolocation content settings exceptions being synced to older versions of |
204 // exceptions being synced to older versions of chrome that only use the | 195 // chrome that only use the obsolete preference. |
205 // obsolete preference. | 196 void SyncObsoleteGeolocationPref(); |
206 void SyncObsoletePrefs(); | |
207 | 197 |
208 static void CanonicalizeContentSettingsExceptions( | 198 static void CanonicalizeContentSettingsExceptions( |
209 base::DictionaryValue* all_settings_dictionary); | 199 base::DictionaryValue* all_settings_dictionary); |
210 | 200 |
211 // Weak; owned by the Profile and reset in ShutdownOnUIThread. | 201 // Weak; owned by the Profile and reset in ShutdownOnUIThread. |
212 PrefService* prefs_; | 202 PrefService* prefs_; |
213 | 203 |
214 bool is_incognito_; | 204 bool is_incognito_; |
215 | 205 |
216 PrefChangeRegistrar pref_change_registrar_; | 206 PrefChangeRegistrar pref_change_registrar_; |
217 | 207 |
218 // Whether we are currently updating preferences, this is used to ignore | 208 // Whether we are currently updating preferences, this is used to ignore |
219 // notifications from the preferences service that we triggered ourself. | 209 // notifications from the preferences service that we triggered ourself. |
220 bool updating_preferences_; | 210 bool updating_preferences_; |
221 | 211 |
222 OriginIdentifierValueMap value_map_; | 212 OriginIdentifierValueMap value_map_; |
223 | 213 |
224 OriginIdentifierValueMap incognito_value_map_; | 214 OriginIdentifierValueMap incognito_value_map_; |
225 | 215 |
226 // Used around accesses to the value map objects to guarantee | 216 // Used around accesses to the value map objects to guarantee |
227 // thread safety. | 217 // thread safety. |
228 mutable base::Lock lock_; | 218 mutable base::Lock lock_; |
229 | 219 |
230 DISALLOW_COPY_AND_ASSIGN(PrefProvider); | 220 DISALLOW_COPY_AND_ASSIGN(PrefProvider); |
231 }; | 221 }; |
232 | 222 |
233 } // namespace content_settings | 223 } // namespace content_settings |
234 | 224 |
235 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ | 225 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ |
OLD | NEW |