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 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ |
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 // A content settings provider that takes its settings out of policies. | 9 // A content settings provider that takes its settings out of policies. |
10 | 10 |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "base/tuple.h" | 15 #include "base/tuple.h" |
| 16 #include "chrome/browser/content_settings/content_settings_observable_provider.h
" |
16 #include "chrome/browser/content_settings/content_settings_origin_identifier_val
ue_map.h" | 17 #include "chrome/browser/content_settings/content_settings_origin_identifier_val
ue_map.h" |
17 #include "chrome/browser/content_settings/content_settings_provider.h" | |
18 #include "chrome/browser/prefs/pref_change_registrar.h" | 18 #include "chrome/browser/prefs/pref_change_registrar.h" |
19 #include "content/common/notification_observer.h" | 19 #include "content/common/notification_observer.h" |
20 #include "content/common/notification_registrar.h" | 20 #include "content/common/notification_registrar.h" |
21 | 21 |
22 class ContentSettingsDetails; | 22 class ContentSettingsDetails; |
23 class DictionaryValue; | 23 class DictionaryValue; |
24 class HostContentSettingsMap; | 24 class HostContentSettingsMap; |
25 class PrefService; | 25 class PrefService; |
26 | 26 |
27 namespace content_settings { | 27 namespace content_settings { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // guarantee thread safety. | 71 // guarantee thread safety. |
72 mutable base::Lock lock_; | 72 mutable base::Lock lock_; |
73 | 73 |
74 PrefChangeRegistrar pref_change_registrar_; | 74 PrefChangeRegistrar pref_change_registrar_; |
75 NotificationRegistrar notification_registrar_; | 75 NotificationRegistrar notification_registrar_; |
76 | 76 |
77 DISALLOW_COPY_AND_ASSIGN(PolicyDefaultProvider); | 77 DISALLOW_COPY_AND_ASSIGN(PolicyDefaultProvider); |
78 }; | 78 }; |
79 | 79 |
80 // PolicyProvider that provider managed content-settings. | 80 // PolicyProvider that provider managed content-settings. |
81 class PolicyProvider : public ProviderInterface, | 81 class PolicyProvider : public ObservableProvider, |
82 public NotificationObserver { | 82 public NotificationObserver { |
83 public: | 83 public: |
84 PolicyProvider(HostContentSettingsMap* map, | 84 PolicyProvider(PrefService* prefs, |
85 PrefService* prefs, | |
86 DefaultProviderInterface* default_provider); | 85 DefaultProviderInterface* default_provider); |
87 virtual ~PolicyProvider(); | 86 virtual ~PolicyProvider(); |
88 static void RegisterUserPrefs(PrefService* prefs); | 87 static void RegisterUserPrefs(PrefService* prefs); |
89 | 88 |
90 // ProviderInterface Implementation | 89 // ProviderInterface implementations. |
91 virtual void SetContentSetting( | 90 virtual void SetContentSetting( |
92 const ContentSettingsPattern& primary_pattern, | 91 const ContentSettingsPattern& primary_pattern, |
93 const ContentSettingsPattern& secondary_pattern, | 92 const ContentSettingsPattern& secondary_pattern, |
94 ContentSettingsType content_type, | 93 ContentSettingsType content_type, |
95 const ResourceIdentifier& resource_identifier, | 94 const ResourceIdentifier& resource_identifier, |
96 ContentSetting content_setting); | 95 ContentSetting content_setting); |
97 | 96 |
98 virtual ContentSetting GetContentSetting( | 97 virtual ContentSetting GetContentSetting( |
99 const GURL& primary_url, | 98 const GURL& primary_url, |
100 const GURL& secondary_url, | 99 const GURL& secondary_url, |
(...skipping 23 matching lines...) Expand all Loading... |
124 ContentSetting> ContentSettingsRule; | 123 ContentSetting> ContentSettingsRule; |
125 | 124 |
126 typedef std::vector<ContentSettingsRule> ContentSettingsRules; | 125 typedef std::vector<ContentSettingsRule> ContentSettingsRules; |
127 | 126 |
128 void ReadManagedContentSettings(bool overwrite); | 127 void ReadManagedContentSettings(bool overwrite); |
129 | 128 |
130 void GetContentSettingsFromPreferences(ContentSettingsRules* rules); | 129 void GetContentSettingsFromPreferences(ContentSettingsRules* rules); |
131 | 130 |
132 void ReadManagedContentSettingsTypes(ContentSettingsType content_type); | 131 void ReadManagedContentSettingsTypes(ContentSettingsType content_type); |
133 | 132 |
134 void NotifyObservers(const ContentSettingsDetails& details); | |
135 | |
136 OriginIdentifierValueMap value_map_; | 133 OriginIdentifierValueMap value_map_; |
137 | 134 |
138 HostContentSettingsMap* host_content_settings_map_; | |
139 PrefService* prefs_; | 135 PrefService* prefs_; |
140 | 136 |
141 // Weak, owned by HostContentSettingsMap. | 137 // Weak, owned by HostContentSettingsMap. |
142 DefaultProviderInterface* default_provider_; | 138 DefaultProviderInterface* default_provider_; |
143 | 139 |
144 PrefChangeRegistrar pref_change_registrar_; | 140 PrefChangeRegistrar pref_change_registrar_; |
145 | 141 |
146 // Used around accesses to the content_settings_ object to guarantee | 142 // Used around accesses to the content_settings_ object to guarantee |
147 // thread safety. | 143 // thread safety. |
148 mutable base::Lock lock_; | 144 mutable base::Lock lock_; |
149 | 145 |
150 DISALLOW_COPY_AND_ASSIGN(PolicyProvider); | 146 DISALLOW_COPY_AND_ASSIGN(PolicyProvider); |
151 }; | 147 }; |
152 | 148 |
153 } // namespace content_settings | 149 } // namespace content_settings |
154 | 150 |
155 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ | 151 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ |
OLD | NEW |