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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 140 |
141 } // namespace | 141 } // namespace |
142 | 142 |
143 // String sent in the "hello" message to the webapp to describe features. | 143 // String sent in the "hello" message to the webapp to describe features. |
144 const char ChromotingInstance::kApiFeatures[] = | 144 const char ChromotingInstance::kApiFeatures[] = |
145 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey " | 145 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey " |
146 "notifyClientDimensions notifyClientResolution pauseVideo pauseAudio " | 146 "notifyClientDimensions notifyClientResolution pauseVideo pauseAudio " |
147 "asyncPin thirdPartyAuth pinlessAuth"; | 147 "asyncPin thirdPartyAuth pinlessAuth"; |
148 | 148 |
149 const char ChromotingInstance::kRequestedCapabilities[] = ""; | 149 const char ChromotingInstance::kRequestedCapabilities[] = ""; |
150 const char ChromotingInstance::kSupportedCapabilities[] = ""; | 150 const char ChromotingInstance::kSupportedCapabilities[] = "desktopShape"; |
151 | 151 |
152 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, | 152 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, |
153 ClientConfig* config) { | 153 ClientConfig* config) { |
154 std::vector<std::string> auth_methods; | 154 std::vector<std::string> auth_methods; |
155 base::SplitString(auth_methods_str, ',', &auth_methods); | 155 base::SplitString(auth_methods_str, ',', &auth_methods); |
156 for (std::vector<std::string>::iterator it = auth_methods.begin(); | 156 for (std::vector<std::string>::iterator it = auth_methods.begin(); |
157 it != auth_methods.end(); ++it) { | 157 it != auth_methods.end(); ++it) { |
158 protocol::AuthenticationMethod authentication_method = | 158 protocol::AuthenticationMethod authentication_method = |
159 protocol::AuthenticationMethod::FromString(*it); | 159 protocol::AuthenticationMethod::FromString(*it); |
160 if (authentication_method.is_valid()) | 160 if (authentication_method.is_valid()) |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 462 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
463 data->SetInteger("width", size.width()); | 463 data->SetInteger("width", size.width()); |
464 data->SetInteger("height", size.height()); | 464 data->SetInteger("height", size.height()); |
465 if (dpi.x()) | 465 if (dpi.x()) |
466 data->SetInteger("x_dpi", dpi.x()); | 466 data->SetInteger("x_dpi", dpi.x()); |
467 if (dpi.y()) | 467 if (dpi.y()) |
468 data->SetInteger("y_dpi", dpi.y()); | 468 data->SetInteger("y_dpi", dpi.y()); |
469 PostChromotingMessage("onDesktopSize", data.Pass()); | 469 PostChromotingMessage("onDesktopSize", data.Pass()); |
470 } | 470 } |
471 | 471 |
| 472 void ChromotingInstance::SetDesktopShape(const SkRegion& shape) { |
| 473 if (desktop_shape_ && shape == *desktop_shape_) |
| 474 return; |
| 475 |
| 476 desktop_shape_.reset(new SkRegion(shape)); |
| 477 |
| 478 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); |
| 479 for (SkRegion::Iterator i(shape); !i.done(); i.next()) { |
| 480 SkIRect rect = i.rect(); |
| 481 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); |
| 482 rect_value->AppendInteger(rect.x()); |
| 483 rect_value->AppendInteger(rect.y()); |
| 484 rect_value->AppendInteger(rect.width()); |
| 485 rect_value->AppendInteger(rect.height()); |
| 486 rects_value->Append(rect_value.release()); |
| 487 } |
| 488 |
| 489 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 490 data->Set("rects", rects_value.release()); |
| 491 PostChromotingMessage("onDesktopShape", data.Pass()); |
| 492 } |
| 493 |
472 void ChromotingInstance::OnConnectionState( | 494 void ChromotingInstance::OnConnectionState( |
473 protocol::ConnectionToHost::State state, | 495 protocol::ConnectionToHost::State state, |
474 protocol::ErrorCode error) { | 496 protocol::ErrorCode error) { |
475 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 497 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
476 data->SetString("state", ConnectionStateToString(state)); | 498 data->SetString("state", ConnectionStateToString(state)); |
477 data->SetString("error", ConnectionErrorToString(error)); | 499 data->SetString("error", ConnectionErrorToString(error)); |
478 PostChromotingMessage("onConnectionStatus", data.Pass()); | 500 PostChromotingMessage("onConnectionStatus", data.Pass()); |
479 } | 501 } |
480 | 502 |
481 void ChromotingInstance::FetchThirdPartyToken( | 503 void ChromotingInstance::FetchThirdPartyToken( |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 url_components.scheme.len); | 1006 url_components.scheme.len); |
985 return url_scheme == kChromeExtensionUrlScheme; | 1007 return url_scheme == kChromeExtensionUrlScheme; |
986 } | 1008 } |
987 | 1009 |
988 bool ChromotingInstance::IsConnected() { | 1010 bool ChromotingInstance::IsConnected() { |
989 return host_connection_.get() && | 1011 return host_connection_.get() && |
990 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); | 1012 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); |
991 } | 1013 } |
992 | 1014 |
993 } // namespace remoting | 1015 } // namespace remoting |
OLD | NEW |