| 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 "chrome/browser/extensions/api/input_ime/input_ime_event_router_base.h" |
| 6 |
| 7 #include "base/strings/string_number_conversions.h" |
| 8 |
| 9 namespace extensions { |
| 10 |
| 11 InputImeEventRouterBase::InputImeEventRouterBase(Profile* profile) |
| 12 : next_request_id_(1), profile_(profile) {} |
| 13 |
| 14 InputImeEventRouterBase::~InputImeEventRouterBase() {} |
| 15 |
| 16 void InputImeEventRouterBase::OnKeyEventHandled(const std::string& extension_id, |
| 17 const std::string& request_id, |
| 18 bool handled) { |
| 19 RequestMap::iterator request = request_map_.find(request_id); |
| 20 if (request == request_map_.end()) { |
| 21 LOG(ERROR) << "Request ID not found: " << request_id; |
| 22 return; |
| 23 } |
| 24 |
| 25 request->second.second.Run(handled); |
| 26 request_map_.erase(request); |
| 27 } |
| 28 |
| 29 std::string InputImeEventRouterBase::AddRequest( |
| 30 const std::string& component_id, |
| 31 ui::IMEEngineHandlerInterface::KeyEventDoneCallback& key_data) { |
| 32 std::string request_id = base::IntToString(next_request_id_); |
| 33 ++next_request_id_; |
| 34 |
| 35 request_map_[request_id] = std::make_pair(component_id, key_data); |
| 36 |
| 37 return request_id; |
| 38 } |
| 39 |
| 40 } // namespace extensions |
| OLD | NEW |