1 // Copyright 2015 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_CONDITION_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_CONDITION_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h"
13 #include "chrome/browser/extensions/api/declarative_content/content_predicate_evaluator.h"
19 namespace extensions
{
23 // Representation of a condition in the Declarative Content API. A condition
24 // consists of a set of predicates on the page state, all of which must be
25 // satisified for the condition to be fulfilled.
27 // For example, given the sample code at
28 // https://developer.chrome.com/extensions/declarativeContent#rules, the entity
29 // rule1['conditions'][0] is represented by a ContentCondition.
30 struct ContentCondition
{
32 explicit ContentCondition(ScopedVector
<const ContentPredicate
> predicates
);
35 ScopedVector
<const ContentPredicate
> predicates
;
38 DISALLOW_COPY_AND_ASSIGN(ContentCondition
);
41 // Factory function that instantiates a ContentCondition according to the
42 // description |condition|, which should be an instance of
43 // declarativeContent.PageStateMatcher from the Declarative Content
44 // API. |predicate_factories| maps attribute names in the API to factories that
45 // create the corresponding predicate.
46 scoped_ptr
<ContentCondition
> CreateContentCondition(
47 const Extension
* extension
,
48 const std::map
<std::string
, ContentPredicateFactory
*>& predicate_factories
,
49 const base::Value
& condition
,
52 } // namespace extensions
54 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_CONDITION_H_