| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 static bool g_logging_to_plugin = false; | 95 static bool g_logging_to_plugin = false; |
| 96 static bool g_has_logging_instance = false; | 96 static bool g_has_logging_instance = false; |
| 97 static ChromotingInstance* g_logging_instance = NULL; | 97 static ChromotingInstance* g_logging_instance = NULL; |
| 98 static logging::LogMessageHandlerFunction g_logging_old_handler = NULL; | 98 static logging::LogMessageHandlerFunction g_logging_old_handler = NULL; |
| 99 | 99 |
| 100 static base::LazyInstance<base::Lock>::Leaky | 100 static base::LazyInstance<base::Lock>::Leaky |
| 101 g_logging_lock = LAZY_INSTANCE_INITIALIZER; | 101 g_logging_lock = LAZY_INSTANCE_INITIALIZER; |
| 102 | 102 |
| 103 // String sent in the "hello" message to the plugin to describe features. | 103 // String sent in the "hello" message to the plugin to describe features. |
| 104 const char ChromotingInstance::kApiFeatures[] = | 104 const char ChromotingInstance::kApiFeatures[] = |
| 105 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey"; | 105 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey " |
| 106 "notifyClientDimensions"; |
| 106 | 107 |
| 107 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, | 108 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, |
| 108 ClientConfig* config) { | 109 ClientConfig* config) { |
| 109 if (auth_methods_str == "v1_token") { | 110 if (auth_methods_str == "v1_token") { |
| 110 config->use_v1_authenticator = true; | 111 config->use_v1_authenticator = true; |
| 111 } else { | 112 } else { |
| 112 config->use_v1_authenticator = false; | 113 config->use_v1_authenticator = false; |
| 113 | 114 |
| 114 std::vector<std::string> auth_methods; | 115 std::vector<std::string> auth_methods; |
| 115 base::SplitString(auth_methods_str, ',', &auth_methods); | 116 base::SplitString(auth_methods_str, ',', &auth_methods); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 TrapKey(keycode, trap); | 293 TrapKey(keycode, trap); |
| 293 } else if (method == "sendClipboardItem") { | 294 } else if (method == "sendClipboardItem") { |
| 294 std::string mime_type; | 295 std::string mime_type; |
| 295 std::string item; | 296 std::string item; |
| 296 if (!data->GetString("mimeType", &mime_type) || | 297 if (!data->GetString("mimeType", &mime_type) || |
| 297 !data->GetString("item", &item)) { | 298 !data->GetString("item", &item)) { |
| 298 LOG(ERROR) << "Invalid sendClipboardItem() data."; | 299 LOG(ERROR) << "Invalid sendClipboardItem() data."; |
| 299 return; | 300 return; |
| 300 } | 301 } |
| 301 SendClipboardItem(mime_type, item); | 302 SendClipboardItem(mime_type, item); |
| 303 } else if (method == "notifyClientDimensions") { |
| 304 int width = 0; |
| 305 int height = 0; |
| 306 if (!data->GetInteger("width", &width) || |
| 307 !data->GetInteger("height", &height)) { |
| 308 LOG(ERROR) << "Invalid notifyClientDimensions."; |
| 309 return; |
| 310 } |
| 311 NotifyClientDimensions(width, height); |
| 302 } | 312 } |
| 303 } | 313 } |
| 304 | 314 |
| 305 void ChromotingInstance::DidChangeView(const pp::Rect& position, | 315 void ChromotingInstance::DidChangeView(const pp::Rect& position, |
| 306 const pp::Rect& clip) { | 316 const pp::Rect& clip) { |
| 307 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); | 317 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); |
| 308 | 318 |
| 309 SkISize new_size = SkISize::Make(position.width(), position.height()); | 319 SkISize new_size = SkISize::Make(position.width(), position.height()); |
| 310 SkIRect new_clip = | 320 SkIRect new_clip = |
| 311 SkIRect::MakeXYWH(clip.x(), clip.y(), clip.width(), clip.height()); | 321 SkIRect::MakeXYWH(clip.x(), clip.y(), clip.width(), clip.height()); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 const std::string& item) { | 475 const std::string& item) { |
| 466 if (!host_connection_.get()) { | 476 if (!host_connection_.get()) { |
| 467 return; | 477 return; |
| 468 } | 478 } |
| 469 protocol::ClipboardEvent event; | 479 protocol::ClipboardEvent event; |
| 470 event.set_mime_type(mime_type); | 480 event.set_mime_type(mime_type); |
| 471 event.set_data(item); | 481 event.set_data(item); |
| 472 host_connection_->clipboard_stub()->InjectClipboardEvent(event); | 482 host_connection_->clipboard_stub()->InjectClipboardEvent(event); |
| 473 } | 483 } |
| 474 | 484 |
| 485 void ChromotingInstance::NotifyClientDimensions(int width, int height) { |
| 486 if (!host_connection_.get()) { |
| 487 return; |
| 488 } |
| 489 protocol::ClientDimensions client_dimensions; |
| 490 client_dimensions.set_width(width); |
| 491 client_dimensions.set_height(height); |
| 492 host_connection_->host_stub()->NotifyClientDimensions(client_dimensions); |
| 493 } |
| 494 |
| 475 ChromotingStats* ChromotingInstance::GetStats() { | 495 ChromotingStats* ChromotingInstance::GetStats() { |
| 476 if (!client_.get()) | 496 if (!client_.get()) |
| 477 return NULL; | 497 return NULL; |
| 478 return client_->GetStats(); | 498 return client_->GetStats(); |
| 479 } | 499 } |
| 480 | 500 |
| 481 void ChromotingInstance::PostChromotingMessage( | 501 void ChromotingInstance::PostChromotingMessage( |
| 482 const std::string& method, | 502 const std::string& method, |
| 483 scoped_ptr<base::DictionaryValue> data) { | 503 scoped_ptr<base::DictionaryValue> data) { |
| 484 scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue()); | 504 scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue()); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 648 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 629 data->SetString("message", message); | 649 data->SetString("message", message); |
| 630 PostChromotingMessage("logDebugMessage", data.Pass()); | 650 PostChromotingMessage("logDebugMessage", data.Pass()); |
| 631 | 651 |
| 632 scriptable_object->LogDebugInfo(message); | 652 scriptable_object->LogDebugInfo(message); |
| 633 } | 653 } |
| 634 g_logging_to_plugin = false; | 654 g_logging_to_plugin = false; |
| 635 } | 655 } |
| 636 | 656 |
| 637 } // namespace remoting | 657 } // namespace remoting |
| OLD | NEW |