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 | 7 |
8 // A content settings provider that takes its settings out of policies. | 8 // A content settings provider that takes its settings out of policies. |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/prefs/public/pref_change_registrar.h" | 13 #include "base/prefs/public/pref_change_registrar.h" |
| 14 #include "base/prefs/public/pref_observer.h" |
14 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
15 #include "chrome/browser/content_settings/content_settings_observable_provider.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 "content/public/browser/notification_observer.h" | |
18 | 18 |
19 class PrefService; | 19 class PrefService; |
20 | 20 |
21 namespace content_settings { | 21 namespace content_settings { |
22 | 22 |
23 // PolicyProvider that provides managed content-settings. | 23 // PolicyProvider that provides managed content-settings. |
24 class PolicyProvider : public ObservableProvider, | 24 class PolicyProvider : public ObservableProvider, |
25 public content::NotificationObserver { | 25 public PrefObserver { |
26 public: | 26 public: |
27 explicit PolicyProvider(PrefService* prefs); | 27 explicit PolicyProvider(PrefService* prefs); |
28 virtual ~PolicyProvider(); | 28 virtual ~PolicyProvider(); |
29 static void RegisterUserPrefs(PrefService* prefs); | 29 static void RegisterUserPrefs(PrefService* prefs); |
30 | 30 |
31 // ProviderInterface implementations. | 31 // ProviderInterface implementations. |
32 virtual RuleIterator* GetRuleIterator( | 32 virtual RuleIterator* GetRuleIterator( |
33 ContentSettingsType content_type, | 33 ContentSettingsType content_type, |
34 const ResourceIdentifier& resource_identifier, | 34 const ResourceIdentifier& resource_identifier, |
35 bool incognito) const OVERRIDE; | 35 bool incognito) const OVERRIDE; |
36 | 36 |
37 virtual bool SetWebsiteSetting( | 37 virtual bool SetWebsiteSetting( |
38 const ContentSettingsPattern& primary_pattern, | 38 const ContentSettingsPattern& primary_pattern, |
39 const ContentSettingsPattern& secondary_pattern, | 39 const ContentSettingsPattern& secondary_pattern, |
40 ContentSettingsType content_type, | 40 ContentSettingsType content_type, |
41 const ResourceIdentifier& resource_identifier, | 41 const ResourceIdentifier& resource_identifier, |
42 Value* value) OVERRIDE; | 42 Value* value) OVERRIDE; |
43 | 43 |
44 virtual void ClearAllContentSettingsRules( | 44 virtual void ClearAllContentSettingsRules( |
45 ContentSettingsType content_type) OVERRIDE; | 45 ContentSettingsType content_type) OVERRIDE; |
46 | 46 |
47 virtual void ShutdownOnUIThread() OVERRIDE; | 47 virtual void ShutdownOnUIThread() OVERRIDE; |
48 | 48 |
49 // content::NotificationObserver implementation. | 49 // PrefObserver implementation. |
50 virtual void Observe(int type, | 50 virtual void OnPreferenceChanged(PrefServiceBase* service, |
51 const content::NotificationSource& source, | 51 const std::string& pref_name) OVERRIDE; |
52 const content::NotificationDetails& details) OVERRIDE; | 52 |
53 private: | 53 private: |
54 // Reads the policy managed default settings. | 54 // Reads the policy managed default settings. |
55 void ReadManagedDefaultSettings(); | 55 void ReadManagedDefaultSettings(); |
56 | 56 |
57 // Reads the policy controlled default settings for a specific content type. | 57 // Reads the policy controlled default settings for a specific content type. |
58 void UpdateManagedDefaultSetting(ContentSettingsType content_type); | 58 void UpdateManagedDefaultSetting(ContentSettingsType content_type); |
59 | 59 |
60 void ReadManagedContentSettings(bool overwrite); | 60 void ReadManagedContentSettings(bool overwrite); |
61 | 61 |
62 void GetContentSettingsFromPreferences(OriginIdentifierValueMap* rules); | 62 void GetContentSettingsFromPreferences(OriginIdentifierValueMap* rules); |
(...skipping 12 matching lines...) Expand all Loading... |
75 // Used around accesses to the |value_map_| object to guarantee | 75 // Used around accesses to the |value_map_| object to guarantee |
76 // thread safety. | 76 // thread safety. |
77 mutable base::Lock lock_; | 77 mutable base::Lock lock_; |
78 | 78 |
79 DISALLOW_COPY_AND_ASSIGN(PolicyProvider); | 79 DISALLOW_COPY_AND_ASSIGN(PolicyProvider); |
80 }; | 80 }; |
81 | 81 |
82 } // namespace content_settings | 82 } // namespace content_settings |
83 | 83 |
84 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ | 84 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ |
OLD | NEW |