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_PREF_CONTENT_SETTINGS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_PREF_CONTENT_SETTINGS_PROVIDER_H_ | 
| 6 #define CHROME_BROWSER_CONTENT_SETTINGS_PREF_CONTENT_SETTINGS_PROVIDER_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_PREF_CONTENT_SETTINGS_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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 PrefChangeRegistrar pref_change_registrar_; | 83 PrefChangeRegistrar pref_change_registrar_; | 
| 84 NotificationRegistrar notification_registrar_; | 84 NotificationRegistrar notification_registrar_; | 
| 85 | 85 | 
| 86 // Whether we are currently updating preferences, this is used to ignore | 86 // Whether we are currently updating preferences, this is used to ignore | 
| 87 // notifications from the preferences service that we triggered ourself. | 87 // notifications from the preferences service that we triggered ourself. | 
| 88 bool updating_preferences_; | 88 bool updating_preferences_; | 
| 89 | 89 | 
| 90 DISALLOW_COPY_AND_ASSIGN(PrefDefaultProvider); | 90 DISALLOW_COPY_AND_ASSIGN(PrefDefaultProvider); | 
| 91 }; | 91 }; | 
| 92 | 92 | 
| 93 class PrefProvider : public ProviderInterface, | 93 // Content-settings-provider that provides content-settings from the user | 
| 
 
Bernhard Bauer
2011/02/15 09:55:25
Nit: Why the dashes?
 
markusheintz_
2011/02/15 11:00:16
For consistence.
e.g. host-content-settings-maps
 
 | |
| 94 // preference. | |
| 95 class PrefProvider : public BaseProvider, | |
| 94 public NotificationObserver { | 96 public NotificationObserver { | 
| 95 public: | 97 public: | 
| 96 static void RegisterUserPrefs(PrefService* prefs); | 98 static void RegisterUserPrefs(PrefService* prefs); | 
| 97 | 99 | 
| 98 explicit PrefProvider(Profile* profile); | 100 explicit PrefProvider(Profile* profile); | 
| 99 virtual ~PrefProvider(); | 101 virtual ~PrefProvider(); | 
| 100 | 102 | 
| 101 // ContentSettingsProvider implementation. | 103 // ContentSettingsProvider implementation. | 
| 102 virtual bool ContentSettingsTypeIsManaged( | 104 virtual bool ContentSettingsTypeIsManaged( | 
| 103 ContentSettingsType content_type); | 105 ContentSettingsType content_type); | 
| 104 | 106 | 
| 105 virtual ContentSetting GetContentSetting( | |
| 106 const GURL& requesting_url, | |
| 107 const GURL& embedding_url, | |
| 108 ContentSettingsType content_type, | |
| 109 const ResourceIdentifier& resource_identifier) const; | |
| 110 | |
| 111 virtual void SetContentSetting( | 107 virtual void SetContentSetting( | 
| 112 const ContentSettingsPattern& requesting_pattern, | 108 const ContentSettingsPattern& requesting_pattern, | 
| 113 const ContentSettingsPattern& embedding_pattern, | 109 const ContentSettingsPattern& embedding_pattern, | 
| 114 ContentSettingsType content_type, | 110 ContentSettingsType content_type, | 
| 115 const ResourceIdentifier& resource_identifier, | 111 const ResourceIdentifier& resource_identifier, | 
| 116 ContentSetting content_setting); | 112 ContentSetting content_setting); | 
| 117 | 113 | 
| 118 virtual void GetAllContentSettingsRules( | |
| 119 ContentSettingsType content_type, | |
| 120 const ResourceIdentifier& resource_identifier, | |
| 121 Rules* content_setting_rules) const; | |
| 122 | |
| 123 virtual void ClearAllContentSettingsRules( | 114 virtual void ClearAllContentSettingsRules( | 
| 124 ContentSettingsType content_type); | 115 ContentSettingsType content_type); | 
| 125 | 116 | 
| 126 virtual void ResetToDefaults(); | 117 virtual void ResetToDefaults(); | 
| 127 | 118 | 
| 119 // BaseProvider implementations. | |
| 120 virtual void Init(); | |
| 121 | |
| 128 // NotificationObserver implementation. | 122 // NotificationObserver implementation. | 
| 129 virtual void Observe(NotificationType type, | 123 virtual void Observe(NotificationType type, | 
| 130 const NotificationSource& source, | 124 const NotificationSource& source, | 
| 131 const NotificationDetails& details); | 125 const NotificationDetails& details); | 
| 132 | 126 | 
| 133 private: | 127 private: | 
| 134 typedef std::pair<ContentSettingsType, std::string> | 128 void ReadExceptions(bool overwrite); | 
| 135 ContentSettingsTypeResourceIdentifierPair; | |
| 136 typedef std::map<ContentSettingsTypeResourceIdentifierPair, ContentSetting> | |
| 137 ResourceContentSettings; | |
| 138 | |
| 139 struct ExtendedContentSettings; | |
| 140 | |
| 141 typedef std::map<std::string, ExtendedContentSettings> HostContentSettings; | |
| 142 | 129 | 
| 143 // Various migration methods (old cookie, popup and per-host data gets | 130 // Various migration methods (old cookie, popup and per-host data gets | 
| 144 // migrated to the new format). | 131 // migrated to the new format). | 
| 145 void MigrateObsoletePerhostPref(PrefService* prefs); | 132 void MigrateObsoletePerhostPref(PrefService* prefs); | 
| 146 void MigrateObsoletePopupsPref(PrefService* prefs); | 133 void MigrateObsoletePopupsPref(PrefService* prefs); | 
| 147 | 134 | 
| 148 bool AllDefault(const ExtendedContentSettings& settings) const; | |
| 149 | |
| 150 void ReadExceptions(bool overwrite); | |
| 151 | |
| 152 bool RequiresResourceIdentifier( | |
| 153 ContentSettingsType content_type) const; | |
| 154 | |
| 155 void CanonicalizeContentSettingsExceptions( | 135 void CanonicalizeContentSettingsExceptions( | 
| 156 DictionaryValue* all_settings_dictionary); | 136 DictionaryValue* all_settings_dictionary); | 
| 157 | 137 | 
| 158 void GetSettingsFromDictionary( | 138 void GetSettingsFromDictionary( | 
| 159 const DictionaryValue* dictionary, | 139 const DictionaryValue* dictionary, | 
| 160 ContentSettings* settings); | 140 ContentSettings* settings); | 
| 161 | 141 | 
| 162 void GetResourceSettingsFromDictionary( | 142 void GetResourceSettingsFromDictionary( | 
| 163 const DictionaryValue* dictionary, | 143 const DictionaryValue* dictionary, | 
| 164 ResourceContentSettings* settings); | 144 ResourceContentSettings* settings); | 
| 165 | 145 | 
| 166 void NotifyObservers(const ContentSettingsDetails& details); | 146 void NotifyObservers(const ContentSettingsDetails& details); | 
| 167 | 147 | 
| 168 void UnregisterObservers(); | 148 void UnregisterObservers(); | 
| 169 | 149 | 
| 170 Profile* profile_; | 150 Profile* profile_; | 
| 171 | 151 | 
| 172 // Whether this settings map is for an OTR session. | |
| 173 bool is_off_the_record_; | |
| 174 | |
| 175 // Used around accesses to the content_settings_ object to guarantee | |
| 176 // thread safety. | |
| 177 mutable base::Lock lock_; | |
| 178 | |
| 179 PrefChangeRegistrar pref_change_registrar_; | 152 PrefChangeRegistrar pref_change_registrar_; | 
| 180 NotificationRegistrar notification_registrar_; | 153 NotificationRegistrar notification_registrar_; | 
| 181 | 154 | 
| 182 // Copies of the pref data, so that we can read it on threads other than the | |
| 183 // UI thread. | |
| 184 HostContentSettings host_content_settings_; | |
| 185 | |
| 186 // Differences to the preference-stored host content settings for | |
| 187 // off-the-record settings. | |
| 188 HostContentSettings off_the_record_settings_; | |
| 189 | |
| 190 // Whether we are currently updating preferences, this is used to ignore | 155 // Whether we are currently updating preferences, this is used to ignore | 
| 191 // notifications from the preferences service that we triggered ourself. | 156 // notifications from the preferences service that we triggered ourself. | 
| 192 bool updating_preferences_; | 157 bool updating_preferences_; | 
| 193 | 158 | 
| 194 // Do not fire any Notifications as long as we are in the constructor. | 159 // Do not fire any Notifications as long as we are in the constructor. | 
| 195 bool initializing_; | 160 bool initializing_; | 
| 196 | 161 | 
| 197 // LEGACY: TBR | |
| 198 ContentSettings GetNonDefaultContentSettings(const GURL& url) const; | |
| 199 | |
| 200 DISALLOW_COPY_AND_ASSIGN(PrefProvider); | 162 DISALLOW_COPY_AND_ASSIGN(PrefProvider); | 
| 201 }; | 163 }; | 
| 202 | 164 | 
| 203 } // namespace content_settings | 165 } // namespace content_settings | 
| 204 | 166 | 
| 205 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PREF_CONTENT_SETTINGS_PROVIDER_H_ | 167 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PREF_CONTENT_SETTINGS_PROVIDER_H_ | 
| OLD | NEW |