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

Unified Diff: extensions/renderer/argument_spec.cc

Issue 2805123002: [Extensions Bindings] Allow schema violations through sendRequest (Closed)
Patch Set: Created 3 years, 8 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
Index: extensions/renderer/argument_spec.cc
diff --git a/extensions/renderer/argument_spec.cc b/extensions/renderer/argument_spec.cc
index bae1a7b5bfa44058380d4e5260bc50ef6dfba796..3001fe1ee6909443ad6c68cc1ff5c8298d60a5dc 100644
--- a/extensions/renderer/argument_spec.cc
+++ b/extensions/renderer/argument_spec.cc
@@ -144,9 +144,18 @@ bool ArgumentSpec::ParseArgument(v8::Local<v8::Context> context,
std::unique_ptr<base::Value>* out_value,
std::string* error) const {
if (type_ == ArgumentType::FUNCTION) {
- // We can't serialize functions. We shouldn't be asked to.
- DCHECK(!out_value);
- return value->IsFunction();
+ if (!value->IsFunction())
+ return false;
+
+ if (out_value) {
+ // Certain APIs (contextMenus) have functions as parameters other than the
+ // callback (contextMenus uses it for an onclick listener). Our generated
+ // types have adapted to consider functions "objects" and serialize them
+ // as dictionaries.
+ // TODO(devlin): It'd be awfully nice to get rid of this eccentricity.
+ *out_value = base::MakeUnique<base::DictionaryValue>();
+ }
+ return true;
}
if (type_ == ArgumentType::REF) {

Powered by Google App Engine
This is Rietveld 408576698