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 #include "tools/json_schema_compiler/util.h" | |
10 #include "chrome/common/extensions/api/experimental.declarative.h" | |
11 | |
12 namespace extensions { | |
13 namespace api { | |
14 namespace experimental_declarative { | |
15 | |
16 // | |
17 // Types | |
18 // | |
19 | |
20 Rule::Rule() {} | |
21 Rule::~Rule() {} | |
22 | |
23 // static | |
24 bool Rule::Populate(const Value& value, Rule* out) { | |
25 if (!value.IsType(Value::TYPE_DICTIONARY)) | |
26 return false; | |
27 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); | |
28 | |
29 { | |
30 int priority_temp; | |
31 if (dict->GetInteger("priority", &priority_temp)) | |
32 out->priority.reset(new int(priority_temp)); | |
33 } | |
34 if (!json_schema_compiler::util::GetArrayFromDictionary(*dict, "conditions", & out->conditions)) | |
35 return false; | |
36 { | |
37 std::string id_temp; | |
38 if (dict->GetString("id", &id_temp)) | |
39 out->id.reset(new std::string(id_temp)); | |
40 } | |
41 if (!json_schema_compiler::util::GetArrayFromDictionary(*dict, "actions", &out ->actions)) | |
42 return false; | |
43 return true; | |
44 } | |
45 | |
46 DictionaryValue* Rule::ToValue() const { | |
47 DictionaryValue* value = new DictionaryValue(); | |
48 | |
49 if (priority.get()) | |
50 value->SetWithoutPathExpansion("priority", Value::CreateIntegerValue(*priori ty)); | |
51 json_schema_compiler::util::SetArrayToDictionary(conditions, "conditions", val ue); | |
52 if (id.get()) | |
53 value->SetWithoutPathExpansion("id", Value::CreateStringValue(*id)); | |
54 json_schema_compiler::util::SetArrayToDictionary(actions, "actions", value); | |
55 | |
56 return value; | |
57 } | |
58 | |
59 | |
60 // | |
61 // Functions | |
62 // | |
63 | |
64 GetRules::Params::Params() {} | |
65 GetRules::Params::~Params() {} | |
66 | |
67 // static | |
68 scoped_ptr<GetRules::Params> GetRules::Params::Create(const ListValue& args) { | |
69 if (args.GetSize() != 2) | |
70 return scoped_ptr<Params>(); | |
71 scoped_ptr<Params> params(new Params()); | |
72 | |
73 if (!args.GetString(0, ¶ms->event)) | |
74 return scoped_ptr<Params>(); | |
75 | |
76 ListValue* rule_identifiers_param = NULL; | |
77 if (!args.GetList(1, &rule_identifiers_param)) | |
78 return scoped_ptr<Params>(); | |
79 if (!json_schema_compiler::util::GetArrayFromList(*rule_identifiers_param, &pa rams->rule_identifiers)) | |
80 return scoped_ptr<Params>(); | |
81 | |
82 return params.Pass(); | |
83 } | |
84 | |
85 // static | |
86 // Rules that were registered, the optional parameters are filled with values. | |
battre
2012/02/08 09:15:20
I think it is sufficient to have this comment in t
calamity
2012/02/09 00:56:52
Done.
| |
87 Value* GetRules::Result::Create(const std::vector<linked_ptr<Rule> > rules) { | |
88 ListValue* value = new ListValue(); | |
89 json_schema_compiler::util::SetArrayToList(rules, value); | |
90 return value; | |
91 } | |
92 | |
93 RemoveRules::Params::Params() {} | |
94 RemoveRules::Params::~Params() {} | |
95 | |
96 // static | |
97 scoped_ptr<RemoveRules::Params> RemoveRules::Params::Create(const ListValue& arg s) { | |
98 if (args.GetSize() != 2) | |
99 return scoped_ptr<Params>(); | |
100 scoped_ptr<Params> params(new Params()); | |
101 | |
102 if (!args.GetString(0, ¶ms->event)) | |
103 return scoped_ptr<Params>(); | |
104 | |
105 ListValue* rule_identifiers_param = NULL; | |
106 if (!args.GetList(1, &rule_identifiers_param)) | |
107 return scoped_ptr<Params>(); | |
108 if (!json_schema_compiler::util::GetArrayFromList(*rule_identifiers_param, &pa rams->rule_identifiers)) | |
109 return scoped_ptr<Params>(); | |
110 | |
111 return params.Pass(); | |
112 } | |
113 | |
114 // static | |
115 Value* RemoveRules::Result::Create() { | |
116 return Value::CreateNullValue(); | |
117 } | |
118 | |
119 AddRules::Params::Params() {} | |
120 AddRules::Params::~Params() {} | |
121 | |
122 // static | |
123 scoped_ptr<AddRules::Params> AddRules::Params::Create(const ListValue& args) { | |
124 if (args.GetSize() != 2) | |
125 return scoped_ptr<Params>(); | |
126 scoped_ptr<Params> params(new Params()); | |
127 | |
128 if (!args.GetString(0, ¶ms->event)) | |
129 return scoped_ptr<Params>(); | |
130 | |
131 ListValue* rules_param = NULL; | |
132 if (!args.GetList(1, &rules_param)) | |
133 return scoped_ptr<Params>(); | |
134 if (!json_schema_compiler::util::GetArrayFromList(*rules_param, ¶ms->rules )) | |
135 return scoped_ptr<Params>(); | |
136 | |
137 return params.Pass(); | |
138 } | |
139 | |
140 // static | |
141 // Rules that were registered, the optional parameters are filled with values. | |
142 Value* AddRules::Result::Create(const std::vector<linked_ptr<Rule> > rules) { | |
143 ListValue* value = new ListValue(); | |
144 json_schema_compiler::util::SetArrayToList(rules, value); | |
145 return value; | |
146 } | |
147 | |
148 } // experimental_declarative | |
149 } // api | |
150 } // extensions | |
OLD | NEW |