| OLD | NEW |
| (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 |
| OLD | NEW |