Chromium Code Reviews| 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 settigns exceptions and supposed to replace the preferences |
|
Bernhard Bauer
2011/08/03 15:22:50
Nit: "settings".
markusheintz_
2011/08/04 12:45:56
Done.
| |
| 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 |
| 172 // Various migration methods (old cookie, popup and per-host data gets | 170 // Various migration methods (old cookie, popup and per-host data gets |
| 173 // migrated to the new format). | 171 // migrated to the new format). |
| 174 void MigrateObsoletePerhostPref(); | 172 void MigrateObsoletePerhostPref(); |
| 175 void MigrateObsoletePopupsPref(); | 173 void MigrateObsoletePopupsPref(); |
| 176 void MigrateObsoleteContentSettingsPatternPref(); | 174 void MigrateObsoleteContentSettingsPatternPref(); |
| 175 void MigrateObsoleteGeolocationPref(); | |
| 177 | 176 |
| 178 // Copies the value of the preference that stores the content settings | 177 // Copies the value of the preference that stores the content settings |
| 179 // exceptions to the obsolete preference for content settings exceptions. This | 178 // exceptions to the obsolete preference for content settings exceptions. This |
| 180 // is necessary to allow content settings exceptions beeing synced to older | 179 // is necessary to allow content settings exceptions beeing synced to older |
| 181 // versions of chrome that only use the obsolete. | 180 // versions of chrome that only use the obsolete preference. |
| 182 void SyncObsoletePref(); | 181 void SyncObsoletePatternPref(); |
| 182 | |
| 183 // Copies geolocation content settings exceptions to the obsolete preference | |
|
Bernhard Bauer
2011/08/03 15:22:50
Can you explain that it copies from the new prefer
markusheintz_
2011/08/04 12:45:56
Done.
| |
| 184 // for geolocation content settings exceptions. This is necessary to allow | |
| 185 // geolocation content settings exceptions beeing synced to older versions of | |
|
Bernhard Bauer
2011/08/03 15:22:50
Nit: "being"
markusheintz_
2011/08/04 12:45:56
Done.
| |
| 186 // chrome that only use the obsolete preference. | |
| 187 void SyncObsoleteGeolocationPref(); | |
| 183 | 188 |
| 184 static void CanonicalizeContentSettingsExceptions( | 189 static void CanonicalizeContentSettingsExceptions( |
| 185 base::DictionaryValue* all_settings_dictionary); | 190 base::DictionaryValue* all_settings_dictionary); |
| 186 | 191 |
| 187 // Weak; owned by the Profile and reset in ShutdownOnUIThread. | 192 // Weak; owned by the Profile and reset in ShutdownOnUIThread. |
| 188 PrefService* prefs_; | 193 PrefService* prefs_; |
| 189 | 194 |
| 190 bool is_incognito_; | 195 bool is_incognito_; |
| 191 | 196 |
| 192 PrefChangeRegistrar pref_change_registrar_; | 197 PrefChangeRegistrar pref_change_registrar_; |
| 193 | 198 |
| 194 // Whether we are currently updating preferences, this is used to ignore | 199 // Whether we are currently updating preferences, this is used to ignore |
| 195 // notifications from the preferences service that we triggered ourself. | 200 // notifications from the preferences service that we triggered ourself. |
| 196 bool updating_preferences_; | 201 bool updating_preferences_; |
| 197 | 202 |
| 198 OriginIdentifierValueMap value_map_; | 203 OriginIdentifierValueMap value_map_; |
| 199 | 204 |
| 200 OriginIdentifierValueMap incognito_value_map_; | 205 OriginIdentifierValueMap incognito_value_map_; |
| 201 | 206 |
| 202 // Used around accesses to the value map objects to guarantee | 207 // Used around accesses to the value map objects to guarantee |
| 203 // thread safety. | 208 // thread safety. |
| 204 mutable base::Lock lock_; | 209 mutable base::Lock lock_; |
| 205 | 210 |
| 206 DISALLOW_COPY_AND_ASSIGN(PrefProvider); | 211 DISALLOW_COPY_AND_ASSIGN(PrefProvider); |
| 207 }; | 212 }; |
| 208 | 213 |
| 209 } // namespace content_settings | 214 } // namespace content_settings |
| 210 | 215 |
| 211 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ | 216 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ |
| OLD | NEW |