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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/myapi/myapi.cc
diff --git a/chrome/browser/extensions/api/myapi/myapi.cc b/chrome/browser/extensions/api/myapi/myapi.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e3f606b715d9cf3d7497a15aefb5983f0589fde6
--- /dev/null
+++ b/chrome/browser/extensions/api/myapi/myapi.cc
@@ -0,0 +1,162 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// GENERATED FROM THE API DEFINITION IN
+// chrome\common\extensions\api\myapi.idl
+// DO NOT EDIT.
+
+#include "tools/json_schema_compiler/util.h"
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+#include "chrome\common\extensions\api/myapi.h"
+
+namespace extensions {
+namespace api {
+namespace myapi {
+
+//
+// Types
+//
+
+BazOptions::BazOptions()
+: id(0) {}
+
+BazOptions::~BazOptions() {}
+
+// static
+bool BazOptions::Populate(
+ const base::Value& value, BazOptions* out) {
+ if (!value.IsType(base::Value::TYPE_DICTIONARY))
+ return false;
+ const base::DictionaryValue* dict = static_cast<const base::DictionaryValue*>(&value);
+ const base::Value* id_value = NULL;
+ if (!dict->GetWithoutPathExpansion("id", &id_value))
+ return false;
+ {
+ if (!id_value->GetAsInteger(&out->id))
+ return false;
+ }
+
+ const base::Value* s_value = NULL;
+ if (!dict->GetWithoutPathExpansion("s", &s_value))
+ return false;
+ {
+ if (!s_value->GetAsString(&out->s))
+ return false;
+ }
+
+ return true;
+}
+
+// static
+scoped_ptr<BazOptions> BazOptions::FromValue(const base::Value& value) {
+ scoped_ptr<BazOptions> out(new BazOptions());
+ if (!Populate(value, out.get()))
+ return scoped_ptr<BazOptions>();
+ return out.Pass();
+}
+
+scoped_ptr<base::DictionaryValue> BazOptions::ToValue() const {
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+
+ value->SetWithoutPathExpansion("id", new base::FundamentalValue(this->id));
+ value->SetWithoutPathExpansion("s", new base::StringValue(this->s));
+
+ return value.Pass();
+}
+
+
+BazResult::BazResult()
+: x(0), y(0) {}
+
+BazResult::~BazResult() {}
+
+// static
+bool BazResult::Populate(
+ const base::Value& value, BazResult* out) {
+ if (!value.IsType(base::Value::TYPE_DICTIONARY))
+ return false;
+ const base::DictionaryValue* dict = static_cast<const base::DictionaryValue*>(&value);
+ const base::Value* x_value = NULL;
+ if (!dict->GetWithoutPathExpansion("x", &x_value))
+ return false;
+ {
+ if (!x_value->GetAsInteger(&out->x))
+ return false;
+ }
+
+ const base::Value* y_value = NULL;
+ if (!dict->GetWithoutPathExpansion("y", &y_value))
+ return false;
+ {
+ if (!y_value->GetAsInteger(&out->y))
+ return false;
+ }
+
+ return true;
+}
+
+// static
+scoped_ptr<BazResult> BazResult::FromValue(const base::Value& value) {
+ scoped_ptr<BazResult> out(new BazResult());
+ if (!Populate(value, out.get()))
+ return scoped_ptr<BazResult>();
+ return out.Pass();
+}
+
+scoped_ptr<base::DictionaryValue> BazResult::ToValue() const {
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+
+ value->SetWithoutPathExpansion("x", new base::FundamentalValue(this->x));
+ value->SetWithoutPathExpansion("y", new base::FundamentalValue(this->y));
+
+ return value.Pass();
+}
+
+
+
+//
+// Functions
+//
+
+namespace DoBaz {
+
+Params::Params() {}
+Params::~Params() {}
+
+// static
+scoped_ptr<Params> Params::Create(const base::ListValue& args) {
+ if (args.GetSize() != 1)
+ return scoped_ptr<Params>();
+ scoped_ptr<Params> params(new Params());
+
+ const base::Value* options_value = NULL;
+ if (args.Get(0, &options_value) &&
+ !options_value->IsType(base::Value::TYPE_NULL)) {
+ {
+ const base::DictionaryValue* dictionary = NULL;
+ if (!options_value->GetAsDictionary(&dictionary))
+ return scoped_ptr<Params>();
+ if (!BazOptions::Populate(*dictionary, &params->options))
+ return scoped_ptr<Params>();
+ }
+ }
+ else {
+ return scoped_ptr<Params>();
+ }
+
+ return params.Pass();
+}
+
+
+scoped_ptr<base::ListValue> Results::Create(const BazResult& result) {
+ scoped_ptr<base::ListValue> create_results(new base::ListValue());
+ create_results->Append((result).ToValue().release());
+ return create_results.Pass();
+}
+} // namespace DoBaz
+
+} // myapi
+} // namespace api
+} // namespace extensions
« 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