Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / extensions / api / declarative_content / content_condition.h
blob7df7fe3dc8306c4f3e8b7f7c8821b2875b9bc7c1
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_
8 #include <map>
9 #include <string>
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"
15 namespace base {
16 class Value;
19 namespace extensions {
21 class Extension;
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 {
31 public:
32 explicit ContentCondition(ScopedVector<const ContentPredicate> predicates);
33 ~ContentCondition();
35 ScopedVector<const ContentPredicate> predicates;
37 private:
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,
50 std::string* error);
52 } // namespace extensions
54 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_CONDITION_H_