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 // Interface for objects providing content setting rules.
7 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_RULE_H_
8 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_RULE_H_
10 #include "base/compiler_specific.h"
11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h"
14 #include "base/synchronization/lock.h"
15 #include "base/values.h"
16 #include "components/content_settings/core/common/content_settings_pattern.h"
18 namespace content_settings
{
22 // Rule takes ownership of |value|.
23 Rule(const ContentSettingsPattern
& primary_pattern
,
24 const ContentSettingsPattern
& secondary_pattern
,
28 ContentSettingsPattern primary_pattern
;
29 ContentSettingsPattern secondary_pattern
;
30 linked_ptr
<base::Value
> value
;
35 virtual ~RuleIterator();
36 virtual bool HasNext() const = 0;
37 virtual Rule
Next() = 0;
40 class EmptyRuleIterator
: public RuleIterator
{
42 ~EmptyRuleIterator() override
;
43 bool HasNext() const override
;
47 class ConcatenationIterator
: public RuleIterator
{
49 // ConcatenationIterator takes ownership of the pointers in the |iterators|
50 // list and |auto_lock|. |auto_lock| can be NULL if no locking is needed.
51 ConcatenationIterator(ScopedVector
<RuleIterator
>* iterators
,
52 base::AutoLock
* auto_lock
);
53 ~ConcatenationIterator() override
;
54 bool HasNext() const override
;
58 ScopedVector
<RuleIterator
> iterators_
;
59 scoped_ptr
<base::AutoLock
> auto_lock_
;
62 } // namespace content_settings
64 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_RULE_H_