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

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: rework, updated base 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 using base::Value;
13 using base::DictionaryValue;
14 using base::ListValue;
15
16 namespace extensions {
17 namespace api {
18 namespace permissions {
19
20 //
21 // Types
22 //
23
24 Permissions::Permissions() {}
25 Permissions::~Permissions() {}
26
27 // static
28 bool Permissions::Populate(const Value& value, Permissions* out) {
29 if (!value.IsType(Value::TYPE_DICTIONARY))
30 return false;
31 const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
32
33 if (!json_schema_compiler::util::GetOptionalArrayFromDictionary(*dict, "origin s", &out->origins))
34 return false;
35 if (!json_schema_compiler::util::GetOptionalArrayFromDictionary(*dict, "permis sions", &out->permissions))
36 return false;
37 return true;
38 }
39
40 scoped_ptr<DictionaryValue> Permissions::ToValue() const {
41 scoped_ptr<DictionaryValue> value(new DictionaryValue());
42
43 if (origins.get())
44 json_schema_compiler::util::SetOptionalArrayToDictionary(origins, "origins", value.get());
45 if (permissions.get())
46 json_schema_compiler::util::SetOptionalArrayToDictionary(permissions, "permi ssions", value.get());
47
48 return value.Pass();
49 }
50
51
52 //
53 // Functions
54 //
55
56 Contains::Params::Params() {}
57 Contains::Params::~Params() {}
58
59 // static
60 scoped_ptr<Contains::Params> Contains::Params::Create(const ListValue& args) {
61 if (args.GetSize() != 1)
62 return scoped_ptr<Params>();
63 scoped_ptr<Params> params(new Params());
64
65 DictionaryValue* permissions_param = NULL;
66 if (!args.GetDictionary(0, &permissions_param))
67 return scoped_ptr<Params>();
68 if (!Permissions::Populate(*permissions_param, &params->permissions))
69 return scoped_ptr<Params>();
70
71 return params.Pass();
72 }
73
74 Value* Contains::Result::Create(const bool result) {
75 return Value::CreateBooleanValue(result);
76 }
77
78 Value* GetAll::Result::Create(const Permissions& permissions) {
79 return permissions.ToValue().release();
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, &params->permissions))
95 return scoped_ptr<Params>();
96
97 return params.Pass();
98 }
99
100 Value* Request::Result::Create(const bool granted) {
101 return Value::CreateBooleanValue(granted);
102 }
103
104 Remove::Params::Params() {}
105 Remove::Params::~Params() {}
106
107 // static
108 scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) {
109 if (args.GetSize() != 1)
110 return scoped_ptr<Params>();
111 scoped_ptr<Params> params(new Params());
112
113 DictionaryValue* permissions_param = NULL;
114 if (!args.GetDictionary(0, &permissions_param))
115 return scoped_ptr<Params>();
116 if (!Permissions::Populate(*permissions_param, &params->permissions))
117 return scoped_ptr<Params>();
118
119 return params.Pass();
120 }
121
122 Value* Remove::Result::Create(const bool removed) {
123 return Value::CreateBooleanValue(removed);
124 }
125
126 } // permissions
127 } // api
128 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698