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

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

Powered by Google App Engine
This is Rietveld 408576698