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::GetOptionalArrayFromDictionary(*dict, "origin
s", &out->origins)) |
| 30 return false; |
| 31 if (!json_schema_compiler::util::GetOptionalArrayFromDictionary(*dict, "permis
sions", &out->permissions)) |
| 32 return false; |
| 33 return true; |
| 34 } |
| 35 |
| 36 DictionaryValue* Permissions::ToValue() const { |
| 37 DictionaryValue* value = new DictionaryValue(); |
| 38 |
| 39 if (origins.get()) |
| 40 json_schema_compiler::util::SetOptionalArrayToDictionary(origins, "origins",
value); |
| 41 if (permissions.get()) |
| 42 json_schema_compiler::util::SetOptionalArrayToDictionary(permissions, "permi
ssions", value); |
| 43 |
| 44 return value; |
| 45 } |
| 46 |
| 47 |
| 48 // |
| 49 // Functions |
| 50 // |
| 51 |
| 52 Contains::Params::Params() {} |
| 53 Contains::Params::~Params() {} |
| 54 |
| 55 // static |
| 56 scoped_ptr<Contains::Params> Contains::Params::Create(const ListValue& args) { |
| 57 if (args.GetSize() < 1) |
| 58 return scoped_ptr<Params>(); |
| 59 scoped_ptr<Params> params(new Params()); |
| 60 |
| 61 DictionaryValue* permissions_param = NULL; |
| 62 if (!args.GetDictionary(0, &permissions_param)) |
| 63 return scoped_ptr<Params>(); |
| 64 if (!Permissions::Populate(*permissions_param, ¶ms->permissions)) |
| 65 return scoped_ptr<Params>(); |
| 66 |
| 67 return params.Pass(); |
| 68 } |
| 69 |
| 70 // static |
| 71 // True if the extension has the specified permissions. |
| 72 Value* Contains::Result::Create(const bool result) { |
| 73 return Value::CreateBooleanValue(result); |
| 74 } |
| 75 |
| 76 // static |
| 77 // The extension's active permissions. |
| 78 Value* GetAll::Result::Create(const Permissions& permissions) { |
| 79 return permissions.ToValue(); |
| 80 } |
| 81 |
| 82 Request::Params::Params() {} |
| 83 Request::Params::~Params() {} |
| 84 |
| 85 // static |
| 86 scoped_ptr<Request::Params> Request::Params::Create(const ListValue& args) { |
| 87 if (args.GetSize() < 1) |
| 88 return scoped_ptr<Params>(); |
| 89 scoped_ptr<Params> params(new Params()); |
| 90 |
| 91 DictionaryValue* permissions_param = NULL; |
| 92 if (!args.GetDictionary(0, &permissions_param)) |
| 93 return scoped_ptr<Params>(); |
| 94 if (!Permissions::Populate(*permissions_param, ¶ms->permissions)) |
| 95 return scoped_ptr<Params>(); |
| 96 |
| 97 return params.Pass(); |
| 98 } |
| 99 |
| 100 // static |
| 101 // True if the user granted the specified permissions. |
| 102 Value* Request::Result::Create(const bool granted) { |
| 103 return Value::CreateBooleanValue(granted); |
| 104 } |
| 105 |
| 106 Remove::Params::Params() {} |
| 107 Remove::Params::~Params() {} |
| 108 |
| 109 // static |
| 110 scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) { |
| 111 if (args.GetSize() < 1) |
| 112 return scoped_ptr<Params>(); |
| 113 scoped_ptr<Params> params(new Params()); |
| 114 |
| 115 DictionaryValue* permissions_param = NULL; |
| 116 if (!args.GetDictionary(0, &permissions_param)) |
| 117 return scoped_ptr<Params>(); |
| 118 if (!Permissions::Populate(*permissions_param, ¶ms->permissions)) |
| 119 return scoped_ptr<Params>(); |
| 120 |
| 121 return params.Pass(); |
| 122 } |
| 123 |
| 124 // static |
| 125 // True if the permissions were removed. |
| 126 Value* Remove::Result::Create(const bool removed) { |
| 127 return Value::CreateBooleanValue(removed); |
| 128 } |
| 129 |
| 130 } // permissions |
| 131 } // api |
| 132 } // extensions |
OLD | NEW |