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