| 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 |
| 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 the geolocation content settings exceptions from the preference that |
| 184 // stores the content settings exceptions to the obsolete preference for |
| 185 // geolocation content settings exceptions. This is necessary to allow |
| 186 // geolocation content settings exceptions being synced to older versions of |
| 187 // chrome that only use the obsolete preference. |
| 188 void SyncObsoleteGeolocationPref(); |
| 183 | 189 |
| 184 static void CanonicalizeContentSettingsExceptions( | 190 static void CanonicalizeContentSettingsExceptions( |
| 185 base::DictionaryValue* all_settings_dictionary); | 191 base::DictionaryValue* all_settings_dictionary); |
| 186 | 192 |
| 187 // Weak; owned by the Profile and reset in ShutdownOnUIThread. | 193 // Weak; owned by the Profile and reset in ShutdownOnUIThread. |
| 188 PrefService* prefs_; | 194 PrefService* prefs_; |
| 189 | 195 |
| 190 bool is_incognito_; | 196 bool is_incognito_; |
| 191 | 197 |
| 192 PrefChangeRegistrar pref_change_registrar_; | 198 PrefChangeRegistrar pref_change_registrar_; |
| 193 | 199 |
| 194 // Whether we are currently updating preferences, this is used to ignore | 200 // Whether we are currently updating preferences, this is used to ignore |
| 195 // notifications from the preferences service that we triggered ourself. | 201 // notifications from the preferences service that we triggered ourself. |
| 196 bool updating_preferences_; | 202 bool updating_preferences_; |
| 197 | 203 |
| 198 OriginIdentifierValueMap value_map_; | 204 OriginIdentifierValueMap value_map_; |
| 199 | 205 |
| 200 OriginIdentifierValueMap incognito_value_map_; | 206 OriginIdentifierValueMap incognito_value_map_; |
| 201 | 207 |
| 202 // Used around accesses to the value map objects to guarantee | 208 // Used around accesses to the value map objects to guarantee |
| 203 // thread safety. | 209 // thread safety. |
| 204 mutable base::Lock lock_; | 210 mutable base::Lock lock_; |
| 205 | 211 |
| 206 DISALLOW_COPY_AND_ASSIGN(PrefProvider); | 212 DISALLOW_COPY_AND_ASSIGN(PrefProvider); |
| 207 }; | 213 }; |
| 208 | 214 |
| 209 } // namespace content_settings | 215 } // namespace content_settings |
| 210 | 216 |
| 211 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ | 217 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ |
| OLD | NEW |