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 COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 8 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
9 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 9 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_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/macros.h" | 15 #include "base/macros.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/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
19 #include "base/threading/thread_checker.h" | 19 #include "base/threading/thread_checker.h" |
20 #include "components/content_settings/core/browser/content_settings_observer.h" | 20 #include "components/content_settings/core/browser/content_settings_observer.h" |
21 #include "components/content_settings/core/browser/content_settings_utils.h" | 21 #include "components/content_settings/core/browser/content_settings_utils.h" |
22 #include "components/content_settings/core/common/content_settings.h" | 22 #include "components/content_settings/core/common/content_settings.h" |
23 #include "components/content_settings/core/common/content_settings_pattern.h" | 23 #include "components/content_settings/core/common/content_settings_pattern.h" |
24 #include "components/content_settings/core/common/content_settings_types.h" | 24 #include "components/content_settings/core/common/content_settings_types.h" |
25 #include "components/keyed_service/core/refcounted_keyed_service.h" | 25 #include "components/keyed_service/core/refcounted_keyed_service.h" |
26 #include "components/prefs/pref_change_registrar.h" | 26 #include "components/prefs/pref_change_registrar.h" |
27 #include "components/syncable_prefs/pref_service_syncable.h" | |
27 | 28 |
28 class ExtensionService; | 29 class ExtensionService; |
29 class GURL; | 30 class GURL; |
30 class PrefService; | 31 class PrefService; |
31 | 32 |
32 namespace base { | 33 namespace base { |
33 class Clock; | 34 class Clock; |
34 class Value; | 35 class Value; |
35 } | 36 } |
36 | 37 |
37 namespace content_settings { | 38 namespace content_settings { |
38 class ObservableProvider; | 39 class ObservableProvider; |
39 class ProviderInterface; | 40 class ProviderInterface; |
40 class PrefProvider; | 41 class PrefProvider; |
41 class TestUtils; | 42 class TestUtils; |
42 } | 43 } |
43 | 44 |
45 namespace syncable_prefs { | |
46 class PrefServiceSyncable; | |
47 } | |
48 | |
44 namespace user_prefs { | 49 namespace user_prefs { |
45 class PrefRegistrySyncable; | 50 class PrefRegistrySyncable; |
46 } | 51 } |
47 | 52 |
48 class HostContentSettingsMap : public content_settings::Observer, | 53 class HostContentSettingsMap : public content_settings::Observer, |
49 public RefcountedKeyedService { | 54 public RefcountedKeyedService { |
50 public: | 55 public: |
51 enum ProviderType { | 56 enum ProviderType { |
52 // EXTENSION names is a layering violation when this class will move to | 57 // EXTENSION names is a layering violation when this class will move to |
53 // components. | 58 // components. |
54 // TODO(mukai): find the solution. | 59 // TODO(mukai): find the solution. |
55 INTERNAL_EXTENSION_PROVIDER = 0, | 60 INTERNAL_EXTENSION_PROVIDER = 0, |
56 POLICY_PROVIDER, | 61 POLICY_PROVIDER, |
57 SUPERVISED_PROVIDER, | 62 SUPERVISED_PROVIDER, |
58 CUSTOM_EXTENSION_PROVIDER, | 63 CUSTOM_EXTENSION_PROVIDER, |
59 PREF_PROVIDER, | 64 PREF_PROVIDER, |
60 DEFAULT_PROVIDER, | 65 DEFAULT_PROVIDER, |
61 NUM_PROVIDER_TYPES | 66 NUM_PROVIDER_TYPES |
62 }; | 67 }; |
63 | 68 |
64 // This should be called on the UI thread, otherwise |thread_checker_| handles | 69 // This should be called on the UI thread, otherwise |thread_checker_| handles |
65 // CalledOnValidThread() wrongly. Only one (or neither) of | 70 // CalledOnValidThread() wrongly. Only one (or neither) of |
66 // |is_incognito_profile| and |is_guest_profile| should be true. | 71 // |is_incognito_profile| and |is_guest_profile| should be true. |
67 HostContentSettingsMap(PrefService* prefs, | 72 HostContentSettingsMap(PrefService* prefs, |
68 bool is_incognito_profile, | 73 bool is_incognito_profile, |
69 bool is_guest_profile); | 74 bool is_guest_profile, |
75 syncable_prefs::PrefServiceSyncable* pref_service); | |
raymes
2016/06/29 03:50:01
I'm wondering if we can just pass in a base::Callb
lshang
2016/06/30 05:03:36
Done.
Yeah as we discussed, I think register the
| |
70 | 76 |
71 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 77 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
72 | 78 |
73 // Adds a new provider for |type|. | 79 // Adds a new provider for |type|. |
74 void RegisterProvider( | 80 void RegisterProvider( |
75 ProviderType type, | 81 ProviderType type, |
76 std::unique_ptr<content_settings::ObservableProvider> provider); | 82 std::unique_ptr<content_settings::ObservableProvider> provider); |
77 | 83 |
78 // Returns the default setting for a particular content type. If |provider_id| | 84 // Returns the default setting for a particular content type. If |provider_id| |
79 // is not NULL, the id of the provider which provided the default setting is | 85 // is not NULL, the id of the provider which provided the default setting is |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 // before any other uses of it. | 395 // before any other uses of it. |
390 ProviderMap content_settings_providers_; | 396 ProviderMap content_settings_providers_; |
391 | 397 |
392 // content_settings_providers_[PREF_PROVIDER] but specialized. | 398 // content_settings_providers_[PREF_PROVIDER] but specialized. |
393 content_settings::PrefProvider* pref_provider_ = nullptr; | 399 content_settings::PrefProvider* pref_provider_ = nullptr; |
394 | 400 |
395 base::ThreadChecker thread_checker_; | 401 base::ThreadChecker thread_checker_; |
396 | 402 |
397 base::ObserverList<content_settings::Observer> observers_; | 403 base::ObserverList<content_settings::Observer> observers_; |
398 | 404 |
405 syncable_prefs::PrefServiceSyncable* pref_service_; | |
406 | |
399 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 407 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
400 }; | 408 }; |
401 | 409 |
402 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 410 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
OLD | NEW |