OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_CONDITION_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_CONDITION_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_CONDITION_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_CONDITION_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "chrome/browser/extensions/api/declarative_content/content_predicate_ev
aluator.h" | 14 #include "chrome/browser/extensions/api/declarative_content/content_predicate_ev
aluator.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class Value; | 17 class Value; |
18 } | 18 } |
19 | 19 |
20 namespace extensions { | 20 namespace extensions { |
21 | 21 |
22 class Extension; | 22 class Extension; |
23 | 23 |
24 // Representation of a condition in the Declarative Content API. A condition | 24 // Representation of a condition in the Declarative Content API. A condition |
25 // consists of a set of predicates on the page state, all of which must be | 25 // consists of a set of predicates on the page state, all of which must be |
26 // satisified for the condition to be fulfilled. | 26 // satisified for the condition to be fulfilled. |
27 // | 27 // |
28 // For example, given the sample code at | 28 // For example, given the sample code at |
29 // https://developer.chrome.com/extensions/declarativeContent#rules, the entity | 29 // https://developer.chrome.com/extensions/declarativeContent#rules, the entity |
30 // rule1['conditions'][0] is represented by a ContentCondition. | 30 // rule1['conditions'][0] is represented by a ContentCondition. |
31 struct ContentCondition { | 31 struct ContentCondition { |
32 public: | 32 public: |
33 explicit ContentCondition( | 33 explicit ContentCondition( |
34 std::vector<scoped_ptr<const ContentPredicate>> predicates); | 34 std::vector<std::unique_ptr<const ContentPredicate>> predicates); |
35 ~ContentCondition(); | 35 ~ContentCondition(); |
36 | 36 |
37 std::vector<scoped_ptr<const ContentPredicate>> predicates; | 37 std::vector<std::unique_ptr<const ContentPredicate>> predicates; |
38 | 38 |
39 private: | 39 private: |
40 DISALLOW_COPY_AND_ASSIGN(ContentCondition); | 40 DISALLOW_COPY_AND_ASSIGN(ContentCondition); |
41 }; | 41 }; |
42 | 42 |
43 // Factory function that instantiates a ContentCondition according to the | 43 // Factory function that instantiates a ContentCondition according to the |
44 // description |condition|, which should be an instance of | 44 // description |condition|, which should be an instance of |
45 // declarativeContent.PageStateMatcher from the Declarative Content | 45 // declarativeContent.PageStateMatcher from the Declarative Content |
46 // API. |predicate_factories| maps attribute names in the API to factories that | 46 // API. |predicate_factories| maps attribute names in the API to factories that |
47 // create the corresponding predicate. | 47 // create the corresponding predicate. |
48 scoped_ptr<ContentCondition> CreateContentCondition( | 48 std::unique_ptr<ContentCondition> CreateContentCondition( |
49 const Extension* extension, | 49 const Extension* extension, |
50 const std::map<std::string, ContentPredicateFactory*>& predicate_factories, | 50 const std::map<std::string, ContentPredicateFactory*>& predicate_factories, |
51 const base::Value& condition, | 51 const base::Value& condition, |
52 std::string* error); | 52 std::string* error); |
53 | 53 |
54 } // namespace extensions | 54 } // namespace extensions |
55 | 55 |
56 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_CONDITION_H
_ | 56 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_CONDITION_H
_ |
OLD | NEW |