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 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 public base::RefCountedThreadSafe<HostContentSettingsMap> { | 42 public base::RefCountedThreadSafe<HostContentSettingsMap> { |
43 public: | 43 public: |
44 enum ProviderType { | 44 enum ProviderType { |
45 POLICY_PROVIDER = 0, | 45 POLICY_PROVIDER = 0, |
46 EXTENSION_PROVIDER = 1, | 46 EXTENSION_PROVIDER = 1, |
47 PREF_PROVIDER, | 47 PREF_PROVIDER, |
48 DEFAULT_PROVIDER, | 48 DEFAULT_PROVIDER, |
49 NUM_PROVIDER_TYPES, | 49 NUM_PROVIDER_TYPES, |
50 }; | 50 }; |
51 | 51 |
52 // TODO(markusheintz): I sold my soul to the devil on order to add this tuple. | |
53 // I really want my soul back, so I really will change this ASAP. | |
54 typedef Tuple5<ContentSettingsPattern, | |
55 ContentSettingsPattern, | |
56 ContentSetting, | |
57 std::string, | |
58 bool> PatternSettingSourceTuple; | |
59 typedef std::vector<PatternSettingSourceTuple> SettingsForOneType; | |
60 | |
61 HostContentSettingsMap(PrefService* prefs, | 52 HostContentSettingsMap(PrefService* prefs, |
62 ExtensionService* extension_service, | 53 ExtensionService* extension_service, |
63 bool incognito); | 54 bool incognito); |
64 | 55 |
65 static void RegisterUserPrefs(PrefService* prefs); | 56 static void RegisterUserPrefs(PrefService* prefs); |
66 | 57 |
67 // Returns the default setting for a particular content type. | 58 // Returns the default setting for a particular content type. |
68 // | 59 // |
69 // This may be called on any thread. | 60 // This may be called on any thread. |
70 ContentSetting GetDefaultContentSetting( | 61 ContentSetting GetDefaultContentSetting( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 // Returns all ContentSettings which apply to the given URLs. For content | 102 // Returns all ContentSettings which apply to the given URLs. For content |
112 // setting types that require an additional resource identifier, the default | 103 // setting types that require an additional resource identifier, the default |
113 // content setting is returned. | 104 // content setting is returned. |
114 // | 105 // |
115 // This may be called on any thread. | 106 // This may be called on any thread. |
116 ContentSettings GetContentSettings( | 107 ContentSettings GetContentSettings( |
117 const GURL& primary_url, | 108 const GURL& primary_url, |
118 const GURL& secondary_url) const; | 109 const GURL& secondary_url) const; |
119 | 110 |
120 // For a given content type, returns all patterns with a non-default setting, | 111 // For a given content type, returns all patterns with a non-default setting, |
121 // mapped to their actual settings, in lexicographical order. |settings| | 112 // mapped to their actual settings, in the order the settings are applied. |
122 // must be a non-NULL outparam. If this map was created for the | 113 // |settings| must be a non-NULL outparam. |
123 // incognito profile, it will only return those settings differing from | |
124 // the main map. For ContentSettingsTypes that require an resource identifier | |
125 // to be specified, the |resource_identifier| must be non-empty. | |
Bernhard Bauer
2011/10/17 13:13:19
Wait, we're changing the comment without changing
marja
2011/10/17 15:10:11
The "If the map was created for the incognito prof
Bernhard Bauer
2011/10/17 15:14:13
Ok, just checking (cs.chromium.org seems to be a b
| |
126 // | 114 // |
127 // This may be called on any thread. | 115 // This may be called on any thread. |
128 void GetSettingsForOneType(ContentSettingsType content_type, | 116 void GetSettingsForOneType(ContentSettingsType content_type, |
129 const std::string& resource_identifier, | 117 const std::string& resource_identifier, |
130 SettingsForOneType* settings) const; | 118 ContentSettingsForOneType* settings) const; |
131 | 119 |
132 // Sets the default setting for a particular content type. This method must | 120 // Sets the default setting for a particular content type. This method must |
133 // not be invoked on an incognito map. | 121 // not be invoked on an incognito map. |
134 // | 122 // |
135 // This should only be called on the UI thread. | 123 // This should only be called on the UI thread. |
136 void SetDefaultContentSetting(ContentSettingsType content_type, | 124 void SetDefaultContentSetting(ContentSettingsType content_type, |
137 ContentSetting setting); | 125 ContentSetting setting); |
138 | 126 |
139 // Sets the content setting for the given patterns and content type. | 127 // Sets the content setting for the given patterns and content type. |
140 // Setting the value to CONTENT_SETTING_DEFAULT causes the default setting | 128 // Setting the value to CONTENT_SETTING_DEFAULT causes the default setting |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 // Adds content settings for |content_type| and |resource_identifier|, | 212 // Adds content settings for |content_type| and |resource_identifier|, |
225 // provided by |provider|, into |settings|. If |incognito| is true, adds only | 213 // provided by |provider|, into |settings|. If |incognito| is true, adds only |
226 // the content settings which are applicable to the incognito mode and differ | 214 // the content settings which are applicable to the incognito mode and differ |
227 // from the normal mode. Otherwise, adds the content settings for the normal | 215 // from the normal mode. Otherwise, adds the content settings for the normal |
228 // mode. | 216 // mode. |
229 void AddSettingsForOneType( | 217 void AddSettingsForOneType( |
230 const content_settings::ProviderInterface* provider, | 218 const content_settings::ProviderInterface* provider, |
231 ProviderType provider_type, | 219 ProviderType provider_type, |
232 ContentSettingsType content_type, | 220 ContentSettingsType content_type, |
233 const std::string& resource_identifier, | 221 const std::string& resource_identifier, |
234 SettingsForOneType* settings, | 222 ContentSettingsForOneType* settings, |
235 bool incognito) const; | 223 bool incognito) const; |
236 | 224 |
237 // Weak; owned by the Profile. | 225 // Weak; owned by the Profile. |
238 PrefService* prefs_; | 226 PrefService* prefs_; |
239 | 227 |
240 PrefChangeRegistrar pref_change_registrar_; | 228 PrefChangeRegistrar pref_change_registrar_; |
241 | 229 |
242 // Whether this settings map is for an OTR session. | 230 // Whether this settings map is for an OTR session. |
243 bool is_off_the_record_; | 231 bool is_off_the_record_; |
244 | 232 |
245 // Whether we are currently updating preferences, this is used to ignore | 233 // Whether we are currently updating preferences, this is used to ignore |
246 // notifications from the preferences service that we triggered ourself. | 234 // notifications from the preferences service that we triggered ourself. |
247 bool updating_preferences_; | 235 bool updating_preferences_; |
248 | 236 |
249 // Content setting providers. | 237 // Content setting providers. |
250 ProviderMap content_settings_providers_; | 238 ProviderMap content_settings_providers_; |
251 | 239 |
252 // Used around accesses to the following objects to guarantee thread safety. | 240 // Used around accesses to the following objects to guarantee thread safety. |
253 mutable base::Lock lock_; | 241 mutable base::Lock lock_; |
254 | 242 |
255 // Misc global settings. | 243 // Misc global settings. |
256 bool block_third_party_cookies_; | 244 bool block_third_party_cookies_; |
257 bool is_block_third_party_cookies_managed_; | 245 bool is_block_third_party_cookies_managed_; |
258 | 246 |
259 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 247 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
260 }; | 248 }; |
261 | 249 |
262 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 250 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
OLD | NEW |