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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "extensions/renderer/api_binding_hooks.h"
6
7 namespace extensions {
8
9 APIBindingHooks::APIBindingHooks() {}
10 APIBindingHooks::~APIBindingHooks() {}
11
12 void APIBindingHooks::RegisterHandleRequest(const std::string& method_name,
13 const HandleRequestHook& hook) {
14 DCHECK(!hooks_used_) << "Hooks must be registered before the first use!";
15 request_hooks_[method_name] = hook;
16 }
17
18 APIBindingHooks::HandleRequestHook APIBindingHooks::GetHandleRequest(
19 const std::string& method_name) {
20 hooks_used_ = true;
21 auto iter = request_hooks_.find(method_name);
22 if (iter != request_hooks_.end())
23 return iter->second;
24
25 return HandleRequestHook();
26 }
27
28 } // namespace extensions
OLDNEW
« 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