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/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "base/prefs/pref_change_registrar.h" | 18 #include "base/prefs/pref_change_registrar.h" |
19 #include "base/threading/platform_thread.h" | 19 #include "base/threading/platform_thread.h" |
| 20 #include "base/threading/thread_checker.h" |
20 #include "base/tuple.h" | 21 #include "base/tuple.h" |
21 #include "chrome/browser/content_settings/content_settings_override_provider.h" | 22 #include "chrome/browser/content_settings/content_settings_override_provider.h" |
22 #include "components/content_settings/core/browser/content_settings_observer.h" | 23 #include "components/content_settings/core/browser/content_settings_observer.h" |
23 #include "components/content_settings/core/common/content_settings.h" | 24 #include "components/content_settings/core/common/content_settings.h" |
24 #include "components/content_settings/core/common/content_settings_pattern.h" | 25 #include "components/content_settings/core/common/content_settings_pattern.h" |
25 #include "components/content_settings/core/common/content_settings_types.h" | 26 #include "components/content_settings/core/common/content_settings_types.h" |
26 | 27 |
27 class ExtensionService; | 28 class ExtensionService; |
28 class GURL; | 29 class GURL; |
29 class PrefService; | 30 class PrefService; |
(...skipping 24 matching lines...) Expand all Loading... |
54 // TODO(mukai): find the solution. | 55 // TODO(mukai): find the solution. |
55 INTERNAL_EXTENSION_PROVIDER = 0, | 56 INTERNAL_EXTENSION_PROVIDER = 0, |
56 POLICY_PROVIDER, | 57 POLICY_PROVIDER, |
57 CUSTOM_EXTENSION_PROVIDER, | 58 CUSTOM_EXTENSION_PROVIDER, |
58 OVERRIDE_PROVIDER, | 59 OVERRIDE_PROVIDER, |
59 PREF_PROVIDER, | 60 PREF_PROVIDER, |
60 DEFAULT_PROVIDER, | 61 DEFAULT_PROVIDER, |
61 NUM_PROVIDER_TYPES, | 62 NUM_PROVIDER_TYPES, |
62 }; | 63 }; |
63 | 64 |
| 65 // This should be called on the UI thread, otherwise |thread_checker_| handles |
| 66 // CalledOnValidThread() wrongly. |
64 HostContentSettingsMap(PrefService* prefs, bool incognito); | 67 HostContentSettingsMap(PrefService* prefs, bool incognito); |
65 | 68 |
66 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 69 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
67 | 70 |
68 // Adds a new provider for |type|. | 71 // Adds a new provider for |type|. |
69 void RegisterProvider( | 72 void RegisterProvider( |
70 ProviderType type, | 73 ProviderType type, |
71 scoped_ptr<content_settings::ObservableProvider> provider); | 74 scoped_ptr<content_settings::ObservableProvider> provider); |
72 | 75 |
73 // Returns the default setting for a particular content type. If |provider_id| | 76 // Returns the default setting for a particular content type. If |provider_id| |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 PrefService* prefs_; | 349 PrefService* prefs_; |
347 | 350 |
348 // Whether this settings map is for an OTR session. | 351 // Whether this settings map is for an OTR session. |
349 bool is_off_the_record_; | 352 bool is_off_the_record_; |
350 | 353 |
351 // Content setting providers. This is only modified at construction | 354 // Content setting providers. This is only modified at construction |
352 // time and by RegisterExtensionService, both of which should happen | 355 // time and by RegisterExtensionService, both of which should happen |
353 // before any other uses of it. | 356 // before any other uses of it. |
354 ProviderMap content_settings_providers_; | 357 ProviderMap content_settings_providers_; |
355 | 358 |
| 359 base::ThreadChecker thread_checker_; |
| 360 |
356 ObserverList<content_settings::Observer> observers_; | 361 ObserverList<content_settings::Observer> observers_; |
357 | 362 |
358 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 363 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
359 }; | 364 }; |
360 | 365 |
361 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 366 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
OLD | NEW |