OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/prefs/public/pref_change_registrar.h" | 17 #include "base/prefs/public/pref_change_registrar.h" |
18 #include "base/synchronization/lock.h" | |
19 #include "base/tuple.h" | 18 #include "base/tuple.h" |
20 #include "chrome/browser/content_settings/content_settings_observer.h" | 19 #include "chrome/browser/content_settings/content_settings_observer.h" |
21 #include "chrome/common/content_settings.h" | 20 #include "chrome/common/content_settings.h" |
22 #include "chrome/common/content_settings_pattern.h" | 21 #include "chrome/common/content_settings_pattern.h" |
23 #include "chrome/common/content_settings_types.h" | 22 #include "chrome/common/content_settings_types.h" |
24 | 23 |
25 namespace base { | 24 namespace base { |
26 class Value; | 25 class Value; |
27 } // namespace base | 26 } // namespace base |
28 | 27 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // from the normal mode. Otherwise, adds the content settings for the normal | 222 // from the normal mode. Otherwise, adds the content settings for the normal |
224 // mode. | 223 // mode. |
225 void AddSettingsForOneType( | 224 void AddSettingsForOneType( |
226 const content_settings::ProviderInterface* provider, | 225 const content_settings::ProviderInterface* provider, |
227 ProviderType provider_type, | 226 ProviderType provider_type, |
228 ContentSettingsType content_type, | 227 ContentSettingsType content_type, |
229 const std::string& resource_identifier, | 228 const std::string& resource_identifier, |
230 ContentSettingsForOneType* settings, | 229 ContentSettingsForOneType* settings, |
231 bool incognito) const; | 230 bool incognito) const; |
232 | 231 |
| 232 // Call UsedContentSettingsProviders() whenever you access |
| 233 // content_settings_providers_ (apart from initialization and |
| 234 // teardown), so that we can DCHECK in RegisterExtensionService that |
| 235 // it is not being called too late. |
| 236 void UsedContentSettingsProviders() const; |
| 237 |
| 238 #ifndef NDEBUG |
| 239 mutable bool used_content_settings_providers_; |
| 240 #endif |
| 241 |
233 // Weak; owned by the Profile. | 242 // Weak; owned by the Profile. |
234 PrefService* prefs_; | 243 PrefService* prefs_; |
235 | 244 |
236 // Whether this settings map is for an OTR session. | 245 // Whether this settings map is for an OTR session. |
237 bool is_off_the_record_; | 246 bool is_off_the_record_; |
238 | 247 |
239 // Content setting providers. | 248 // Content setting providers. This is only modified at construction |
| 249 // time and by RegisterExtensionService, both of which should happen |
| 250 // before any other uses of it. |
240 ProviderMap content_settings_providers_; | 251 ProviderMap content_settings_providers_; |
241 | 252 |
242 // Used around accesses to the following objects to guarantee thread safety. | |
243 mutable base::Lock lock_; | |
244 | |
245 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 253 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
246 }; | 254 }; |
247 | 255 |
248 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 256 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
OLD | NEW |