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 |
11 | 11 |
12 #include <map> | 12 #include <map> |
13 #include <string> | 13 #include <string> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/memory/linked_ptr.h" | 18 #include "base/memory/linked_ptr.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "base/synchronization/lock.h" | 20 #include "base/synchronization/lock.h" |
21 #include "chrome/browser/content_settings/content_settings_pattern.h" | 21 #include "chrome/browser/content_settings/content_settings_pattern.h" |
22 #include "chrome/browser/content_settings/content_settings_observer.h" | |
22 #include "chrome/browser/prefs/pref_change_registrar.h" | 23 #include "chrome/browser/prefs/pref_change_registrar.h" |
23 #include "chrome/common/content_settings.h" | 24 #include "chrome/common/content_settings.h" |
24 #include "content/browser/browser_thread.h" | 25 #include "content/browser/browser_thread.h" |
25 #include "content/common/notification_observer.h" | 26 #include "content/common/notification_observer.h" |
26 #include "content/common/notification_registrar.h" | 27 #include "content/common/notification_registrar.h" |
27 | 28 |
28 namespace content_settings { | 29 namespace content_settings { |
29 class DefaultProviderInterface; | 30 class DefaultProviderInterface; |
30 class ProviderInterface; | 31 class AbstractProvider; |
31 } // namespace content_settings | 32 } // namespace content_settings |
32 | 33 |
33 class ContentSettingsDetails; | 34 class ContentSettingsDetails; |
34 class DictionaryValue; | 35 class DictionaryValue; |
35 class ExtensionService; | 36 class ExtensionService; |
36 class GURL; | 37 class GURL; |
37 class PrefService; | 38 class PrefService; |
38 class Profile; | 39 class Profile; |
39 | 40 |
40 class HostContentSettingsMap | 41 class HostContentSettingsMap |
41 : public NotificationObserver, | 42 : public content_settings::Observer, |
43 public NotificationObserver, | |
42 public base::RefCountedThreadSafe<HostContentSettingsMap> { | 44 public base::RefCountedThreadSafe<HostContentSettingsMap> { |
43 public: | 45 public: |
44 typedef Tuple3<ContentSettingsPattern, ContentSetting, std::string> | 46 typedef Tuple3<ContentSettingsPattern, ContentSetting, std::string> |
45 PatternSettingSourceTriple; | 47 PatternSettingSourceTriple; |
46 typedef std::vector<PatternSettingSourceTriple> SettingsForOneType; | 48 typedef std::vector<PatternSettingSourceTriple> SettingsForOneType; |
47 | 49 |
48 HostContentSettingsMap(PrefService* prefs, | 50 HostContentSettingsMap(PrefService* prefs, |
49 ExtensionService* extension_service, | 51 ExtensionService* extension_service, |
50 bool incognito); | 52 bool incognito); |
51 | 53 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 | 185 |
184 // Returns true if the default setting for the |content_type| is managed. | 186 // Returns true if the default setting for the |content_type| is managed. |
185 bool IsDefaultContentSettingManaged(ContentSettingsType content_type) const; | 187 bool IsDefaultContentSettingManaged(ContentSettingsType content_type) const; |
186 | 188 |
187 // Detaches the HostContentSettingsMap from all Profile-related objects like | 189 // Detaches the HostContentSettingsMap from all Profile-related objects like |
188 // PrefService. This methods needs to be called before destroying the Profile. | 190 // PrefService. This methods needs to be called before destroying the Profile. |
189 // Afterwards, none of the methods above that should only be called on the UI | 191 // Afterwards, none of the methods above that should only be called on the UI |
190 // thread should be called anymore. | 192 // thread should be called anymore. |
191 void ShutdownOnUIThread(); | 193 void ShutdownOnUIThread(); |
192 | 194 |
195 // ProviderObserverInterface implementation. | |
Bernhard Bauer
2011/07/13 07:58:18
Nit: The interface is called just |content_setting
markusheintz_
2011/07/13 12:48:16
Done.
| |
196 virtual void OnContentSettingChanged( | |
197 const ContentSettingsDetails& details); | |
198 | |
193 // NotificationObserver implementation. | 199 // NotificationObserver implementation. |
194 virtual void Observe(int type, | 200 virtual void Observe(int type, |
195 const NotificationSource& source, | 201 const NotificationSource& source, |
196 const NotificationDetails& details); | 202 const NotificationDetails& details); |
197 | 203 |
198 private: | 204 private: |
199 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; | 205 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; |
200 | 206 |
201 virtual ~HostContentSettingsMap(); | 207 virtual ~HostContentSettingsMap(); |
202 | 208 |
(...skipping 17 matching lines...) Expand all Loading... | |
220 | 226 |
221 // Whether we are currently updating preferences, this is used to ignore | 227 // Whether we are currently updating preferences, this is used to ignore |
222 // notifications from the preferences service that we triggered ourself. | 228 // notifications from the preferences service that we triggered ourself. |
223 bool updating_preferences_; | 229 bool updating_preferences_; |
224 | 230 |
225 // Default content setting providers. | 231 // Default content setting providers. |
226 std::vector<linked_ptr<content_settings::DefaultProviderInterface> > | 232 std::vector<linked_ptr<content_settings::DefaultProviderInterface> > |
227 default_content_settings_providers_; | 233 default_content_settings_providers_; |
228 | 234 |
229 // Content setting providers. | 235 // Content setting providers. |
230 std::vector<linked_ptr<content_settings::ProviderInterface> > | 236 std::vector<linked_ptr<content_settings::AbstractProvider> > |
Bernhard Bauer
2011/07/13 07:58:18
Wait, I think we should still use the base interfa
markusheintz_
2011/07/13 12:48:16
Oh yeah. Forgot to change that back. Initially I r
| |
231 content_settings_providers_; | 237 content_settings_providers_; |
232 | 238 |
233 // Used around accesses to the following objects to guarantee thread safety. | 239 // Used around accesses to the following objects to guarantee thread safety. |
234 mutable base::Lock lock_; | 240 mutable base::Lock lock_; |
235 | 241 |
236 // Misc global settings. | 242 // Misc global settings. |
237 bool block_third_party_cookies_; | 243 bool block_third_party_cookies_; |
238 bool is_block_third_party_cookies_managed_; | 244 bool is_block_third_party_cookies_managed_; |
239 | 245 |
240 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 246 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
241 }; | 247 }; |
242 | 248 |
243 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 249 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
OLD | NEW |