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 CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_RULE_H_
8 #define CHROME_BROWSER_CONTENT_SETTINGS_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 "chrome/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 virtual ~EmptyRuleIterator();
43 virtual bool HasNext() const OVERRIDE
;
44 virtual Rule
Next() 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 virtual ~ConcatenationIterator();
54 virtual bool HasNext() const OVERRIDE
;
55 virtual Rule
Next() OVERRIDE
;
57 ScopedVector
<RuleIterator
> iterators_
;
58 scoped_ptr
<base::AutoLock
> auto_lock_
;
61 } // namespace content_settings
63 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_RULE_H_