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

Unified 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, add a couple of tests 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « generated_files_will_not_submit/permissions.h ('k') | generated_files_will_not_submit/simple_api.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: generated_files_will_not_submit/permissions.cc
diff --git a/generated_files_will_not_submit/permissions.cc b/generated_files_will_not_submit/permissions.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dba311f2726e59347836834f1ac2c67c311681cc
--- /dev/null
+++ b/generated_files_will_not_submit/permissions.cc
@@ -0,0 +1,174 @@
+// Copyright (c) 2012 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/permissions.json
+// DO NOT EDIT.
+
+#include "tools/json_schema_compiler/util.h"
+#include "chrome/common/extensions/api/permissions.h"
+
+using base::Value;
+using base::DictionaryValue;
+using base::ListValue;
+
+namespace extensions {
+namespace api {
+namespace permissions {
+
+//
+// Types
+//
+
+Permissions::Permissions() {}
+Permissions::~Permissions() {}
+
+// static
+bool Permissions::Populate(const Value& value, Permissions* out) {
+ if (!value.IsType(Value::TYPE_DICTIONARY))
+ return false;
+ const DictionaryValue* dict = static_cast<const DictionaryValue*>(&value);
+
+ Value* origins_value = NULL;
+ if (dict->GetWithoutPathExpansion("origins", &origins_value)) {
+ {
+ if (!origins_value->IsType(Value::TYPE_LIST))
+ return false;
+ ListValue* list = NULL;
+ if (!origins_value->GetAsList(&list))
+ return false;
+ if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &out->origins))
+ return false;
+ }
+ }
+
+ Value* permissions_value = NULL;
+ if (dict->GetWithoutPathExpansion("permissions", &permissions_value)) {
+ {
+ if (!permissions_value->IsType(Value::TYPE_LIST))
+ return false;
+ ListValue* list = NULL;
+ if (!permissions_value->GetAsList(&list))
+ return false;
+ if (!json_schema_compiler::util::PopulateOptionalArrayFromList(*list, &out->permissions))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+scoped_ptr<DictionaryValue> Permissions::ToValue() const {
+ scoped_ptr<DictionaryValue> value(new DictionaryValue());
+
+ if (origins.get())
+ json_schema_compiler::util::PopulateDictionaryFromOptionalArray(origins, "origins", value.get());
+ if (permissions.get())
+ json_schema_compiler::util::PopulateDictionaryFromOptionalArray(permissions, "permissions", value.get());
+
+ return value.Pass();
+}
+
+
+//
+// Functions
+//
+
+Contains::Params::Params() {}
+Contains::Params::~Params() {}
+
+// static
+scoped_ptr<Contains::Params> Contains::Params::Create(const ListValue& args) {
+ if (args.GetSize() != 1)
+ return scoped_ptr<Params>();
+ scoped_ptr<Params> params(new Params());
+
+ Value* permissions_value = NULL;
+ if (!args.Get(0, &permissions_value) || permissions_value->IsType(Value::TYPE_NULL))
+ return scoped_ptr<Params>();
+ {
+ if (!permissions_value->IsType(Value::TYPE_DICTIONARY))
+ return scoped_ptr<Params>();
+ DictionaryValue* dictionary = NULL;
+ if (!permissions_value->GetAsDictionary(&dictionary))
+ return scoped_ptr<Params>();
+ if (!Permissions::Populate(*dictionary, &params->permissions))
+ return scoped_ptr<Params>();
+ }
+
+ return params.Pass();
+}
+
+
+Value* Contains::Result::Create(const bool result) {
+ return Value::CreateBooleanValue(result);
+}
+
+Value* GetAll::Result::Create(const Permissions& permissions) {
+ return permissions.ToValue().release();
+}
+
+Request::Params::Params() {}
+Request::Params::~Params() {}
+
+// static
+scoped_ptr<Request::Params> Request::Params::Create(const ListValue& args) {
+ if (args.GetSize() != 1)
+ return scoped_ptr<Params>();
+ scoped_ptr<Params> params(new Params());
+
+ Value* permissions_value = NULL;
+ if (!args.Get(0, &permissions_value) || permissions_value->IsType(Value::TYPE_NULL))
+ return scoped_ptr<Params>();
+ {
+ if (!permissions_value->IsType(Value::TYPE_DICTIONARY))
+ return scoped_ptr<Params>();
+ DictionaryValue* dictionary = NULL;
+ if (!permissions_value->GetAsDictionary(&dictionary))
+ return scoped_ptr<Params>();
+ if (!Permissions::Populate(*dictionary, &params->permissions))
+ return scoped_ptr<Params>();
+ }
+
+ return params.Pass();
+}
+
+
+Value* Request::Result::Create(const bool granted) {
+ return Value::CreateBooleanValue(granted);
+}
+
+Remove::Params::Params() {}
+Remove::Params::~Params() {}
+
+// static
+scoped_ptr<Remove::Params> Remove::Params::Create(const ListValue& args) {
+ if (args.GetSize() != 1)
+ return scoped_ptr<Params>();
+ scoped_ptr<Params> params(new Params());
+
+ Value* permissions_value = NULL;
+ if (!args.Get(0, &permissions_value) || permissions_value->IsType(Value::TYPE_NULL))
+ return scoped_ptr<Params>();
+ {
+ if (!permissions_value->IsType(Value::TYPE_DICTIONARY))
+ return scoped_ptr<Params>();
+ DictionaryValue* dictionary = NULL;
+ if (!permissions_value->GetAsDictionary(&dictionary))
+ return scoped_ptr<Params>();
+ if (!Permissions::Populate(*dictionary, &params->permissions))
+ return scoped_ptr<Params>();
+ }
+
+ return params.Pass();
+}
+
+
+Value* Remove::Result::Create(const bool removed) {
+ return Value::CreateBooleanValue(removed);
+}
+
+} // permissions
+} // api
+} // extensions
« no previous file with comments | « generated_files_will_not_submit/permissions.h ('k') | generated_files_will_not_submit/simple_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698