OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/content_settings/core/browser/content_settings_binary_value
_map.h" | 5 #include "components/content_settings/core/browser/content_settings_binary_value
_map.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "components/content_settings/core/browser/content_settings_rule.h" | 10 #include "components/content_settings/core/browser/content_settings_rule.h" |
11 #include "components/content_settings/core/common/content_settings.h" | 11 #include "components/content_settings/core/common/content_settings.h" |
12 | 12 |
13 namespace content_settings { | 13 namespace content_settings { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 class RuleIteratorBinary : public RuleIterator { | 17 class RuleIteratorBinary : public RuleIterator { |
18 public: | 18 public: |
19 RuleIteratorBinary(bool is_enabled, std::unique_ptr<base::AutoLock> auto_lock) | 19 RuleIteratorBinary(bool is_enabled, std::unique_ptr<base::AutoLock> auto_lock) |
20 : is_done_(is_enabled), auto_lock_(std::move(auto_lock)) {} | 20 : is_done_(is_enabled), auto_lock_(std::move(auto_lock)) {} |
21 | 21 |
22 bool HasNext() const override { return !is_done_; } | 22 bool HasNext() const override { return !is_done_; } |
23 | 23 |
24 Rule Next() override { | 24 Rule Next() override { |
25 DCHECK(HasNext()); | 25 DCHECK(HasNext()); |
26 is_done_ = true; | 26 is_done_ = true; |
27 return Rule(ContentSettingsPattern::Wildcard(), | 27 return Rule(ContentSettingsPattern::Wildcard(), |
28 ContentSettingsPattern::Wildcard(), | 28 ContentSettingsPattern::Wildcard(), |
29 new base::FundamentalValue(CONTENT_SETTING_BLOCK)); | 29 new base::Value(CONTENT_SETTING_BLOCK)); |
30 } | 30 } |
31 | 31 |
32 private: | 32 private: |
33 bool is_done_; | 33 bool is_done_; |
34 std::unique_ptr<base::AutoLock> auto_lock_; | 34 std::unique_ptr<base::AutoLock> auto_lock_; |
35 }; | 35 }; |
36 | 36 |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 BinaryValueMap::BinaryValueMap() {} | 39 BinaryValueMap::BinaryValueMap() {} |
(...skipping 15 matching lines...) Expand all Loading... |
55 is_enabled_[content_type] = !is_disabled; | 55 is_enabled_[content_type] = !is_disabled; |
56 } | 56 } |
57 | 57 |
58 bool BinaryValueMap::IsContentSettingEnabled( | 58 bool BinaryValueMap::IsContentSettingEnabled( |
59 ContentSettingsType content_type) const { | 59 ContentSettingsType content_type) const { |
60 auto it = is_enabled_.find(content_type); | 60 auto it = is_enabled_.find(content_type); |
61 return it == is_enabled_.end() || it->second; | 61 return it == is_enabled_.end() || it->second; |
62 } | 62 } |
63 | 63 |
64 } // namespace content_settings | 64 } // namespace content_settings |
OLD | NEW |