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

Unified Diff: extensions/renderer/api_binding.cc

Issue 2609553003: [Extensions Bindings] Allow custom hooks to return values, throw (Closed)
Patch Set: rebase 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 | « no previous file | extensions/renderer/api_binding_hooks.h » ('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 7e59671985123ce69ff3e84358bf8b98e6ffc269..9856a8158e731a151d27875cb6721118f9eca6c9 100644
--- a/extensions/renderer/api_binding.cc
+++ b/extensions/renderer/api_binding.cc
@@ -200,12 +200,10 @@ void APIBinding::HandleCall(const std::string& name,
{
v8::TryCatch try_catch(isolate);
APIBindingHooks::RequestResult hooks_result =
- APIBindingHooks::RequestResult::NOT_HANDLED;
- hooks_result = binding_hooks_->HandleRequest(api_name_, name, context,
- signature, &argument_list,
- *type_refs_);
+ binding_hooks_->HandleRequest(api_name_, name, context,
+ signature, &argument_list, *type_refs_);
- switch (hooks_result) {
+ switch (hooks_result.code) {
case APIBindingHooks::RequestResult::INVALID_INVOCATION:
invalid_invocation = true;
// Throw a type error below so that it's not caught by our try-catch.
@@ -215,6 +213,8 @@ void APIBinding::HandleCall(const std::string& name,
try_catch.ReThrow();
return;
case APIBindingHooks::RequestResult::HANDLED:
+ if (!hooks_result.return_value.IsEmpty())
+ arguments->Return(hooks_result.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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698