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

Side by Side 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, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | remoting/webapp/client_plugin.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/client/plugin/chromoting_instance.h" 5 #include "remoting/client/plugin/chromoting_instance.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 Disconnect(); 242 Disconnect();
243 } else if (method == "incomingIq") { 243 } else if (method == "incomingIq") {
244 std::string iq; 244 std::string iq;
245 if (!data->GetString("iq", &iq)) { 245 if (!data->GetString("iq", &iq)) {
246 LOG(ERROR) << "Invalid onIq() data."; 246 LOG(ERROR) << "Invalid onIq() data.";
247 return; 247 return;
248 } 248 }
249 OnIncomingIq(iq); 249 OnIncomingIq(iq);
250 } else if (method == "releaseAllKeys") { 250 } else if (method == "releaseAllKeys") {
251 ReleaseAllKeys(); 251 ReleaseAllKeys();
252 } else if (method == "injectKeyEvent") {
253 int usb_keycode = 0;
254 bool is_pressed = false;
255 if (!data->GetInteger("usb_keycode", &usb_keycode) ||
256 !data->GetBoolean("pressed", &is_pressed)) {
257 LOG(ERROR) << "Invalid injectKeyEvent.";
258 return;
259 }
260
261 protocol::KeyEvent event;
262 event.set_usb_keycode(usb_keycode);
263 event.set_pressed(is_pressed);
264 // Even though new hosts will ignore keycode, it's a required field.
265 event.set_keycode(0);
266 InjectKeyEvent(event);
252 } else if (method == "sendClipboardItem") { 267 } else if (method == "sendClipboardItem") {
253 std::string mime_type; 268 std::string mime_type;
254 std::string item; 269 std::string item;
255 if (!data->GetString("mimeType", &mime_type) || 270 if (!data->GetString("mimeType", &mime_type) ||
256 !data->GetString("item", &item)) { 271 !data->GetString("item", &item)) {
257 LOG(ERROR) << "Invalid sendClipboardItem() data."; 272 LOG(ERROR) << "Invalid sendClipboardItem() data.";
258 return; 273 return;
259 } 274 }
260 SendClipboardItem(mime_type, item); 275 SendClipboardItem(mime_type, item);
261 } 276 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 host_connection_.reset(); 408 host_connection_.reset();
394 409
395 SetConnectionState(STATE_CLOSED, ERROR_NONE); 410 SetConnectionState(STATE_CLOSED, ERROR_NONE);
396 } 411 }
397 412
398 void ChromotingInstance::OnIncomingIq(const std::string& iq) { 413 void ChromotingInstance::OnIncomingIq(const std::string& iq) {
399 xmpp_proxy_->OnIq(iq); 414 xmpp_proxy_->OnIq(iq);
400 } 415 }
401 416
402 void ChromotingInstance::ReleaseAllKeys() { 417 void ChromotingInstance::ReleaseAllKeys() {
403 if (key_event_tracker_.get()) { 418 if (key_event_tracker_.get())
404 key_event_tracker_->ReleaseAllKeys(); 419 key_event_tracker_->ReleaseAllKeys();
405 } 420 }
421
422 void ChromotingInstance::InjectKeyEvent(const protocol::KeyEvent& event) {
423 if (key_event_tracker_.get())
424 key_event_tracker_->InjectKeyEvent(event);
406 } 425 }
407 426
408 void ChromotingInstance::SendClipboardItem(const std::string& mime_type, 427 void ChromotingInstance::SendClipboardItem(const std::string& mime_type,
409 const std::string& item) { 428 const std::string& item) {
410 // TODO(simonmorris): Plumb this in to a ClipboardStub. 429 // TODO(simonmorris): Plumb this in to a ClipboardStub.
411 } 430 }
412 431
413 ChromotingStats* ChromotingInstance::GetStats() { 432 ChromotingStats* ChromotingInstance::GetStats() {
414 if (!client_.get()) 433 if (!client_.get())
415 return NULL; 434 return NULL;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 570 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
552 data->SetString("message", message); 571 data->SetString("message", message);
553 PostChromotingMessage("logDebugMessage", data.Pass()); 572 PostChromotingMessage("logDebugMessage", data.Pass());
554 573
555 scriptable_object->LogDebugInfo(message); 574 scriptable_object->LogDebugInfo(message);
556 } 575 }
557 g_logging_to_plugin = false; 576 g_logging_to_plugin = false;
558 } 577 }
559 578
560 } // namespace remoting 579 } // namespace remoting
OLDNEW
« 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