Index: extensions/renderer/api_binding_hooks.cc |
diff --git a/extensions/renderer/api_binding_hooks.cc b/extensions/renderer/api_binding_hooks.cc |
index d5d608fff41808551141f4464191f31e65e454e6..2da9784de835b9834c28c091b970e3a2e99f8952 100644 |
--- a/extensions/renderer/api_binding_hooks.cc |
+++ b/extensions/renderer/api_binding_hooks.cc |
@@ -207,12 +207,6 @@ APIBindingHooks::APIBindingHooks(const std::string& api_name, |
: api_name_(api_name), run_js_(run_js) {} |
APIBindingHooks::~APIBindingHooks() {} |
-void APIBindingHooks::RegisterHandleRequest(const std::string& method_name, |
- const HandleRequestHook& hook) { |
- DCHECK(!hooks_used_) << "Hooks must be registered before the first use!"; |
- request_hooks_[method_name] = hook; |
-} |
- |
APIBindingHooks::RequestResult APIBindingHooks::RunHooks( |
const std::string& method_name, |
v8::Local<v8::Context> context, |
@@ -220,15 +214,11 @@ APIBindingHooks::RequestResult APIBindingHooks::RunHooks( |
std::vector<v8::Local<v8::Value>>* arguments, |
const APITypeReferenceMap& type_refs) { |
// Easy case: a native custom hook. |
- auto request_hooks_iter = request_hooks_.find(method_name); |
- if (request_hooks_iter != request_hooks_.end()) { |
- RequestResult result = |
- request_hooks_iter->second.Run( |
- signature, context, arguments, type_refs); |
- // Right now, it doesn't make sense to register a request handler that |
- // doesn't handle the request. |
- DCHECK_NE(RequestResult::NOT_HANDLED, result.code); |
- return result; |
+ if (delegate_) { |
+ RequestResult result = delegate_->HandleRequest( |
+ method_name, signature, context, arguments, type_refs); |
+ if (result.code != RequestResult::NOT_HANDLED) |
+ return result; |
} |
// Harder case: looking up a custom hook registered on the context (since |