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

Unified Diff: chrome/browser/ui/input_method/input_method_engine.cc

Issue 1771173002: Implement input.ime.sendKeyEvents API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update test. Created 4 years, 9 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/ui/input_method/input_method_engine.cc
diff --git a/chrome/browser/ui/input_method/input_method_engine.cc b/chrome/browser/ui/input_method/input_method_engine.cc
index 6966f31cdf92b806b9031984b0d706bcf2fdd40c..9636dbd2e7ae5de513600124d1d4d62324824026 100644
--- a/chrome/browser/ui/input_method/input_method_engine.cc
+++ b/chrome/browser/ui/input_method/input_method_engine.cc
@@ -4,9 +4,16 @@
#include "chrome/browser/ui/input_method/input_method_engine.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_tree_host.h"
#include "ui/base/ime/composition_text.h"
#include "ui/base/ime/ime_bridge.h"
#include "ui/base/ime/ime_input_context_handler_interface.h"
+#include "ui/base/ime/input_method.h"
+#include "ui/events/keycodes/keyboard_code_conversion.h"
namespace {
@@ -29,13 +36,6 @@ InputMethodEngine::~InputMethodEngine() {
CloseImeWindows();
}
-bool InputMethodEngine::SendKeyEvents(
- int context_id,
- const std::vector<KeyboardEvent>& events) {
- // TODO(azurewei) Implement SendKeyEvents funciton
- return false;
-}
-
bool InputMethodEngine::IsActive() const {
return true;
}
@@ -163,4 +163,18 @@ void InputMethodEngine::OnWindowDestroyed(ui::ImeWindow* ime_window) {
}
}
+bool InputMethodEngine::SendKeyEvent(ui::KeyEvent* event) {
+ Browser* browser = chrome::FindLastActiveWithProfile(profile_);
+ if (!browser)
+ return false;
+
+ if (event->key_code() == ui::VKEY_UNKNOWN)
+ event->set_key_code(ui::DomCodeToUsLayoutKeyboardCode(event->code()));
+
+ ui::InputMethod* input_method =
+ browser->window()->GetNativeWindow()->GetHost()->GetInputMethod();
+ input_method->DispatchKeyEvent(event);
+ return true;
+}
+
} // namespace input_method

Powered by Google App Engine
This is Rietveld 408576698