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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/content_settings/content_settings_override_provider.h
diff --git a/chrome/browser/content_settings/content_settings_override_provider.h b/chrome/browser/content_settings/content_settings_override_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..b517386a84d064e6fc662ea5853abf11466f87e4
--- /dev/null
+++ b/chrome/browser/content_settings/content_settings_override_provider.h
@@ -0,0 +1,83 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_
+#define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_
+
+#include <map>
Bernhard Bauer 2014/09/12 09:37:38 This is unnecessary now.
Daniel Nishi 2014/09/12 16:40:35 Done.
+
+#include "base/macros.h"
+#include "base/synchronization/lock.h"
+#include "chrome/browser/content_settings/content_settings_provider.h"
+#include "components/content_settings/core/common/content_settings_types.h"
+
+class ContentSettingsPattern;
+class PrefService;
+
+namespace user_prefs {
+class PrefRegistrySyncable;
+}
+
+namespace content_settings {
+
+// OverrideProvider contains if certain content settings are enabled or
+// 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.
+class OverrideProvider : public ProviderInterface {
+ public:
+ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
+
+ OverrideProvider(PrefService* prefs, bool incognito);
+ virtual ~OverrideProvider();
+
+ // ProviderInterface implementations.
+ virtual RuleIterator* GetRuleIterator(
+ ContentSettingsType content_type,
+ const ResourceIdentifier& resource_identifier,
+ bool incognito) const OVERRIDE;
+
+ virtual void ClearAllContentSettingsRules(
+ ContentSettingsType content_type) OVERRIDE;
+
+ virtual bool SetWebsiteSetting(
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
+ ContentSettingsType content_type,
+ const ResourceIdentifier& resource_identifier,
+ base::Value* value) OVERRIDE;
+
+ virtual void ShutdownOnUIThread() OVERRIDE;
+
+ // Sets if a given |content_type| is |enabled|.
+ void SetOverrideSetting(ContentSettingsType content_type, bool enabled);
+
+ // Returns if |content_type| is enabled. If it is not enabled, the content
+ // setting type is considered globally disabled and acts as though it is
+ // blocked. If it is enabled, the content setting type's permission is granted
+ // by the other providers.
+ bool IsEnabled(ContentSettingsType content_type) const;
+
+ private:
+ // Reads the override settings from the preferences service.
+ void ReadOverrideSettings();
+
+ // Clears all of the settings.
+ void ClearBlockedSettings();
+
+ // Copies of the pref data, so that we can read it on the IO thread.
+ bool allowed_settings_[CONTENT_SETTINGS_NUM_TYPES];
+
+ PrefService* prefs_;
+
+ bool is_incognito_;
+
+ // Used around accesses to the |override_content_settings_| object to
+ // guarantee thread safety.
+ mutable base::Lock lock_;
+
+ DISALLOW_COPY_AND_ASSIGN(OverrideProvider);
+};
+
+} // namespace content_settings
+
+#endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_

Powered by Google App Engine
This is Rietveld 408576698