Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: chrome/browser/content_settings/content_settings_policy_provider.h

Issue 6542048: Add content_settings::PolicyProvider and a set of new policies to managed content settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "chrome/browser/content_settings/content_settings_provider.h" 13 #include "chrome/browser/content_settings/content_settings_provider.h"
14 #include "chrome/browser/content_settings/content_settings_base_provider.h"
14 #include "chrome/browser/prefs/pref_change_registrar.h" 15 #include "chrome/browser/prefs/pref_change_registrar.h"
15 #include "chrome/common/notification_observer.h" 16 #include "chrome/common/notification_observer.h"
16 #include "chrome/common/notification_registrar.h" 17 #include "chrome/common/notification_registrar.h"
17 18
18 class ContentSettingsDetails; 19 class ContentSettingsDetails;
19 class DictionaryValue; 20 class DictionaryValue;
20 class PrefService; 21 class PrefService;
21 class Profile; 22 class Profile;
22 23
23 namespace content_settings { 24 namespace content_settings {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // Used around accesses to the managed_default_content_settings_ object to 70 // Used around accesses to the managed_default_content_settings_ object to
70 // guarantee thread safety. 71 // guarantee thread safety.
71 mutable base::Lock lock_; 72 mutable base::Lock lock_;
72 73
73 PrefChangeRegistrar pref_change_registrar_; 74 PrefChangeRegistrar pref_change_registrar_;
74 NotificationRegistrar notification_registrar_; 75 NotificationRegistrar notification_registrar_;
75 76
76 DISALLOW_COPY_AND_ASSIGN(PolicyDefaultProvider); 77 DISALLOW_COPY_AND_ASSIGN(PolicyDefaultProvider);
77 }; 78 };
78 79
80 // PolicyProvider that provider managed content-settings.
81 class PolicyProvider : public BaseProvider,
82 public NotificationObserver {
83 public:
84 explicit PolicyProvider(Profile* profile);
85 ~PolicyProvider();
86 static void RegisterUserPrefs(PrefService* prefs);
87
88 // BaseProvider Implementation
89 virtual void Init();
90
91 // ProviderInterface Implementation
92 virtual bool ContentSettingsTypeIsManaged(
93 ContentSettingsType content_type);
94
95 virtual void SetContentSetting(
96 const ContentSettingsPattern& requesting_pattern,
97 const ContentSettingsPattern& embedding_pattern,
98 ContentSettingsType content_type,
99 const ResourceIdentifier& resource_identifier,
100 ContentSetting content_setting);
101
102 virtual void ClearAllContentSettingsRules(
103 ContentSettingsType content_type);
104
105 virtual void ResetToDefaults();
106
107 // NotificationObserver implementation.
108 virtual void Observe(NotificationType type,
109 const NotificationSource& source,
110 const NotificationDetails& details);
111 private:
112 void ReadManagedContentSettings(bool overwrite);
113
114 void ReadManagedContentSettingsTypes(
115 ContentSettingsType content_type);
116
117 void GetPatternsFromPref(const char* pref_name,
118 ContentSettingsType content_type,
119 ContentSetting setting);
120
121 void NotifyObservers(const ContentSettingsDetails& details);
122
123 void UnregisterObservers();
124
125 Profile* profile_;
126
127 bool content_type_is_managed_[CONTENT_SETTINGS_NUM_TYPES];
128
129 PrefChangeRegistrar pref_change_registrar_;
130 NotificationRegistrar notification_registrar_;
131
132 DISALLOW_COPY_AND_ASSIGN(PolicyProvider);
133 };
134
79 } // namespace content_settings 135 } // namespace content_settings
80 136
81 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_ 137 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698