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

Side by Side Diff: remoting/client/plugin/chromoting_instance.cc

Issue 9958141: Merge 130082 - Add an injectKeyEvent API to the Chromoting client plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src/
Patch Set: 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 Disconnect(); 241 Disconnect();
242 } else if (method == "incomingIq") { 242 } else if (method == "incomingIq") {
243 std::string iq; 243 std::string iq;
244 if (!data->GetString("iq", &iq)) { 244 if (!data->GetString("iq", &iq)) {
245 LOG(ERROR) << "Invalid onIq() data."; 245 LOG(ERROR) << "Invalid onIq() data.";
246 return; 246 return;
247 } 247 }
248 OnIncomingIq(iq); 248 OnIncomingIq(iq);
249 } else if (method == "releaseAllKeys") { 249 } else if (method == "releaseAllKeys") {
250 ReleaseAllKeys(); 250 ReleaseAllKeys();
251 } else if (method == "injectKeyEvent") {
252 int usb_keycode = 0;
253 bool is_pressed = false;
254 if (!data->GetInteger("usb_keycode", &usb_keycode) ||
255 !data->GetBoolean("pressed", &is_pressed)) {
256 LOG(ERROR) << "Invalid injectKeyEvent.";
257 return;
258 }
259
260 protocol::KeyEvent event;
261 event.set_usb_keycode(usb_keycode);
262 event.set_pressed(is_pressed);
263 // Even though new hosts will ignore keycode, it's a required field.
264 event.set_keycode(0);
265 InjectKeyEvent(event);
251 } 266 }
252 } 267 }
253 268
254 void ChromotingInstance::DidChangeView(const pp::Rect& position, 269 void ChromotingInstance::DidChangeView(const pp::Rect& position,
255 const pp::Rect& clip) { 270 const pp::Rect& clip) {
256 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); 271 DCHECK(plugin_message_loop_->BelongsToCurrentThread());
257 272
258 SkISize new_size = SkISize::Make(position.width(), position.height()); 273 SkISize new_size = SkISize::Make(position.width(), position.height());
259 SkIRect new_clip = 274 SkIRect new_clip =
260 SkIRect::MakeXYWH(clip.x(), clip.y(), clip.width(), clip.height()); 275 SkIRect::MakeXYWH(clip.x(), clip.y(), clip.width(), clip.height());
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 host_connection_.reset(); 398 host_connection_.reset();
384 399
385 SetConnectionState(STATE_CLOSED, ERROR_NONE); 400 SetConnectionState(STATE_CLOSED, ERROR_NONE);
386 } 401 }
387 402
388 void ChromotingInstance::OnIncomingIq(const std::string& iq) { 403 void ChromotingInstance::OnIncomingIq(const std::string& iq) {
389 xmpp_proxy_->OnIq(iq); 404 xmpp_proxy_->OnIq(iq);
390 } 405 }
391 406
392 void ChromotingInstance::ReleaseAllKeys() { 407 void ChromotingInstance::ReleaseAllKeys() {
393 if (key_event_tracker_.get()) { 408 if (key_event_tracker_.get())
394 key_event_tracker_->ReleaseAllKeys(); 409 key_event_tracker_->ReleaseAllKeys();
395 } 410 }
411
412 void ChromotingInstance::InjectKeyEvent(const protocol::KeyEvent& event) {
413 if (key_event_tracker_.get())
414 key_event_tracker_->InjectKeyEvent(event);
396 } 415 }
397 416
398 ChromotingStats* ChromotingInstance::GetStats() { 417 ChromotingStats* ChromotingInstance::GetStats() {
399 if (!client_.get()) 418 if (!client_.get())
400 return NULL; 419 return NULL;
401 return client_->GetStats(); 420 return client_->GetStats();
402 } 421 }
403 422
404 void ChromotingInstance::PostChromotingMessage( 423 void ChromotingInstance::PostChromotingMessage(
405 const std::string& method, 424 const std::string& method,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 555 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
537 data->SetString("message", message); 556 data->SetString("message", message);
538 PostChromotingMessage("logDebugMessage", data.Pass()); 557 PostChromotingMessage("logDebugMessage", data.Pass());
539 558
540 scriptable_object->LogDebugInfo(message); 559 scriptable_object->LogDebugInfo(message);
541 } 560 }
542 g_logging_to_plugin = false; 561 g_logging_to_plugin = false;
543 } 562 }
544 563
545 } // namespace remoting 564 } // 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