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

Unified Diff: components/content_settings/core/browser/content_settings_binary_value_map.cc

Issue 902833003: Add a HostContentSettingsMap layer for Supervised Users. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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: components/content_settings/core/browser/content_settings_binary_value_map.cc
diff --git a/components/content_settings/core/browser/content_settings_binary_value_map.cc b/components/content_settings/core/browser/content_settings_binary_value_map.cc
new file mode 100644
index 0000000000000000000000000000000000000000..136d3874dd10f265ffb9395203f6aab4bdc23235
--- /dev/null
+++ b/components/content_settings/core/browser/content_settings_binary_value_map.cc
@@ -0,0 +1,65 @@
+// Copyright (c) 2015 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.
+
+#include "components/content_settings/core/browser/content_settings_binary_value_map.h"
+
+#include "base/synchronization/lock.h"
+#include "components/content_settings/core/browser/content_settings_rule.h"
+#include "components/content_settings/core/common/content_settings.h"
+
+namespace content_settings {
+
+namespace {
+
+class RuleIteratorBinary : public RuleIterator {
+ public:
+ explicit RuleIteratorBinary(bool is_enabled,
+ scoped_ptr<base::AutoLock> auto_lock)
+ : is_done_(is_enabled), auto_lock_(auto_lock.Pass()) {}
+
+ bool HasNext() const override { return !is_done_; }
+
+ Rule Next() override {
+ DCHECK(!is_done_);
+ is_done_ = true;
+ return Rule(ContentSettingsPattern::Wildcard(),
+ ContentSettingsPattern::Wildcard(),
+ new base::FundamentalValue(CONTENT_SETTING_BLOCK));
+ }
+
+ private:
+ bool is_done_;
+ scoped_ptr<base::AutoLock> auto_lock_;
+};
+
+} // namespace
+
+BinaryValueMap::BinaryValueMap() {
+ for (bool& enabled : is_enabled_) {
+ enabled = true;
+ }
+}
+
+RuleIterator* BinaryValueMap::GetRuleIterator(
+ ContentSettingsType content_type,
+ const ResourceIdentifier& resource_identifier,
+ scoped_ptr<base::AutoLock> auto_lock) const {
+ if (resource_identifier.empty()) {
+ return new RuleIteratorBinary(IsContentSettingEnabled(content_type),
+ auto_lock.Pass());
+ }
+ return new EmptyRuleIterator();
+}
+
+void BinaryValueMap::SetContentSettingDisabled(ContentSettingsType content_type,
+ bool is_disabled) {
+ is_enabled_[content_type] = !is_disabled;
+}
+
+bool BinaryValueMap::IsContentSettingEnabled(
+ ContentSettingsType content_type) const {
+ return is_enabled_[content_type];
+}
+
+} // namespace content_settings

Powered by Google App Engine
This is Rietveld 408576698