| OLD | NEW |
| 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 Loading... |
| 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); | |
| 266 } | 251 } |
| 267 } | 252 } |
| 268 | 253 |
| 269 void ChromotingInstance::DidChangeView(const pp::Rect& position, | 254 void ChromotingInstance::DidChangeView(const pp::Rect& position, |
| 270 const pp::Rect& clip) { | 255 const pp::Rect& clip) { |
| 271 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); | 256 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); |
| 272 | 257 |
| 273 SkISize new_size = SkISize::Make(position.width(), position.height()); | 258 SkISize new_size = SkISize::Make(position.width(), position.height()); |
| 274 SkIRect new_clip = | 259 SkIRect new_clip = |
| 275 SkIRect::MakeXYWH(clip.x(), clip.y(), clip.width(), clip.height()); | 260 SkIRect::MakeXYWH(clip.x(), clip.y(), clip.width(), clip.height()); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 host_connection_.reset(); | 383 host_connection_.reset(); |
| 399 | 384 |
| 400 SetConnectionState(STATE_CLOSED, ERROR_NONE); | 385 SetConnectionState(STATE_CLOSED, ERROR_NONE); |
| 401 } | 386 } |
| 402 | 387 |
| 403 void ChromotingInstance::OnIncomingIq(const std::string& iq) { | 388 void ChromotingInstance::OnIncomingIq(const std::string& iq) { |
| 404 xmpp_proxy_->OnIq(iq); | 389 xmpp_proxy_->OnIq(iq); |
| 405 } | 390 } |
| 406 | 391 |
| 407 void ChromotingInstance::ReleaseAllKeys() { | 392 void ChromotingInstance::ReleaseAllKeys() { |
| 408 if (key_event_tracker_.get()) | 393 if (key_event_tracker_.get()) { |
| 409 key_event_tracker_->ReleaseAllKeys(); | 394 key_event_tracker_->ReleaseAllKeys(); |
| 410 } | 395 } |
| 411 | |
| 412 void ChromotingInstance::InjectKeyEvent(const protocol::KeyEvent& event) { | |
| 413 if (key_event_tracker_.get()) | |
| 414 key_event_tracker_->InjectKeyEvent(event); | |
| 415 } | 396 } |
| 416 | 397 |
| 417 ChromotingStats* ChromotingInstance::GetStats() { | 398 ChromotingStats* ChromotingInstance::GetStats() { |
| 418 if (!client_.get()) | 399 if (!client_.get()) |
| 419 return NULL; | 400 return NULL; |
| 420 return client_->GetStats(); | 401 return client_->GetStats(); |
| 421 } | 402 } |
| 422 | 403 |
| 423 void ChromotingInstance::PostChromotingMessage( | 404 void ChromotingInstance::PostChromotingMessage( |
| 424 const std::string& method, | 405 const std::string& method, |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 536 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 556 data->SetString("message", message); | 537 data->SetString("message", message); |
| 557 PostChromotingMessage("logDebugMessage", data.Pass()); | 538 PostChromotingMessage("logDebugMessage", data.Pass()); |
| 558 | 539 |
| 559 scriptable_object->LogDebugInfo(message); | 540 scriptable_object->LogDebugInfo(message); |
| 560 } | 541 } |
| 561 g_logging_to_plugin = false; | 542 g_logging_to_plugin = false; |
| 562 } | 543 } |
| 563 | 544 |
| 564 } // namespace remoting | 545 } // namespace remoting |
| OLD | NEW |