| 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 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "chrome/browser/content_settings/content_settings_origin_identifier_val
ue_map.h" | 17 #include "chrome/browser/content_settings/content_settings_origin_identifier_val
ue_map.h" |
| 18 #include "chrome/browser/content_settings/content_settings_provider.h" | 18 #include "chrome/browser/content_settings/content_settings_abstract_provider.h" |
| 19 #include "chrome/browser/content_settings/content_settings_utils.h" | 19 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 20 #include "chrome/browser/prefs/pref_change_registrar.h" | 20 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 21 #include "content/common/notification_observer.h" | 21 #include "content/common/notification_observer.h" |
| 22 #include "content/common/notification_registrar.h" | 22 #include "content/common/notification_registrar.h" |
| 23 | 23 |
| 24 class ContentSettingsDetails; | 24 class ContentSettingsDetails; |
| 25 class DictionaryValue; | 25 class DictionaryValue; |
| 26 class HostContentSettingsMap; | 26 class HostContentSettingsMap; |
| 27 class PrefService; | 27 class PrefService; |
| 28 | 28 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 // Whether we are currently updating preferences, this is used to ignore | 93 // Whether we are currently updating preferences, this is used to ignore |
| 94 // notifications from the preferences service that we triggered ourself. | 94 // notifications from the preferences service that we triggered ourself. |
| 95 bool updating_preferences_; | 95 bool updating_preferences_; |
| 96 | 96 |
| 97 DISALLOW_COPY_AND_ASSIGN(PrefDefaultProvider); | 97 DISALLOW_COPY_AND_ASSIGN(PrefDefaultProvider); |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 // Content settings provider that provides content settings from the user | 100 // Content settings provider that provides content settings from the user |
| 101 // preference. | 101 // preference. |
| 102 class PrefProvider : public ProviderInterface, | 102 class PrefProvider : public AbstractProvider, |
| 103 public NotificationObserver { | 103 public NotificationObserver { |
| 104 public: | 104 public: |
| 105 static void RegisterUserPrefs(PrefService* prefs); | 105 static void RegisterUserPrefs(PrefService* prefs); |
| 106 | 106 |
| 107 PrefProvider(HostContentSettingsMap* map, | 107 PrefProvider(Observer* observer, |
| 108 PrefService* prefs, | 108 PrefService* prefs, |
| 109 bool incognito); | 109 bool incognito); |
| 110 virtual ~PrefProvider(); | 110 virtual ~PrefProvider(); |
| 111 | 111 |
| 112 // ProviderInterface implementations. | 112 // ProviderInterface implementations. |
| 113 virtual void SetContentSetting( | 113 virtual void SetContentSetting( |
| 114 const ContentSettingsPattern& primary_pattern, | 114 const ContentSettingsPattern& primary_pattern, |
| 115 const ContentSettingsPattern& secondary_pattern, | 115 const ContentSettingsPattern& secondary_pattern, |
| 116 ContentSettingsType content_type, | 116 ContentSettingsType content_type, |
| 117 const ResourceIdentifier& resource_identifier, | 117 const ResourceIdentifier& resource_identifier, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 // Copies the value of the preference that stores the content settings | 183 // Copies the value of the preference that stores the content settings |
| 184 // exceptions to the obsolete preference for content settings exceptions. This | 184 // exceptions to the obsolete preference for content settings exceptions. This |
| 185 // is necessary to allow content settings exceptions beeing synced to older | 185 // is necessary to allow content settings exceptions beeing synced to older |
| 186 // versions of chrome that only use the obsolete. | 186 // versions of chrome that only use the obsolete. |
| 187 void SyncObsoletePref(); | 187 void SyncObsoletePref(); |
| 188 | 188 |
| 189 static void CanonicalizeContentSettingsExceptions( | 189 static void CanonicalizeContentSettingsExceptions( |
| 190 DictionaryValue* all_settings_dictionary); | 190 DictionaryValue* all_settings_dictionary); |
| 191 | 191 |
| 192 void NotifyObservers(const ContentSettingsDetails& details); | |
| 193 | |
| 194 // Weak; owned by the Profile and reset in ShutdownOnUIThread. | 192 // Weak; owned by the Profile and reset in ShutdownOnUIThread. |
| 195 PrefService* prefs_; | 193 PrefService* prefs_; |
| 196 | 194 |
| 197 // Weak; owns us | |
| 198 HostContentSettingsMap* host_content_settings_map_; | |
| 199 | |
| 200 bool is_incognito_; | 195 bool is_incognito_; |
| 201 | 196 |
| 202 PrefChangeRegistrar pref_change_registrar_; | 197 PrefChangeRegistrar pref_change_registrar_; |
| 203 | 198 |
| 204 // Whether we are currently updating preferences, this is used to ignore | 199 // Whether we are currently updating preferences, this is used to ignore |
| 205 // notifications from the preferences service that we triggered ourself. | 200 // notifications from the preferences service that we triggered ourself. |
| 206 bool updating_preferences_; | 201 bool updating_preferences_; |
| 207 | 202 |
| 208 OriginIdentifierValueMap value_map_; | 203 OriginIdentifierValueMap value_map_; |
| 209 | 204 |
| 210 OriginIdentifierValueMap incognito_value_map_; | 205 OriginIdentifierValueMap incognito_value_map_; |
| 211 | 206 |
| 212 // Used around accesses to the value map objects to guarantee | 207 // Used around accesses to the value map objects to guarantee |
| 213 // thread safety. | 208 // thread safety. |
| 214 mutable base::Lock lock_; | 209 mutable base::Lock lock_; |
| 215 | 210 |
| 216 DISALLOW_COPY_AND_ASSIGN(PrefProvider); | 211 DISALLOW_COPY_AND_ASSIGN(PrefProvider); |
| 217 }; | 212 }; |
| 218 | 213 |
| 219 } // namespace content_settings | 214 } // namespace content_settings |
| 220 | 215 |
| 221 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ | 216 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ |
| OLD | NEW |