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..babbdc3b97c85c374cca947e35107a6e3f1954fc |
--- /dev/null |
+++ b/chrome/browser/content_settings/content_settings_override_provider.h |
@@ -0,0 +1,57 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
Bernhard Bauer
2014/09/10 09:07:18
2014, and I think the (c) shouldn't be there for n
Daniel Nishi
2014/09/10 16:38:29
Done.
|
+// 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> |
+ |
+#include "base/basictypes.h" |
Bernhard Bauer
2014/09/10 09:07:17
Do you actually need basictypes here, or base/macr
Daniel Nishi
2014/09/10 16:38:29
The latter.
Done.
|
+#include "base/synchronization/lock.h" |
+#include "components/content_settings/core/common/content_settings_types.h" |
+ |
+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/10 09:07:18
What's the thread safety story here?
Daniel Nishi
2014/09/10 16:38:29
I think now that I've locked checking IsEnabled(),
|
+class OverrideProvider { |
+ public: |
+ static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
+ |
+ OverrideProvider(PrefService* prefs, bool incognito); |
+ virtual ~OverrideProvider(); |
+ |
+ // Returns if |content_type| is enabled. |
Bernhard Bauer
2014/09/10 09:07:17
Note that content settings in principle are a gene
Daniel Nishi
2014/09/10 16:38:29
I've clarified the comment.
I think for how it is
|
+ bool IsEnabled(ContentSettingsType content_type) const; |
+ |
+ // Sets |content_type|'s enabled status. |
+ void SetContentSetting(ContentSettingsType content_type, bool is_enabled); |
+ |
+ private: |
+ // Reads the override settings from the preferences service. |
+ void ReadOverrideSettings(); |
+ |
+ // Copies of the pref data, so that we can read it on the IO thread. |
+ std::map<ContentSettingsType, bool> override_settings_; |
+ |
+ 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_ |