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

Unified Diff: extensions/renderer/api_binding_hooks.cc

Issue 2552343006: [Extensions Binding] Allow for registering custom hooks (Closed)
Patch Set: jbroman 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
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..69ade18a96fa5f9650b78f8068c12d6282a86990
--- /dev/null
+++ b/extensions/renderer/api_binding_hooks.cc
@@ -0,0 +1,26 @@
+// 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) {
+ request_hooks_[method_name] = hook;
+}
+
+APIBindingHooks::HandleRequestHook APIBindingHooks::GetHandleRequest(
+ const std::string& method_name) {
+ auto iter = request_hooks_.find(method_name);
+ if (iter != request_hooks_.end())
+ return iter->second;
+
+ return HandleRequestHook();
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698