OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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. | |
4 | |
5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_ | |
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_ | |
7 | |
8 #include <map> | |
9 | |
10 #include "base/macros.h" | |
11 #include "base/memory/linked_ptr.h" | |
12 #include "base/synchronization/lock.h" | |
13 #include "chrome/browser/content_settings/content_settings_provider.h" | |
14 #include "components/content_settings/core/common/content_settings_types.h" | |
15 | |
16 class ContentSettingsPattern; | |
17 class PrefService; | |
18 | |
19 namespace user_prefs { | |
20 class PrefRegistrySyncable; | |
21 } | |
22 | |
23 namespace content_settings { | |
24 | |
25 // OverrideProvider contains if certain content settings are enabled or | |
26 // globally disabled. | |
27 class OverrideProvider : public ProviderInterface { | |
28 public: | |
29 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | |
30 | |
31 OverrideProvider(PrefService* prefs, bool incognito); | |
32 virtual ~OverrideProvider(); | |
33 | |
34 // ProviderInterface implementations. | |
35 virtual RuleIterator* GetRuleIterator( | |
36 ContentSettingsType content_type, | |
37 const ResourceIdentifier& resource_identifier, | |
38 bool incognito) const OVERRIDE; | |
39 | |
40 virtual void ClearAllContentSettingsRules( | |
41 ContentSettingsType content_type) OVERRIDE; | |
42 | |
43 virtual bool SetWebsiteSetting( | |
44 const ContentSettingsPattern& primary_pattern, | |
45 const ContentSettingsPattern& secondary_pattern, | |
46 ContentSettingsType content_type, | |
47 const ResourceIdentifier& resource_identifier, | |
48 base::Value* value) OVERRIDE; | |
49 | |
50 virtual void ShutdownOnUIThread() OVERRIDE; | |
51 | |
52 // Returns if |content_type| is enabled. If it is not enabled, the content | |
53 // setting type is considered globally disabled and acts as though it is | |
54 // blocked. If it is enabled, the content setting type's permission is granted | |
55 // by the other providers. | |
56 bool IsEnabled(ContentSettingsType content_type) const; | |
57 | |
58 private: | |
59 // Reads the override settings from the preferences service. | |
60 void ReadOverrideSettings(); | |
61 | |
62 // Copies of the pref data, so that we can read it on the IO thread. | |
63 typedef linked_ptr<base::Value> ValuePtr; | |
64 typedef std::map<ContentSettingsType, ValuePtr> ValueMap; | |
Bernhard Bauer
2014/09/11 16:49:56
If this provider is only used to turn content type
Daniel Nishi
2014/09/11 20:58:12
Done.
| |
65 ValueMap override_settings_; | |
66 | |
67 PrefService* prefs_; | |
68 | |
69 bool is_incognito_; | |
70 | |
71 // Used around accesses to the |override_content_settings_| object to | |
72 // guarantee thread safety. | |
73 mutable base::Lock lock_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(OverrideProvider); | |
76 }; | |
77 | |
78 } // namespace content_settings | |
79 | |
80 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_ | |
OLD | NEW |