Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: generated_files_will_not_submit/permissions.cc

Issue 9309044: Supporting more APIs with json_schema_compiler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: a few comments, fixes Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 std::vector<std::string> origins_temp;
30 if(json_schema_compiler::util::GetOptionalArrayFromDictionary(*dict, "origins" , &out->origins))
31 out->origins.reset(new std::vector<std::string>(origins_temp));
32 std::vector<std::string> permissions_temp;
33 if(json_schema_compiler::util::GetOptionalArrayFromDictionary(*dict, "permissi ons", &out->permissions))
34 out->permissions.reset(new std::vector<std::string>(permissions_temp));
35 return true;
36 }
37
38 DictionaryValue* Permissions::ToValue() const {
39 DictionaryValue* value = new DictionaryValue();
40
41 if(origins.get())
42 json_schema_compiler::util::SetOptionalArrayToDictionary(origins, "origins", value);
43 if(permissions.get())
44 json_schema_compiler::util::SetOptionalArrayToDictionary(permissions, "permi ssions", value);
45
46 return value;
47 }
48
49
50 //
51 // Functions
52 //
53
54 Contains::Params::Params() {}
55 Contains::Params::~Params() {}
56
57 // static
58 scoped_ptr<Contains::Params> Contains::Params::Create(const ListValue& args) {
59
60 scoped_ptr<Params> params(new Params());
61
62 DictionaryValue* permissions_param = NULL;
63 if (!args.GetDictionary(0, &permissions_param))
64 return scoped_ptr<Params>();
65 if(!Permissions::Populate(*permissions_param, &params->permissions))
66 return scoped_ptr<Params>();
67
68 return params.Pass();
69 }
70
71 // static
72 // True if the extension has the specified permissions.
73 Value* Contains::Result::Create(const bool result) {
74 return Value::CreateBooleanValue(result);
75 }
76
77 // static
78 // The extension's active permissions.
79 Value* GetAll::Result::Create(const Permissions& permissions) {
80 return permissions.ToValue();
81 }
82
83 Request::Params::Params() {}
84 Request::Params::~Params() {}
85
86 // static
87 scoped_ptr<Request::Params> Request::Params::Create(const ListValue& args) {
88
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, &params->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
112 scoped_ptr<Params> params(new Params());
113
114 DictionaryValue* permissions_param = NULL;
115 if (!args.GetDictionary(0, &permissions_param))
116 return scoped_ptr<Params>();
117 if(!Permissions::Populate(*permissions_param, &params->permissions))
118 return scoped_ptr<Params>();
119
120 return params.Pass();
121 }
122
123 // static
124 // True if the permissions were removed.
125 Value* Remove::Result::Create(const bool removed) {
126 return Value::CreateBooleanValue(removed);
127 }
128
129 } // permissions
130 } // api
131 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698