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

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

Issue 542253003: Add a global on/off switch for content settings and expose a toggle on the Website Settings options… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@global-settings
Patch Set: Rebase. Created 6 years, 3 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
OLDNEW
(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 "base/macros.h"
9 #include "base/synchronization/lock.h"
10 #include "components/content_settings/core/browser/content_settings_provider.h"
11 #include "components/content_settings/core/common/content_settings_types.h"
12
13 class ContentSettingsPattern;
14 class PrefService;
15
16 namespace user_prefs {
17 class PrefRegistrySyncable;
18 }
19
20 namespace content_settings {
21
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
24 // read on any thread.
25 class OverrideProvider : public ProviderInterface {
26 public:
27 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
28
29 OverrideProvider(PrefService* prefs, bool incognito);
30 virtual ~OverrideProvider();
31
32 // ProviderInterface implementations.
33 virtual RuleIterator* GetRuleIterator(
34 ContentSettingsType content_type,
35 const ResourceIdentifier& resource_identifier,
36 bool incognito) const OVERRIDE;
37
38 virtual void ClearAllContentSettingsRules(
39 ContentSettingsType content_type) OVERRIDE;
40
41 virtual bool SetWebsiteSetting(
42 const ContentSettingsPattern& primary_pattern,
43 const ContentSettingsPattern& secondary_pattern,
44 ContentSettingsType content_type,
45 const ResourceIdentifier& resource_identifier,
46 base::Value* value) OVERRIDE;
47
48 virtual void ShutdownOnUIThread() OVERRIDE;
49
50 // Sets if a given |content_type| is |enabled|.
51 void SetOverrideSetting(ContentSettingsType content_type, bool enabled);
52
53 // 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
55 // blocked. If it is enabled, the content setting type's permission is granted
56 // by the other providers.
57 bool IsEnabled(ContentSettingsType content_type) const;
58
59 private:
60 // Reads the override settings from the preferences service.
61 void ReadOverrideSettings();
62
63 // Copies of the pref data, so that we can read it on the IO thread.
64 bool allowed_settings_[CONTENT_SETTINGS_NUM_TYPES];
65
66 PrefService* prefs_;
67
68 bool is_incognito_;
69
70 // Used around accesses to the |override_content_settings_| object to
71 // guarantee thread safety.
72 mutable base::Lock lock_;
73
74 DISALLOW_COPY_AND_ASSIGN(OverrideProvider);
75 };
76
77 } // namespace content_settings
78
79 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/browser/content_settings/content_settings_override_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698