Revert 168224 - Update V8 to version 3.15.4.
[chromium-blink-merge.git] / chrome / browser / content_settings / content_settings_policy_provider.h
blobb9c2b4bfbd9d9148292d93c6b45be3b3f0593e31
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/public/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 content_settings {
22 // PolicyProvider that provides managed content-settings.
23 class PolicyProvider : public ObservableProvider {
24 public:
25 explicit PolicyProvider(PrefService* prefs);
26 virtual ~PolicyProvider();
27 static void RegisterUserPrefs(PrefService* prefs);
29 // ProviderInterface implementations.
30 virtual RuleIterator* GetRuleIterator(
31 ContentSettingsType content_type,
32 const ResourceIdentifier& resource_identifier,
33 bool incognito) const OVERRIDE;
35 virtual bool SetWebsiteSetting(
36 const ContentSettingsPattern& primary_pattern,
37 const ContentSettingsPattern& secondary_pattern,
38 ContentSettingsType content_type,
39 const ResourceIdentifier& resource_identifier,
40 Value* value) OVERRIDE;
42 virtual void ClearAllContentSettingsRules(
43 ContentSettingsType content_type) OVERRIDE;
45 virtual void ShutdownOnUIThread() OVERRIDE;
47 private:
48 // Reads the policy managed default settings.
49 void ReadManagedDefaultSettings();
51 // Callback for preference changes.
52 void OnPreferenceChanged(const std::string& pref_name);
54 // Reads the policy controlled default settings for a specific content type.
55 void UpdateManagedDefaultSetting(ContentSettingsType content_type);
57 void ReadManagedContentSettings(bool overwrite);
59 void GetContentSettingsFromPreferences(OriginIdentifierValueMap* rules);
61 void GetAutoSelectCertificateSettingsFromPreferences(
62 OriginIdentifierValueMap* value_map);
64 void ReadManagedContentSettingsTypes(ContentSettingsType content_type);
66 OriginIdentifierValueMap value_map_;
68 PrefService* prefs_;
70 PrefChangeRegistrar pref_change_registrar_;
72 // Used around accesses to the |value_map_| object to guarantee
73 // thread safety.
74 mutable base::Lock lock_;
76 DISALLOW_COPY_AND_ASSIGN(PolicyProvider);
79 } // namespace content_settings
81 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_POLICY_PROVIDER_H_