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