OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_OVERRIDE_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_ |
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "components/content_settings/core/browser/content_settings_provider.h" | 10 #include "components/content_settings/core/browser/content_settings_provider.h" |
11 #include "components/content_settings/core/common/content_settings_types.h" | 11 #include "components/content_settings/core/common/content_settings_types.h" |
12 | 12 |
13 class ContentSettingsPattern; | 13 class ContentSettingsPattern; |
14 class PrefService; | 14 class PrefService; |
15 | 15 |
16 namespace user_prefs { | 16 namespace user_prefs { |
17 class PrefRegistrySyncable; | 17 class PrefRegistrySyncable; |
18 } | 18 } |
19 | 19 |
20 namespace content_settings { | 20 namespace content_settings { |
21 | 21 |
22 // OverrideProvider contains if certain content settings are enabled or | 22 // OverrideProvider contains if certain content settings are enabled or |
23 // globally disabled. It may only be written to using the UI thread, but may be | 23 // globally disabled. It may only be written to using the UI thread, but may be |
24 // read on any thread. | 24 // read on any thread. |
25 class OverrideProvider : public ProviderInterface { | 25 class OverrideProvider : public ProviderInterface { |
26 public: | 26 public: |
27 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 27 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
28 | 28 |
29 OverrideProvider(PrefService* prefs, bool incognito); | 29 OverrideProvider(PrefService* prefs, bool incognito); |
30 virtual ~OverrideProvider(); | 30 ~OverrideProvider() override; |
31 | 31 |
32 // ProviderInterface implementations. | 32 // ProviderInterface implementations. |
33 virtual RuleIterator* GetRuleIterator( | 33 RuleIterator* GetRuleIterator(ContentSettingsType content_type, |
34 ContentSettingsType content_type, | 34 const ResourceIdentifier& resource_identifier, |
35 const ResourceIdentifier& resource_identifier, | 35 bool incognito) const override; |
36 bool incognito) const override; | |
37 | 36 |
38 virtual void ClearAllContentSettingsRules( | 37 void ClearAllContentSettingsRules(ContentSettingsType content_type) override; |
39 ContentSettingsType content_type) override; | |
40 | 38 |
41 virtual bool SetWebsiteSetting( | 39 bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern, |
42 const ContentSettingsPattern& primary_pattern, | 40 const ContentSettingsPattern& secondary_pattern, |
43 const ContentSettingsPattern& secondary_pattern, | 41 ContentSettingsType content_type, |
44 ContentSettingsType content_type, | 42 const ResourceIdentifier& resource_identifier, |
45 const ResourceIdentifier& resource_identifier, | 43 base::Value* value) override; |
46 base::Value* value) override; | |
47 | 44 |
48 virtual void ShutdownOnUIThread() override; | 45 void ShutdownOnUIThread() override; |
49 | 46 |
50 // Sets if a given |content_type| is |enabled|. | 47 // Sets if a given |content_type| is |enabled|. |
51 void SetOverrideSetting(ContentSettingsType content_type, bool enabled); | 48 void SetOverrideSetting(ContentSettingsType content_type, bool enabled); |
52 | 49 |
53 // Returns if |content_type| is enabled. If it is not enabled, the content | 50 // Returns if |content_type| is enabled. If it is not enabled, the content |
54 // setting type is considered globally disabled and acts as though it is | 51 // setting type is considered globally disabled and acts as though it is |
55 // blocked. If it is enabled, the content setting type's permission is granted | 52 // blocked. If it is enabled, the content setting type's permission is granted |
56 // by the other providers. | 53 // by the other providers. |
57 bool IsEnabled(ContentSettingsType content_type) const; | 54 bool IsEnabled(ContentSettingsType content_type) const; |
58 | 55 |
(...skipping 11 matching lines...) Expand all Loading... |
70 // Used around accesses to the |override_content_settings_| object to | 67 // Used around accesses to the |override_content_settings_| object to |
71 // guarantee thread safety. | 68 // guarantee thread safety. |
72 mutable base::Lock lock_; | 69 mutable base::Lock lock_; |
73 | 70 |
74 DISALLOW_COPY_AND_ASSIGN(OverrideProvider); | 71 DISALLOW_COPY_AND_ASSIGN(OverrideProvider); |
75 }; | 72 }; |
76 | 73 |
77 } // namespace content_settings | 74 } // namespace content_settings |
78 | 75 |
79 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_ | 76 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_ |
OLD | NEW |