Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / content_settings / content_settings_rule.cc
blob2e5257579c3ffe7debc9dd7e40d7739c11d5de29
1 // Copyright (c) 2011 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.
5 #include "base/logging.h"
6 #include "chrome/browser/content_settings/content_settings_rule.h"
8 namespace content_settings {
10 Rule::Rule() {}
12 Rule::Rule(
13 const ContentSettingsPattern& primary_pattern,
14 const ContentSettingsPattern& secondary_pattern,
15 base::Value* value)
16 : primary_pattern(primary_pattern),
17 secondary_pattern(secondary_pattern),
18 value(value) {
19 DCHECK(value);
22 Rule::~Rule() {}
24 RuleIterator::~RuleIterator() {}
26 EmptyRuleIterator::~EmptyRuleIterator() {}
28 bool EmptyRuleIterator::HasNext() const {
29 return false;
32 Rule EmptyRuleIterator::Next() {
33 NOTREACHED();
34 return Rule();
37 ConcatenationIterator::ConcatenationIterator(
38 ScopedVector<RuleIterator>* iterators,
39 base::AutoLock* auto_lock)
40 : auto_lock_(auto_lock) {
41 iterators_.swap(*iterators);
43 ScopedVector<RuleIterator>::iterator it = iterators_.begin();
44 while (it != iterators_.end()) {
45 if (!(*it)->HasNext())
46 it = iterators_.erase(it);
47 else
48 ++it;
52 ConcatenationIterator::~ConcatenationIterator() {}
54 bool ConcatenationIterator::HasNext() const {
55 return (!iterators_.empty());
58 Rule ConcatenationIterator::Next() {
59 ScopedVector<RuleIterator>::iterator current_iterator =
60 iterators_.begin();
61 DCHECK(current_iterator != iterators_.end());
62 DCHECK((*current_iterator)->HasNext());
63 const Rule& to_return = (*current_iterator)->Next();
64 if (!(*current_iterator)->HasNext())
65 iterators_.erase(current_iterator);
66 return to_return;
69 } // namespace content_settings