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

Unified Diff: chrome/browser/extensions/api/input_ime/input_ime_event_router_base.cc

Issue 1570723002: Add class extensions::InputImeEventRouterBase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Devlin's comments. Created 4 years, 11 months 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: chrome/browser/extensions/api/input_ime/input_ime_event_router_base.cc
diff --git a/chrome/browser/extensions/api/input_ime/input_ime_event_router_base.cc b/chrome/browser/extensions/api/input_ime/input_ime_event_router_base.cc
new file mode 100644
index 0000000000000000000000000000000000000000..698e0a54c8ade22ce4809d6e14c6ebb2643958c5
--- /dev/null
+++ b/chrome/browser/extensions/api/input_ime/input_ime_event_router_base.cc
@@ -0,0 +1,40 @@
+// 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 "chrome/browser/extensions/api/input_ime/input_ime_event_router_base.h"
+
+#include "base/strings/string_number_conversions.h"
+
+namespace extensions {
+
+InputImeEventRouterBase::InputImeEventRouterBase(Profile* profile)
+ : next_request_id_(1), profile_(profile) {}
+
+InputImeEventRouterBase::~InputImeEventRouterBase() {}
+
+void InputImeEventRouterBase::OnKeyEventHandled(const std::string& extension_id,
+ const std::string& request_id,
+ bool handled) {
+ RequestMap::iterator request = request_map_.find(request_id);
+ if (request == request_map_.end()) {
+ LOG(ERROR) << "Request ID not found: " << request_id;
+ return;
+ }
+
+ request->second.second.Run(handled);
+ request_map_.erase(request);
+}
+
+std::string InputImeEventRouterBase::AddRequest(
+ const std::string& component_id,
+ ui::IMEEngineHandlerInterface::KeyEventDoneCallback& key_data) {
+ std::string request_id = base::IntToString(next_request_id_);
+ ++next_request_id_;
+
+ request_map_[request_id] = std::make_pair(component_id, key_data);
+
+ return request_id;
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/input_ime/input_ime_event_router_base.h ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698