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 out->origins.reset(new std::vector<std::string>); |
| 30 json_schema_compiler::util::GetOptionalArrayFromDictionary(*dict, "origins", &
out->origins); |
| 31 out->permissions.reset(new std::vector<std::string>); |
| 32 json_schema_compiler::util::GetOptionalArrayFromDictionary(*dict, "permissions
", &out->permissions); |
| 33 return true; |
| 34 } |
| 35 |
| 36 DictionaryValue* Permissions::ToValue() const { |
| 37 DictionaryValue* value = new DictionaryValue(); |
| 38 |
| 39 json_schema_compiler::util::SetOptionalArrayFromDictionary(origins, "origins",
value); |
| 40 json_schema_compiler::util::SetOptionalArrayFromDictionary(permissions, "permi
ssions", value); |
| 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 |
| 56 scoped_ptr<Params> params(new Params()); |
| 57 |
| 58 DictionaryValue* permissions_param = NULL; |
| 59 if (!args.GetDictionary(0, &permissions_param)) |
| 60 return scoped_ptr<Params>(); |
| 61 if(!Permissions::Populate(*permissions_param, ¶ms->permissions)) |
| 62 return scoped_ptr<Params>(); |
| 63 |
| 64 return params.Pass(); |
| 65 } |
| 66 |
| 67 // static |
| 68 // True if the extension has the specified permissions. |
| 69 Value* Contains::Result::Create(const bool result) { |
| 70 return Value::CreateBooleanValue(result); |
| 71 } |
| 72 |
| 73 // static |
| 74 // The extension's active permissions. |
| 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 |
| 85 scoped_ptr<Params> params(new Params()); |
| 86 |
| 87 DictionaryValue* permissions_param = NULL; |
| 88 if (!args.GetDictionary(0, &permissions_param)) |
| 89 return scoped_ptr<Params>(); |
| 90 if(!Permissions::Populate(*permissions_param, ¶ms->permissions)) |
| 91 return scoped_ptr<Params>(); |
| 92 |
| 93 return params.Pass(); |
| 94 } |
| 95 |
| 96 // static |
| 97 // True if the user granted the specified permissions. |
| 98 Value* Request::Result::Create(const bool granted) { |
| 99 return Value::CreateBooleanValue(granted); |
| 100 } |
| 101 |
| 102 Remove::Params::Params() {} |
| 103 Remove::Params::~Params() {} |
| 104 |
| 105 // static |
| 106 scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) { |
| 107 |
| 108 scoped_ptr<Params> params(new Params()); |
| 109 |
| 110 DictionaryValue* permissions_param = NULL; |
| 111 if (!args.GetDictionary(0, &permissions_param)) |
| 112 return scoped_ptr<Params>(); |
| 113 if(!Permissions::Populate(*permissions_param, ¶ms->permissions)) |
| 114 return scoped_ptr<Params>(); |
| 115 |
| 116 return params.Pass(); |
| 117 } |
| 118 |
| 119 // static |
| 120 // True if the permissions were removed. |
| 121 Value* Remove::Result::Create(const bool removed) { |
| 122 return Value::CreateBooleanValue(removed); |
| 123 } |
| 124 |
| 125 } // permissions |
| 126 } // api |
| 127 } // extensions |
OLD | NEW |