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

Unified Diff: extensions/renderer/api_signature.cc

Issue 2915813003: [Extensions Bindings] Accept null callbacks while ignoring schema (Closed)
Patch Set: jbroman's Created 3 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 | « no previous file | extensions/renderer/api_signature_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_signature.cc
diff --git a/extensions/renderer/api_signature.cc b/extensions/renderer/api_signature.cc
index e15a53f80392707341e8d3c536a8b3a6658bf49f..b2eb02fc73d7c1699298d63c8eb6550dca7abad9 100644
--- a/extensions/renderer/api_signature.cc
+++ b/extensions/renderer/api_signature.cc
@@ -317,10 +317,13 @@ bool APISignature::ConvertArgumentsIgnoringSchema(
// the arguments in the signature. This is very broken.
if (HasCallback(signature_)) {
CHECK(!arguments.empty());
- if (arguments[size - 1]->IsFunction()) {
- callback = arguments[size - 1].As<v8::Function>();
- --size;
- }
+ v8::Local<v8::Value> value = arguments.back();
+ --size;
+ // Bindings should ensure that the value here is appropriate, but see the
+ // comment above for limitations.
+ DCHECK(value->IsFunction() || value->IsUndefined() || value->IsNull());
+ if (value->IsFunction())
+ callback = value.As<v8::Function>();
}
auto json = base::MakeUnique<base::ListValue>();
« no previous file with comments | « no previous file | extensions/renderer/api_signature_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698