Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: chrome/browser/content_settings/pref_content_settings_provider.h

Issue 6484035: Add a content_settings::BaseProvider for code that is shared by all content settings providers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 // PolicyProvider that provides content settings from the user preference.
Bernhard Bauer 2011/02/14 16:58:36 You mean ContentSettingsProvider?
markusheintz_ 2011/02/14 18:25:28 Of course. Done :-)
94 class PrefProvider : public BaseProvider,
94 public NotificationObserver { 95 public NotificationObserver {
95 public: 96 public:
96 static void RegisterUserPrefs(PrefService* prefs); 97 static void RegisterUserPrefs(PrefService* prefs);
97 98
98 explicit PrefProvider(Profile* profile); 99 explicit PrefProvider(Profile* profile);
99 virtual ~PrefProvider(); 100 virtual ~PrefProvider();
100 101
101 // ContentSettingsProvider implementation. 102 // ContentSettingsProvider implementation.
102 virtual bool ContentSettingsTypeIsManaged( 103 virtual bool ContentSettingsTypeIsManaged(
103 ContentSettingsType content_type); 104 ContentSettingsType content_type);
104 105
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( 106 virtual void SetContentSetting(
112 const ContentSettingsPattern& requesting_pattern, 107 const ContentSettingsPattern& requesting_pattern,
113 const ContentSettingsPattern& embedding_pattern, 108 const ContentSettingsPattern& embedding_pattern,
114 ContentSettingsType content_type, 109 ContentSettingsType content_type,
115 const ResourceIdentifier& resource_identifier, 110 const ResourceIdentifier& resource_identifier,
116 ContentSetting content_setting); 111 ContentSetting content_setting);
117 112
118 virtual void GetAllContentSettingsRules(
119 ContentSettingsType content_type,
120 const ResourceIdentifier& resource_identifier,
121 Rules* content_setting_rules) const;
122
123 virtual void ClearAllContentSettingsRules( 113 virtual void ClearAllContentSettingsRules(
124 ContentSettingsType content_type); 114 ContentSettingsType content_type);
125 115
126 virtual void ResetToDefaults(); 116 virtual void ResetToDefaults();
127 117
118 // BaseProvider implementations.
119 virtual void Init();
120
128 // NotificationObserver implementation. 121 // NotificationObserver implementation.
129 virtual void Observe(NotificationType type, 122 virtual void Observe(NotificationType type,
130 const NotificationSource& source, 123 const NotificationSource& source,
131 const NotificationDetails& details); 124 const NotificationDetails& details);
132 125
133 private: 126 private:
134 typedef std::pair<ContentSettingsType, std::string> 127 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 128
143 // Various migration methods (old cookie, popup and per-host data gets 129 // Various migration methods (old cookie, popup and per-host data gets
144 // migrated to the new format). 130 // migrated to the new format).
145 void MigrateObsoletePerhostPref(PrefService* prefs); 131 void MigrateObsoletePerhostPref(PrefService* prefs);
146 void MigrateObsoletePopupsPref(PrefService* prefs); 132 void MigrateObsoletePopupsPref(PrefService* prefs);
147 133
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( 134 void CanonicalizeContentSettingsExceptions(
156 DictionaryValue* all_settings_dictionary); 135 DictionaryValue* all_settings_dictionary);
157 136
158 void GetSettingsFromDictionary( 137 void GetSettingsFromDictionary(
159 const DictionaryValue* dictionary, 138 const DictionaryValue* dictionary,
160 ContentSettings* settings); 139 ContentSettings* settings);
161 140
162 void GetResourceSettingsFromDictionary( 141 void GetResourceSettingsFromDictionary(
163 const DictionaryValue* dictionary, 142 const DictionaryValue* dictionary,
164 ResourceContentSettings* settings); 143 ResourceContentSettings* settings);
165 144
166 void NotifyObservers(const ContentSettingsDetails& details); 145 void NotifyObservers(const ContentSettingsDetails& details);
167 146
168 void UnregisterObservers(); 147 void UnregisterObservers();
169 148
170 Profile* profile_; 149 Profile* profile_;
171 150
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_; 151 PrefChangeRegistrar pref_change_registrar_;
180 NotificationRegistrar notification_registrar_; 152 NotificationRegistrar notification_registrar_;
181 153
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 154 // Whether we are currently updating preferences, this is used to ignore
191 // notifications from the preferences service that we triggered ourself. 155 // notifications from the preferences service that we triggered ourself.
192 bool updating_preferences_; 156 bool updating_preferences_;
193 157
194 // Do not fire any Notifications as long as we are in the constructor. 158 // Do not fire any Notifications as long as we are in the constructor.
195 bool initializing_; 159 bool initializing_;
196 160
197 // LEGACY: TBR
198 ContentSettings GetNonDefaultContentSettings(const GURL& url) const;
199
200 DISALLOW_COPY_AND_ASSIGN(PrefProvider); 161 DISALLOW_COPY_AND_ASSIGN(PrefProvider);
201 }; 162 };
202 163
203 } // namespace content_settings 164 } // namespace content_settings
204 165
205 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PREF_CONTENT_SETTINGS_PROVIDER_H_ 166 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PREF_CONTENT_SETTINGS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698