| 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 // Maps hostnames to custom content settings. Written on the UI thread and read | 5 // Maps hostnames to custom content settings. Written on the UI thread and read |
| 6 // on any thread. One instance per profile. | 6 // on any thread. One instance per profile. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 8 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
| 9 #define CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 9 #define CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
| 10 #pragma once | 10 #pragma once |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } // namespace content_settings | 31 } // namespace content_settings |
| 32 | 32 |
| 33 class ContentSettingsDetails; | 33 class ContentSettingsDetails; |
| 34 class DictionaryValue; | 34 class DictionaryValue; |
| 35 class GURL; | 35 class GURL; |
| 36 class PrefService; | 36 class PrefService; |
| 37 class Profile; | 37 class Profile; |
| 38 | 38 |
| 39 class HostContentSettingsMap | 39 class HostContentSettingsMap |
| 40 : public NotificationObserver, | 40 : public NotificationObserver, |
| 41 public base::RefCountedThreadSafe<HostContentSettingsMap, | 41 public base::RefCountedThreadSafe<HostContentSettingsMap> { |
| 42 BrowserThread::DeleteOnUIThread> { | |
| 43 public: | 42 public: |
| 44 typedef Tuple3<ContentSettingsPattern, ContentSetting, std::string> | 43 typedef Tuple3<ContentSettingsPattern, ContentSetting, std::string> |
| 45 PatternSettingSourceTriple; | 44 PatternSettingSourceTriple; |
| 46 typedef std::vector<PatternSettingSourceTriple> SettingsForOneType; | 45 typedef std::vector<PatternSettingSourceTriple> SettingsForOneType; |
| 47 | 46 |
| 48 explicit HostContentSettingsMap(Profile* profile); | 47 explicit HostContentSettingsMap(Profile* profile); |
| 49 | 48 |
| 50 static void RegisterUserPrefs(PrefService* prefs); | 49 static void RegisterUserPrefs(PrefService* prefs); |
| 51 | 50 |
| 52 // Returns the default setting for a particular content type. | 51 // Returns the default setting for a particular content type. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 // Afterwards, none of the methods above that should only be called on the UI | 186 // Afterwards, none of the methods above that should only be called on the UI |
| 188 // thread should be called anymore. | 187 // thread should be called anymore. |
| 189 void ShutdownOnUIThread(); | 188 void ShutdownOnUIThread(); |
| 190 | 189 |
| 191 // NotificationObserver implementation. | 190 // NotificationObserver implementation. |
| 192 virtual void Observe(NotificationType type, | 191 virtual void Observe(NotificationType type, |
| 193 const NotificationSource& source, | 192 const NotificationSource& source, |
| 194 const NotificationDetails& details); | 193 const NotificationDetails& details); |
| 195 | 194 |
| 196 private: | 195 private: |
| 197 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 196 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; |
| 198 friend class DeleteTask<HostContentSettingsMap>; | |
| 199 | 197 |
| 200 virtual ~HostContentSettingsMap(); | 198 virtual ~HostContentSettingsMap(); |
| 201 | 199 |
| 202 ContentSetting GetContentSettingInternal( | 200 ContentSetting GetContentSettingInternal( |
| 203 const GURL& primary_url, | 201 const GURL& primary_url, |
| 204 const GURL& secondary_url, | 202 const GURL& secondary_url, |
| 205 ContentSettingsType content_type, | 203 ContentSettingsType content_type, |
| 206 const std::string& resource_identifier) const; | 204 const std::string& resource_identifier) const; |
| 207 | 205 |
| 208 void UnregisterObservers(); | |
| 209 | |
| 210 // Various migration methods (old cookie, popup and per-host data gets | 206 // Various migration methods (old cookie, popup and per-host data gets |
| 211 // migrated to the new format). | 207 // migrated to the new format). |
| 212 void MigrateObsoleteCookiePref(PrefService* prefs); | 208 void MigrateObsoleteCookiePref(); |
| 213 | 209 |
| 214 // The profile we're associated with. | 210 // Weak; owned by the Profile. |
| 215 Profile* profile_; | 211 PrefService* prefs_; |
| 216 | 212 |
| 217 NotificationRegistrar notification_registrar_; | |
| 218 PrefChangeRegistrar pref_change_registrar_; | 213 PrefChangeRegistrar pref_change_registrar_; |
| 219 | 214 |
| 220 // Whether this settings map is for an OTR session. | 215 // Whether this settings map is for an OTR session. |
| 221 bool is_off_the_record_; | 216 bool is_off_the_record_; |
| 222 | 217 |
| 223 // Whether we are currently updating preferences, this is used to ignore | 218 // Whether we are currently updating preferences, this is used to ignore |
| 224 // notifications from the preferences service that we triggered ourself. | 219 // notifications from the preferences service that we triggered ourself. |
| 225 bool updating_preferences_; | 220 bool updating_preferences_; |
| 226 | 221 |
| 227 // Default content setting providers. | 222 // Default content setting providers. |
| 228 std::vector<linked_ptr<content_settings::DefaultProviderInterface> > | 223 std::vector<linked_ptr<content_settings::DefaultProviderInterface> > |
| 229 default_content_settings_providers_; | 224 default_content_settings_providers_; |
| 230 | 225 |
| 231 // Content setting providers. | 226 // Content setting providers. |
| 232 std::vector<linked_ptr<content_settings::ProviderInterface> > | 227 std::vector<linked_ptr<content_settings::ProviderInterface> > |
| 233 content_settings_providers_; | 228 content_settings_providers_; |
| 234 | 229 |
| 235 // Used around accesses to the following objects to guarantee thread safety. | 230 // Used around accesses to the following objects to guarantee thread safety. |
| 236 mutable base::Lock lock_; | 231 mutable base::Lock lock_; |
| 237 | 232 |
| 238 // Misc global settings. | 233 // Misc global settings. |
| 239 bool block_third_party_cookies_; | 234 bool block_third_party_cookies_; |
| 240 bool is_block_third_party_cookies_managed_; | 235 bool is_block_third_party_cookies_managed_; |
| 241 | 236 |
| 242 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 237 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
| 243 }; | 238 }; |
| 244 | 239 |
| 245 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 240 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
| OLD | NEW |