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

Unified Diff: extensions/renderer/api_binding_hooks.cc

Issue 2831453002: [Extensions Bindings] Move custom handling to APIBindingHooksDelegate (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
« no previous file with comments | « extensions/renderer/api_binding_hooks.h ('k') | extensions/renderer/api_binding_hooks_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « extensions/renderer/api_binding_hooks.h ('k') | extensions/renderer/api_binding_hooks_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698