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

Unified Diff: remoting/client/plugin/chromoting_instance.cc

Issue 9968030: Add an injectKeyEvent API to the Chromoting client plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 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
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | remoting/webapp/client_plugin.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/plugin/chromoting_instance.cc
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index d357ce52975d0f2721d7ee8b7dc19ca93536498f..30e3c51366b8bf6ddc48cf63dcb9339bd080b753 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -249,6 +249,21 @@ void ChromotingInstance::HandleMessage(const pp::Var& message) {
OnIncomingIq(iq);
} else if (method == "releaseAllKeys") {
ReleaseAllKeys();
+ } else if (method == "injectKeyEvent") {
+ int usb_keycode = 0;
+ bool is_pressed = false;
+ if (!data->GetInteger("usb_keycode", &usb_keycode) ||
+ !data->GetBoolean("pressed", &is_pressed)) {
+ LOG(ERROR) << "Invalid injectKeyEvent.";
+ return;
+ }
+
+ protocol::KeyEvent event;
+ event.set_usb_keycode(usb_keycode);
+ event.set_pressed(is_pressed);
+ // Even though new hosts will ignore keycode, it's a required field.
+ event.set_keycode(0);
+ InjectKeyEvent(event);
} else if (method == "sendClipboardItem") {
std::string mime_type;
std::string item;
@@ -400,9 +415,13 @@ void ChromotingInstance::OnIncomingIq(const std::string& iq) {
}
void ChromotingInstance::ReleaseAllKeys() {
- if (key_event_tracker_.get()) {
+ if (key_event_tracker_.get())
key_event_tracker_->ReleaseAllKeys();
- }
+}
+
+void ChromotingInstance::InjectKeyEvent(const protocol::KeyEvent& event) {
+ if (key_event_tracker_.get())
+ key_event_tracker_->InjectKeyEvent(event);
}
void ChromotingInstance::SendClipboardItem(const std::string& mime_type,
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | remoting/webapp/client_plugin.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698