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

Unified Diff: extensions/renderer/api_binding.cc

Issue 2610743002: [Extensions Bindings] Make function definitions optional for an API. (Closed)
Patch Set: comment fix, unit test for empty API Created 3 years, 11 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 | « extensions/renderer/api_binding.h ('k') | extensions/renderer/api_binding_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_binding.cc
diff --git a/extensions/renderer/api_binding.cc b/extensions/renderer/api_binding.cc
index 163858dbc6503b311b05aaf14e20f6b44b196a14..bf559f995355231fd20557ecbba4e48a311eae88 100644
--- a/extensions/renderer/api_binding.cc
+++ b/extensions/renderer/api_binding.cc
@@ -64,7 +64,7 @@ void CallbackHelper(const v8::FunctionCallbackInfo<v8::Value>& info) {
} // namespace
APIBinding::APIBinding(const std::string& api_name,
- const base::ListValue& function_definitions,
+ const base::ListValue* function_definitions,
const base::ListValue* type_definitions,
const base::ListValue* event_definitions,
const APIMethodCallback& callback,
@@ -76,15 +76,17 @@ APIBinding::APIBinding(const std::string& api_name,
type_refs_(type_refs),
weak_factory_(this) {
DCHECK(!method_callback_.is_null());
- for (const auto& func : function_definitions) {
- const base::DictionaryValue* func_dict = nullptr;
- CHECK(func->GetAsDictionary(&func_dict));
- std::string name;
- CHECK(func_dict->GetString("name", &name));
-
- const base::ListValue* params = nullptr;
- CHECK(func_dict->GetList("parameters", &params));
- signatures_[name] = base::MakeUnique<APISignature>(*params);
+ if (function_definitions) {
+ for (const auto& func : *function_definitions) {
+ const base::DictionaryValue* func_dict = nullptr;
+ CHECK(func->GetAsDictionary(&func_dict));
+ std::string name;
+ CHECK(func_dict->GetString("name", &name));
+
+ const base::ListValue* params = nullptr;
+ CHECK(func_dict->GetList("parameters", &params));
+ signatures_[name] = base::MakeUnique<APISignature>(*params);
+ }
}
if (type_definitions) {
for (const auto& type : *type_definitions) {
« no previous file with comments | « extensions/renderer/api_binding.h ('k') | extensions/renderer/api_binding_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698