Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / content_settings / content_settings_policy_provider.h
blob0bd4b2ef8b397ab2f4e5b064f0883eedabd8a5b9
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_
8 // A content settings provider that takes its settings out of policies.
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/prefs/pref_change_registrar.h"
14 #include "base/synchronization/lock.h"
15 #include "chrome/browser/content_settings/content_settings_observable_provider.h"
16 #include "chrome/browser/content_settings/content_settings_origin_identifier_value_map.h"
18 class PrefService;
20 namespace user_prefs {
21 class PrefRegistrySyncable;
24 namespace content_settings {
26 // PolicyProvider that provides managed content-settings.
27 class PolicyProvider : public ObservableProvider {
28 public:
29 explicit PolicyProvider(PrefService* prefs);
30 virtual ~PolicyProvider();
31 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
33 // ProviderInterface implementations.
34 virtual RuleIterator* GetRuleIterator(
35 ContentSettingsType content_type,
36 const ResourceIdentifier& resource_identifier,
37 bool incognito) const OVERRIDE;
39 virtual bool SetWebsiteSetting(
40 const ContentSettingsPattern& primary_pattern,
41 const ContentSettingsPattern& secondary_pattern,
42 ContentSettingsType content_type,
43 const ResourceIdentifier& resource_identifier,
44 base::Value* value) OVERRIDE;
46 virtual void ClearAllContentSettingsRules(
47 ContentSettingsType content_type) OVERRIDE;
49 virtual void ShutdownOnUIThread() OVERRIDE;
51 private:
52 // Reads the policy managed default settings.
53 void ReadManagedDefaultSettings();
55 // Callback for preference changes.
56 void OnPreferenceChanged(const std::string& pref_name);
58 // Reads the policy controlled default settings for a specific content type.
59 void UpdateManagedDefaultSetting(ContentSettingsType content_type);
61 void ReadManagedContentSettings(bool overwrite);
63 void GetContentSettingsFromPreferences(OriginIdentifierValueMap* rules);
65 void GetAutoSelectCertificateSettingsFromPreferences(
66 OriginIdentifierValueMap* value_map);
68 void ReadManagedContentSettingsTypes(ContentSettingsType content_type);
70 OriginIdentifierValueMap value_map_;
72 PrefService* prefs_;
74 PrefChangeRegistrar pref_change_registrar_;
76 // Used around accesses to the |value_map_| object to guarantee
77 // thread safety.
78 mutable base::Lock lock_;
80 DISALLOW_COPY_AND_ASSIGN(PolicyProvider);
83 } // namespace content_settings
85 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_