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

Unified Diff: extensions/renderer/api_binding_hooks.cc

Issue 2552343006: [Extensions Binding] Allow for registering custom hooks (Closed)
Patch Set: . 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 | « extensions/renderer/api_binding_hooks.h ('k') | extensions/renderer/api_binding_types.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
new file mode 100644
index 0000000000000000000000000000000000000000..98d0c72badadd4064ada05211d2f790c23594cfb
--- /dev/null
+++ b/extensions/renderer/api_binding_hooks.cc
@@ -0,0 +1,28 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "extensions/renderer/api_binding_hooks.h"
+
+namespace extensions {
+
+APIBindingHooks::APIBindingHooks() {}
+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::HandleRequestHook APIBindingHooks::GetHandleRequest(
+ const std::string& method_name) {
+ hooks_used_ = true;
+ auto iter = request_hooks_.find(method_name);
+ if (iter != request_hooks_.end())
+ return iter->second;
+
+ return HandleRequestHook();
+}
+
+} // namespace extensions
« no previous file with comments | « extensions/renderer/api_binding_hooks.h ('k') | extensions/renderer/api_binding_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698