OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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. |
| 4 |
| 5 // GENERATED FROM THE API DEFINITION IN |
| 6 // chrome/common/extensions/api/experimental.declarative.json |
| 7 // DO NOT EDIT. |
| 8 |
| 9 #ifndef CHROME_COMMON_EXTENSIONS_API_EXPERIMENTAL_DECLARATIVE_H__ |
| 10 #define CHROME_COMMON_EXTENSIONS_API_EXPERIMENTAL_DECLARATIVE_H__ |
| 11 #pragma once |
| 12 |
| 13 #include <string> |
| 14 #include <vector> |
| 15 |
| 16 #include "base/basictypes.h" |
| 17 #include "base/memory/linked_ptr.h" |
| 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/values.h" |
| 20 |
| 21 using base::Value; |
| 22 using base::DictionaryValue; |
| 23 using base::ListValue; |
| 24 |
| 25 namespace extensions { |
| 26 namespace api { |
| 27 namespace experimental_declarative { |
| 28 |
| 29 // |
| 30 // Types |
| 31 // |
| 32 |
| 33 // Description of a declarative rule for handling events. |
| 34 struct Rule { |
| 35 ~Rule(); |
| 36 Rule(); |
| 37 |
| 38 // Optional priority of this rule. Defaults to 100. |
| 39 scoped_ptr<int> priority; |
| 40 |
| 41 // List of conditions that can trigger the actions. |
| 42 std::vector<linked_ptr<DictionaryValue> > conditions; |
| 43 |
| 44 // Optional identifier that allows referencing this rule. |
| 45 scoped_ptr<std::string> id; |
| 46 |
| 47 // List of actions that are triggered if one of the condtions is fulfilled. |
| 48 std::vector<linked_ptr<DictionaryValue> > actions; |
| 49 |
| 50 // Populates a Rule object from a Value. Returns whether |out| was |
| 51 // successfully populated. |
| 52 static bool Populate(const Value& value, Rule* out); |
| 53 |
| 54 // Returns a new DictionaryValue representing the serialized form of this |
| 55 // Rule object. Passesownership to caller. |
| 56 DictionaryValue* ToValue() const; |
| 57 |
| 58 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(Rule); |
| 60 }; |
| 61 |
| 62 // |
| 63 // Functions |
| 64 // |
| 65 |
| 66 namespace GetRules { |
| 67 struct Params { |
| 68 // Name of the event this function affects. |
| 69 // If non-empty, only rules with identifiers contained in this array are |
| 70 // returned. |
| 71 std::string event; |
| 72 std::vector<std::string> rule_identifiers; |
| 73 |
| 74 ~Params(); |
| 75 |
| 76 static scoped_ptr<Params> Create(const ListValue& args); |
| 77 |
| 78 private: |
| 79 Params(); |
| 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(Params); |
| 82 }; |
| 83 |
| 84 class Result { |
| 85 public: |
| 86 // Rules that were registered, the optional parameters are filled with |
| 87 // values. |
| 88 static Value* Create(const std::vector<linked_ptr<Rule> > rules); |
| 89 |
| 90 private: |
| 91 Result() {}; |
| 92 DISALLOW_COPY_AND_ASSIGN(Result); |
| 93 }; |
| 94 |
| 95 }; |
| 96 |
| 97 namespace RemoveRules { |
| 98 struct Params { |
| 99 // Name of the event this function affects. |
| 100 // If non-empty, only rules with identifiers contained in this array are |
| 101 // unregistered. |
| 102 std::string event; |
| 103 std::vector<std::string> rule_identifiers; |
| 104 |
| 105 ~Params(); |
| 106 |
| 107 static scoped_ptr<Params> Create(const ListValue& args); |
| 108 |
| 109 private: |
| 110 Params(); |
| 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(Params); |
| 113 }; |
| 114 |
| 115 class Result { |
| 116 public: |
| 117 static Value* Create(); |
| 118 |
| 119 private: |
| 120 Result() {}; |
| 121 DISALLOW_COPY_AND_ASSIGN(Result); |
| 122 }; |
| 123 |
| 124 }; |
| 125 |
| 126 namespace AddRules { |
| 127 struct Params { |
| 128 // Name of the event this function affects. |
| 129 // Rules to be registered. These do not replace previously registered rules. |
| 130 std::string event; |
| 131 std::vector<linked_ptr<Rule> > rules; |
| 132 |
| 133 ~Params(); |
| 134 |
| 135 static scoped_ptr<Params> Create(const ListValue& args); |
| 136 |
| 137 private: |
| 138 Params(); |
| 139 |
| 140 DISALLOW_COPY_AND_ASSIGN(Params); |
| 141 }; |
| 142 |
| 143 class Result { |
| 144 public: |
| 145 // Rules that were registered, the optional parameters are filled with |
| 146 // values. |
| 147 static Value* Create(const std::vector<linked_ptr<Rule> > rules); |
| 148 |
| 149 private: |
| 150 Result() {}; |
| 151 DISALLOW_COPY_AND_ASSIGN(Result); |
| 152 }; |
| 153 |
| 154 }; |
| 155 |
| 156 |
| 157 } // experimental_declarative |
| 158 } // api |
| 159 } // extensions |
| 160 |
| 161 #endif // CHROME_COMMON_EXTENSIONS_API_EXPERIMENTAL_DECLARATIVE_H__ |
OLD | NEW |