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

Unified Diff: extensions/renderer/api_binding.cc

Issue 2609553003: [Extensions Bindings] Allow custom hooks to return values, throw (Closed)
Patch Set: woot Created 4 years 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_binding_hooks.h » ('j') | extensions/renderer/api_binding_hooks.h » ('J')
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 218565b17821ff57a41e2f1f326a45db8787312b..e10886f4f7107bdd87793c472ac2656ba03143a4 100644
--- a/extensions/renderer/api_binding.cc
+++ b/extensions/renderer/api_binding.cc
@@ -210,9 +210,10 @@ void APIBinding::HandleCall(const std::string& name,
v8::TryCatch try_catch(isolate);
APIBindingHooks::RequestResult hooks_result =
APIBindingHooks::RequestResult::NOT_HANDLED;
+ v8::Local<v8::Value> return_value;
hooks_result = binding_hooks_->HandleRequest(api_name_, name, context,
signature, &argument_list,
- *type_refs_);
+ *type_refs_, &return_value);
switch (hooks_result) {
case APIBindingHooks::RequestResult::INVALID_INVOCATION:
@@ -224,6 +225,8 @@ void APIBinding::HandleCall(const std::string& name,
try_catch.ReThrow();
return;
case APIBindingHooks::RequestResult::HANDLED:
+ if (!return_value.IsEmpty())
jbroman 2017/01/02 20:05:46 Do we expect this to ever be IsEmpty is a case tha
Devlin 2017/01/04 18:38:07 In the case of a native (c++) handler hook without
+ arguments->Return(return_value);
return; // Our work here is done.
case APIBindingHooks::RequestResult::NOT_HANDLED:
break; // Handle in the default manner.
« no previous file with comments | « no previous file | extensions/renderer/api_binding_hooks.h » ('j') | extensions/renderer/api_binding_hooks.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698