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 |
| 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_base_provider.h" | |
| 18 #include "chrome/browser/content_settings/content_settings_provider.h" | 17 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 18 #include "chrome/browser/content_settings/content_settings_origin_identifier_val ue_map.h" | |
| 19 #include "chrome/browser/prefs/pref_change_registrar.h" | 19 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 20 #include "content/common/notification_observer.h" | 20 #include "content/common/notification_observer.h" |
| 21 #include "content/common/notification_registrar.h" | 21 #include "content/common/notification_registrar.h" |
| 22 | 22 |
| 23 // TODO | |
| 24 #include "chrome/browser/content_settings/content_settings_base_provider.h" | |
| 25 | |
| 23 class ContentSettingsDetails; | 26 class ContentSettingsDetails; |
| 24 class DictionaryValue; | 27 class DictionaryValue; |
| 25 class PrefService; | 28 class PrefService; |
| 26 class Profile; | 29 class Profile; |
| 27 | 30 |
| 28 namespace content_settings { | 31 namespace content_settings { |
| 29 | 32 |
| 30 // Content settings provider that provides default content settings based on | 33 // Content settings provider that provides default content settings based on |
| 31 // user prefs. | 34 // user prefs. |
| 32 class PrefDefaultProvider : public DefaultProviderInterface, | 35 class PrefDefaultProvider : public DefaultProviderInterface, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 // notifications from the preferences service that we triggered ourself. | 95 // notifications from the preferences service that we triggered ourself. |
| 93 bool updating_preferences_; | 96 bool updating_preferences_; |
| 94 | 97 |
| 95 bool initializing_; | 98 bool initializing_; |
| 96 | 99 |
| 97 DISALLOW_COPY_AND_ASSIGN(PrefDefaultProvider); | 100 DISALLOW_COPY_AND_ASSIGN(PrefDefaultProvider); |
| 98 }; | 101 }; |
| 99 | 102 |
| 100 // Content settings provider that provides content settings from the user | 103 // Content settings provider that provides content settings from the user |
| 101 // preference. | 104 // preference. |
| 102 class PrefProvider : public BaseProvider, | 105 class PrefProvider : public ProviderInterface, |
| 103 public NotificationObserver { | 106 public NotificationObserver { |
| 104 public: | 107 public: |
| 105 static void RegisterUserPrefs(PrefService* prefs); | 108 static void RegisterUserPrefs(PrefService* prefs); |
| 106 | 109 |
| 107 explicit PrefProvider(Profile* profile); | 110 explicit PrefProvider(Profile* profile); |
| 108 virtual ~PrefProvider(); | 111 virtual ~PrefProvider(); |
| 109 | 112 |
| 113 // ProviderInterface implementations. | |
| 114 virtual void Init(); | |
| 115 | |
| 110 virtual void SetContentSetting( | 116 virtual void SetContentSetting( |
| 111 const ContentSettingsPattern& requesting_pattern, | 117 const ContentSettingsPattern& requesting_pattern, |
| 112 const ContentSettingsPattern& embedding_pattern, | 118 const ContentSettingsPattern& embedding_pattern, |
| 113 ContentSettingsType content_type, | 119 ContentSettingsType content_type, |
| 114 const ResourceIdentifier& resource_identifier, | 120 const ResourceIdentifier& resource_identifier, |
| 115 ContentSetting content_setting); | 121 ContentSetting content_setting); |
| 116 | 122 |
| 123 virtual ContentSetting GetContentSetting( | |
| 124 const GURL& requesting_url, | |
| 125 const GURL& embedding_url, | |
| 126 ContentSettingsType content_type, | |
| 127 const ResourceIdentifier& resource_identifier) const; | |
| 128 | |
| 129 virtual void GetAllContentSettingsRules( | |
| 130 ContentSettingsType content_type, | |
| 131 const ResourceIdentifier& resource_identifier, | |
| 132 Rules* content_setting_rules) const; | |
| 133 | |
| 117 virtual void ClearAllContentSettingsRules( | 134 virtual void ClearAllContentSettingsRules( |
| 118 ContentSettingsType content_type); | 135 ContentSettingsType content_type); |
| 119 | 136 |
| 120 virtual void ResetToDefaults(); | 137 virtual void ResetToDefaults(); |
| 121 | 138 |
| 122 // BaseProvider implementations. | |
| 123 virtual void Init(); | |
| 124 | |
| 125 // NotificationObserver implementation. | 139 // NotificationObserver implementation. |
| 126 virtual void Observe(NotificationType type, | 140 virtual void Observe(NotificationType type, |
| 127 const NotificationSource& source, | 141 const NotificationSource& source, |
| 128 const NotificationDetails& details); | 142 const NotificationDetails& details); |
| 129 | 143 |
| 130 private: | 144 private: |
| 131 void ReadExceptions(bool overwrite); | 145 void ReadExceptions(bool overwrite); |
| 132 | 146 |
| 133 // Various migration methods (old cookie, popup and per-host data gets | 147 // Various migration methods (old cookie, popup and per-host data gets |
| 134 // migrated to the new format). | 148 // migrated to the new format). |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 145 void GetResourceSettingsFromDictionary( | 159 void GetResourceSettingsFromDictionary( |
| 146 const DictionaryValue* dictionary, | 160 const DictionaryValue* dictionary, |
| 147 ResourceContentSettings* settings); | 161 ResourceContentSettings* settings); |
| 148 | 162 |
| 149 void NotifyObservers(const ContentSettingsDetails& details); | 163 void NotifyObservers(const ContentSettingsDetails& details); |
| 150 | 164 |
| 151 void UnregisterObservers(); | 165 void UnregisterObservers(); |
| 152 | 166 |
| 153 Profile* profile_; | 167 Profile* profile_; |
| 154 | 168 |
| 169 bool is_incognito_; | |
| 170 | |
| 155 PrefChangeRegistrar pref_change_registrar_; | 171 PrefChangeRegistrar pref_change_registrar_; |
| 156 NotificationRegistrar notification_registrar_; | 172 NotificationRegistrar notification_registrar_; |
| 157 | 173 |
| 158 // Whether we are currently updating preferences, this is used to ignore | 174 // Whether we are currently updating preferences, this is used to ignore |
| 159 // notifications from the preferences service that we triggered ourself. | 175 // notifications from the preferences service that we triggered ourself. |
| 160 bool updating_preferences_; | 176 bool updating_preferences_; |
| 161 | 177 |
| 162 // Do not fire any Notifications as long as we are in the constructor. | 178 // Do not fire any Notifications as long as we are in the constructor. |
| 163 bool initializing_; | 179 bool initializing_; |
| 164 | 180 |
| 181 OriginIdentifierValueMap value_map_; | |
| 182 | |
| 183 OriginIdentifierValueMap incognito_value_map_; | |
| 184 | |
| 185 // Used around accesses to the content_settings_ object to guarantee | |
|
Bernhard Bauer
2011/05/24 14:21:29
Nit: "around accesses to the value maps" or someth
markusheintz_
2011/05/26 13:22:13
Done.
| |
| 186 // thread safety. | |
| 187 mutable base::Lock lock_; | |
| 188 | |
| 165 DISALLOW_COPY_AND_ASSIGN(PrefProvider); | 189 DISALLOW_COPY_AND_ASSIGN(PrefProvider); |
| 166 }; | 190 }; |
| 167 | 191 |
| 168 } // namespace content_settings | 192 } // namespace content_settings |
| 169 | 193 |
| 170 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ | 194 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ |
| OLD | NEW |