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

Unified Diff: remoting/client/input/text_keyboard_input_strategy.cc

Issue 2868383003: [CRD iOS] Send key events to the session. (Closed)
Patch Set: Update based on feedback. Created 3 years, 7 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
« no previous file with comments | « remoting/client/input/text_keyboard_input_strategy.h ('k') | remoting/client/native_device_keymap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/input/text_keyboard_input_strategy.cc
diff --git a/remoting/client/input/text_keyboard_input_strategy.cc b/remoting/client/input/text_keyboard_input_strategy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7a0a6f7446a3dbb246573d60a8d7a449fe3bb0f7
--- /dev/null
+++ b/remoting/client/input/text_keyboard_input_strategy.cc
@@ -0,0 +1,49 @@
+// Copyright 2017 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 "remoting/client/input/text_keyboard_input_strategy.h"
+
+#include "remoting/client/input/client_input_injector.h"
+#include "remoting/client/native_device_keymap.h"
+#include "ui/events/keycodes/dom/dom_code.h"
+
+namespace remoting {
+
+TextKeyboardInputStrategy::TextKeyboardInputStrategy(
+ ClientInputInjector* input_injector)
+ : input_injector_(input_injector) {}
+
+TextKeyboardInputStrategy::~TextKeyboardInputStrategy() {}
+
+// KeyboardInputStrategy
+
+void TextKeyboardInputStrategy::HandleTextEvent(const std::string& text,
+ uint8_t modifiers) {
+ // TODO(nicholss): Handle modifers.
+ input_injector_->SendTextEvent(text);
+}
+
+void TextKeyboardInputStrategy::HandleDeleteEvent(uint8_t modifiers) {
+ std::queue<KeyEvent> keys = ConvertDeleteEvent(modifiers);
+ while (!keys.empty()) {
+ KeyEvent key = keys.front();
+ input_injector_->SendKeyEvent(0, key.keycode, key.keydown);
+ keys.pop();
+ }
+}
+
+std::queue<KeyEvent> TextKeyboardInputStrategy::ConvertDeleteEvent(
+ uint8_t modifiers) {
+ std::queue<KeyEvent> keys;
+ // TODO(nicholss): Handle modifers.
+ // Key press.
+ keys.push({static_cast<uint32_t>(ui::DomCode::BACKSPACE), true});
+
+ // Key release.
+ keys.push({static_cast<uint32_t>(ui::DomCode::BACKSPACE), false});
+
+ return keys;
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/client/input/text_keyboard_input_strategy.h ('k') | remoting/client/native_device_keymap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698