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/permissions.json |
| 7 // DO NOT EDIT. |
| 8 |
| 9 #include "tools/json_schema_compiler/util.h" |
| 10 #include "chrome/common/extensions/api/permissions.h" |
| 11 |
| 12 using base::Value; |
| 13 using base::DictionaryValue; |
| 14 using base::ListValue; |
| 15 |
| 16 namespace extensions { |
| 17 namespace api { |
| 18 namespace permissions { |
| 19 |
| 20 // |
| 21 // Types |
| 22 // |
| 23 |
| 24 Permissions::Permissions() {} |
| 25 Permissions::~Permissions() {} |
| 26 |
| 27 // static |
| 28 bool Permissions::Populate(const Value& value, Permissions* out) { |
| 29 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 30 return false; |
| 31 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 32 |
| 33 Value* origins_value = NULL; |
| 34 if (dict->GetWithoutPathExpansion("origins", &origins_value)) { |
| 35 { |
| 36 if (!origins_value->IsType(Value::TYPE_LIST)) |
| 37 return false; |
| 38 ListValue* list = NULL; |
| 39 if (!origins_value->GetAsList(&list)) |
| 40 return false; |
| 41 if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &out
->origins)) |
| 42 return false; |
| 43 } |
| 44 } |
| 45 |
| 46 Value* permissions_value = NULL; |
| 47 if (dict->GetWithoutPathExpansion("permissions", &permissions_value)) { |
| 48 { |
| 49 if (!permissions_value->IsType(Value::TYPE_LIST)) |
| 50 return false; |
| 51 ListValue* list = NULL; |
| 52 if (!permissions_value->GetAsList(&list)) |
| 53 return false; |
| 54 if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &out
->permissions)) |
| 55 return false; |
| 56 } |
| 57 } |
| 58 |
| 59 return true; |
| 60 } |
| 61 |
| 62 scoped_ptr<DictionaryValue> Permissions::ToValue() const { |
| 63 scoped_ptr<DictionaryValue> value(new DictionaryValue()); |
| 64 |
| 65 if (origins.get()) |
| 66 json_schema_compiler::util::PopulateDictionaryFromOptionalArray(origins, "or
igins", value.get()); |
| 67 if (permissions.get()) |
| 68 json_schema_compiler::util::PopulateDictionaryFromOptionalArray(permissions,
"permissions", value.get()); |
| 69 |
| 70 return value.Pass(); |
| 71 } |
| 72 |
| 73 |
| 74 // |
| 75 // Functions |
| 76 // |
| 77 |
| 78 Contains::Params::Params() {} |
| 79 Contains::Params::~Params() {} |
| 80 |
| 81 // static |
| 82 scoped_ptr<Contains::Params> Contains::Params::Create(const ListValue& args) { |
| 83 if (args.GetSize() != 1) |
| 84 return scoped_ptr<Params>(); |
| 85 scoped_ptr<Params> params(new Params()); |
| 86 |
| 87 Value* permissions_value = NULL; |
| 88 if (!args.Get(0, &permissions_value) || permissions_value->IsType(Value::TYPE_
NULL)) |
| 89 return scoped_ptr<Params>(); |
| 90 { |
| 91 if (!permissions_value->IsType(Value::TYPE_DICTIONARY)) |
| 92 return scoped_ptr<Params>(); |
| 93 DictionaryValue* dictionary = NULL; |
| 94 if (!permissions_value->GetAsDictionary(&dictionary)) |
| 95 return scoped_ptr<Params>(); |
| 96 if (!Permissions::Populate(*dictionary, ¶ms->permissions)) |
| 97 return scoped_ptr<Params>(); |
| 98 } |
| 99 |
| 100 return params.Pass(); |
| 101 } |
| 102 |
| 103 |
| 104 Value* Contains::Result::Create(const bool result) { |
| 105 return Value::CreateBooleanValue(result); |
| 106 } |
| 107 |
| 108 Value* GetAll::Result::Create(const Permissions& permissions) { |
| 109 return permissions.ToValue().release(); |
| 110 } |
| 111 |
| 112 Request::Params::Params() {} |
| 113 Request::Params::~Params() {} |
| 114 |
| 115 // static |
| 116 scoped_ptr<Request::Params> Request::Params::Create(const ListValue& args) { |
| 117 if (args.GetSize() != 1) |
| 118 return scoped_ptr<Params>(); |
| 119 scoped_ptr<Params> params(new Params()); |
| 120 |
| 121 Value* permissions_value = NULL; |
| 122 if (!args.Get(0, &permissions_value) || permissions_value->IsType(Value::TYPE_
NULL)) |
| 123 return scoped_ptr<Params>(); |
| 124 { |
| 125 if (!permissions_value->IsType(Value::TYPE_DICTIONARY)) |
| 126 return scoped_ptr<Params>(); |
| 127 DictionaryValue* dictionary = NULL; |
| 128 if (!permissions_value->GetAsDictionary(&dictionary)) |
| 129 return scoped_ptr<Params>(); |
| 130 if (!Permissions::Populate(*dictionary, ¶ms->permissions)) |
| 131 return scoped_ptr<Params>(); |
| 132 } |
| 133 |
| 134 return params.Pass(); |
| 135 } |
| 136 |
| 137 |
| 138 Value* Request::Result::Create(const bool granted) { |
| 139 return Value::CreateBooleanValue(granted); |
| 140 } |
| 141 |
| 142 Remove::Params::Params() {} |
| 143 Remove::Params::~Params() {} |
| 144 |
| 145 // static |
| 146 scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) { |
| 147 if (args.GetSize() != 1) |
| 148 return scoped_ptr<Params>(); |
| 149 scoped_ptr<Params> params(new Params()); |
| 150 |
| 151 Value* permissions_value = NULL; |
| 152 if (!args.Get(0, &permissions_value) || permissions_value->IsType(Value::TYPE_
NULL)) |
| 153 return scoped_ptr<Params>(); |
| 154 { |
| 155 if (!permissions_value->IsType(Value::TYPE_DICTIONARY)) |
| 156 return scoped_ptr<Params>(); |
| 157 DictionaryValue* dictionary = NULL; |
| 158 if (!permissions_value->GetAsDictionary(&dictionary)) |
| 159 return scoped_ptr<Params>(); |
| 160 if (!Permissions::Populate(*dictionary, ¶ms->permissions)) |
| 161 return scoped_ptr<Params>(); |
| 162 } |
| 163 |
| 164 return params.Pass(); |
| 165 } |
| 166 |
| 167 |
| 168 Value* Remove::Result::Create(const bool removed) { |
| 169 return Value::CreateBooleanValue(removed); |
| 170 } |
| 171 |
| 172 } // permissions |
| 173 } // api |
| 174 } // extensions |
OLD | NEW |