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

Side by Side Diff: chrome/browser/extensions/api/myapi/myapi.cc

Issue 17679004: testing adding an extension api Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 5 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) 2013 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\myapi.idl
7 // DO NOT EDIT.
8
9 #include "tools/json_schema_compiler/util.h"
10 #include "base/logging.h"
11 #include "base/strings/string_number_conversions.h"
12 #include "chrome\common\extensions\api/myapi.h"
13
14 namespace extensions {
15 namespace api {
16 namespace myapi {
17
18 //
19 // Types
20 //
21
22 BazOptions::BazOptions()
23 : id(0) {}
24
25 BazOptions::~BazOptions() {}
26
27 // static
28 bool BazOptions::Populate(
29 const base::Value& value, BazOptions* out) {
30 if (!value.IsType(base::Value::TYPE_DICTIONARY))
31 return false;
32 const base::DictionaryValue* dict = static_cast<const base::DictionaryValue*>( &value);
33 const base::Value* id_value = NULL;
34 if (!dict->GetWithoutPathExpansion("id", &id_value))
35 return false;
36 {
37 if (!id_value->GetAsInteger(&out->id))
38 return false;
39 }
40
41 const base::Value* s_value = NULL;
42 if (!dict->GetWithoutPathExpansion("s", &s_value))
43 return false;
44 {
45 if (!s_value->GetAsString(&out->s))
46 return false;
47 }
48
49 return true;
50 }
51
52 // static
53 scoped_ptr<BazOptions> BazOptions::FromValue(const base::Value& value) {
54 scoped_ptr<BazOptions> out(new BazOptions());
55 if (!Populate(value, out.get()))
56 return scoped_ptr<BazOptions>();
57 return out.Pass();
58 }
59
60 scoped_ptr<base::DictionaryValue> BazOptions::ToValue() const {
61 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
62
63 value->SetWithoutPathExpansion("id", new base::FundamentalValue(this->id));
64 value->SetWithoutPathExpansion("s", new base::StringValue(this->s));
65
66 return value.Pass();
67 }
68
69
70 BazResult::BazResult()
71 : x(0), y(0) {}
72
73 BazResult::~BazResult() {}
74
75 // static
76 bool BazResult::Populate(
77 const base::Value& value, BazResult* out) {
78 if (!value.IsType(base::Value::TYPE_DICTIONARY))
79 return false;
80 const base::DictionaryValue* dict = static_cast<const base::DictionaryValue*>( &value);
81 const base::Value* x_value = NULL;
82 if (!dict->GetWithoutPathExpansion("x", &x_value))
83 return false;
84 {
85 if (!x_value->GetAsInteger(&out->x))
86 return false;
87 }
88
89 const base::Value* y_value = NULL;
90 if (!dict->GetWithoutPathExpansion("y", &y_value))
91 return false;
92 {
93 if (!y_value->GetAsInteger(&out->y))
94 return false;
95 }
96
97 return true;
98 }
99
100 // static
101 scoped_ptr<BazResult> BazResult::FromValue(const base::Value& value) {
102 scoped_ptr<BazResult> out(new BazResult());
103 if (!Populate(value, out.get()))
104 return scoped_ptr<BazResult>();
105 return out.Pass();
106 }
107
108 scoped_ptr<base::DictionaryValue> BazResult::ToValue() const {
109 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
110
111 value->SetWithoutPathExpansion("x", new base::FundamentalValue(this->x));
112 value->SetWithoutPathExpansion("y", new base::FundamentalValue(this->y));
113
114 return value.Pass();
115 }
116
117
118
119 //
120 // Functions
121 //
122
123 namespace DoBaz {
124
125 Params::Params() {}
126 Params::~Params() {}
127
128 // static
129 scoped_ptr<Params> Params::Create(const base::ListValue& args) {
130 if (args.GetSize() != 1)
131 return scoped_ptr<Params>();
132 scoped_ptr<Params> params(new Params());
133
134 const base::Value* options_value = NULL;
135 if (args.Get(0, &options_value) &&
136 !options_value->IsType(base::Value::TYPE_NULL)) {
137 {
138 const base::DictionaryValue* dictionary = NULL;
139 if (!options_value->GetAsDictionary(&dictionary))
140 return scoped_ptr<Params>();
141 if (!BazOptions::Populate(*dictionary, &params->options))
142 return scoped_ptr<Params>();
143 }
144 }
145 else {
146 return scoped_ptr<Params>();
147 }
148
149 return params.Pass();
150 }
151
152
153 scoped_ptr<base::ListValue> Results::Create(const BazResult& result) {
154 scoped_ptr<base::ListValue> create_results(new base::ListValue());
155 create_results->Append((result).ToValue().release());
156 return create_results.Pass();
157 }
158 } // namespace DoBaz
159
160 } // myapi
161 } // namespace api
162 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/myapi/myapi.h ('k') | chrome/browser/extensions/api/myapi/myapi_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698