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 namespace extensions { |
| 13 namespace api { |
| 14 namespace permissions { |
| 15 |
| 16 // |
| 17 // Types |
| 18 // |
| 19 |
| 20 Permissions::Permissions() {} |
| 21 Permissions::~Permissions() {} |
| 22 |
| 23 // static |
| 24 bool Permissions::Populate(const Value& value, Permissions* out) { |
| 25 if (!value.IsType(Value::TYPE_DICTIONARY)) |
| 26 return false; |
| 27 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value); |
| 28 |
| 29 if (!json_schema_compiler::util::GetOptionalStrings(*dict, "origins", &out->or
igins)) |
| 30 return false; |
| 31 if (!json_schema_compiler::util::GetOptionalStrings(*dict, "permissions", &out
->permissions)) |
| 32 return false; |
| 33 return true; |
| 34 } |
| 35 |
| 36 DictionaryValue* Permissions::ToValue() const { |
| 37 DictionaryValue* value = new DictionaryValue(); |
| 38 |
| 39 json_schema_compiler::util::SetOptionalStrings(origins, "origins", value); |
| 40 json_schema_compiler::util::SetOptionalStrings(permissions, "permissions", val
ue); |
| 41 |
| 42 return value; |
| 43 } |
| 44 |
| 45 |
| 46 // |
| 47 // Functions |
| 48 // |
| 49 |
| 50 Contains::Params::Params() {} |
| 51 Contains::Params::~Params() {} |
| 52 |
| 53 // static |
| 54 scoped_ptr<Contains::Params> Contains::Params::Create(const ListValue& args) { |
| 55 if (args.GetSize() != 1) |
| 56 return scoped_ptr<Params>(); |
| 57 |
| 58 scoped_ptr<Params> params(new Params()); |
| 59 |
| 60 DictionaryValue* permissions_param = NULL; |
| 61 if (!args.GetDictionary(0, &permissions_param)) |
| 62 return scoped_ptr<Params>(); |
| 63 if (!Permissions::Populate(*permissions_param, ¶ms->permissions)) |
| 64 return scoped_ptr<Params>(); |
| 65 |
| 66 return params.Pass(); |
| 67 } |
| 68 |
| 69 // static |
| 70 Value* Contains::Result::Create(const bool result) { |
| 71 return Value::CreateBooleanValue(result); |
| 72 } |
| 73 |
| 74 // static |
| 75 Value* GetAll::Result::Create(const Permissions& permissions) { |
| 76 return permissions.ToValue(); |
| 77 } |
| 78 |
| 79 Request::Params::Params() {} |
| 80 Request::Params::~Params() {} |
| 81 |
| 82 // static |
| 83 scoped_ptr<Request::Params> Request::Params::Create(const ListValue& args) { |
| 84 if (args.GetSize() != 1) |
| 85 return scoped_ptr<Params>(); |
| 86 |
| 87 scoped_ptr<Params> params(new Params()); |
| 88 |
| 89 DictionaryValue* permissions_param = NULL; |
| 90 if (!args.GetDictionary(0, &permissions_param)) |
| 91 return scoped_ptr<Params>(); |
| 92 if (!Permissions::Populate(*permissions_param, ¶ms->permissions)) |
| 93 return scoped_ptr<Params>(); |
| 94 |
| 95 return params.Pass(); |
| 96 } |
| 97 |
| 98 // static |
| 99 Value* Request::Result::Create(const bool granted) { |
| 100 return Value::CreateBooleanValue(granted); |
| 101 } |
| 102 |
| 103 Remove::Params::Params() {} |
| 104 Remove::Params::~Params() {} |
| 105 |
| 106 // static |
| 107 scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) { |
| 108 if (args.GetSize() != 1) |
| 109 return scoped_ptr<Params>(); |
| 110 |
| 111 scoped_ptr<Params> params(new Params()); |
| 112 |
| 113 DictionaryValue* permissions_param = NULL; |
| 114 if (!args.GetDictionary(0, &permissions_param)) |
| 115 return scoped_ptr<Params>(); |
| 116 if (!Permissions::Populate(*permissions_param, ¶ms->permissions)) |
| 117 return scoped_ptr<Params>(); |
| 118 |
| 119 return params.Pass(); |
| 120 } |
| 121 |
| 122 // static |
| 123 Value* Remove::Result::Create(const bool removed) { |
| 124 return Value::CreateBooleanValue(removed); |
| 125 } |
| 126 |
| 127 } // permissions |
| 128 } // api |
| 129 } // extensions |
OLD | NEW |