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 (!json_schema_compiler::util::GetOptionalStrings(*dict, "origins", &out->or
igins)) |
| 29 return false; |
| 30 if (!json_schema_compiler::util::GetOptionalStrings(*dict, "permissions", &out
->permissions)) |
| 31 return false; |
| 32 return true; |
| 33 } |
| 34 |
| 35 DictionaryValue* Permissions::ToValue() const { |
| 36 DictionaryValue* value = new DictionaryValue(); |
| 37 |
| 38 json_schema_compiler::util::SetOptionalStrings(origins, "origins", value); |
| 39 json_schema_compiler::util::SetOptionalStrings(permissions, "permissions", val
ue); |
| 40 |
| 41 return value; |
| 42 } |
| 43 |
| 44 |
| 45 // |
| 46 // Functions |
| 47 // |
| 48 |
| 49 Contains::Params::Params() {} |
| 50 Contains::Params::~Params() {} |
| 51 |
| 52 // static |
| 53 bool Contains::Params::Populate(const ListValue& args, |
| 54 Contains::Params* out) { |
| 55 if (args.GetSize() != 1) |
| 56 return false; |
| 57 |
| 58 DictionaryValue* permissions_param = NULL; |
| 59 if (!args.GetDictionary(0, &permissions_param)) |
| 60 return false; |
| 61 if (!Permissions::Populate(*permissions_param, &out->permissions)) |
| 62 return false; |
| 63 |
| 64 return true; |
| 65 } |
| 66 |
| 67 // static |
| 68 Value* Contains::Result::Create(const bool result) { |
| 69 return Value::CreateBooleanValue(result); |
| 70 } |
| 71 |
| 72 // static |
| 73 Value* GetAll::Result::Create(const Permissions& permissions) { |
| 74 DictionaryValue* result = new DictionaryValue(); |
| 75 result->SetWithoutPathExpansion("permissions",permissions.ToValue()); |
| 76 return result; |
| 77 } |
| 78 |
| 79 Request::Params::Params() {} |
| 80 Request::Params::~Params() {} |
| 81 |
| 82 // static |
| 83 bool Request::Params::Populate(const ListValue& args, |
| 84 Request::Params* out) { |
| 85 if (args.GetSize() != 1) |
| 86 return false; |
| 87 |
| 88 DictionaryValue* permissions_param = NULL; |
| 89 if (!args.GetDictionary(0, &permissions_param)) |
| 90 return false; |
| 91 if (!Permissions::Populate(*permissions_param, &out->permissions)) |
| 92 return false; |
| 93 |
| 94 return true; |
| 95 } |
| 96 |
| 97 // static |
| 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 bool Remove::Params::Populate(const ListValue& args, |
| 107 Remove::Params* out) { |
| 108 if (args.GetSize() != 1) |
| 109 return false; |
| 110 |
| 111 DictionaryValue* permissions_param = NULL; |
| 112 if (!args.GetDictionary(0, &permissions_param)) |
| 113 return false; |
| 114 if (!Permissions::Populate(*permissions_param, &out->permissions)) |
| 115 return false; |
| 116 |
| 117 return true; |
| 118 } |
| 119 |
| 120 // static |
| 121 Value* Remove::Result::Create(const bool removed) { |
| 122 return Value::CreateBooleanValue(removed); |
| 123 } |
| 124 |
| 125 } // namespace extensions |
| 126 } // namespace permissions_api |
OLD | NEW |