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