OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_scriptable_object.h" | 5 #include "remoting/client/plugin/chromoting_scriptable_object.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 // TODO(wez): Remove this when crbug.com/86353 is complete. | 10 // TODO(wez): Remove this when crbug.com/86353 is complete. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 AddAttribute(kVideoBandwidthAttribute, Var()); | 96 AddAttribute(kVideoBandwidthAttribute, Var()); |
97 AddAttribute(kVideoFrameRateAttribute, Var()); | 97 AddAttribute(kVideoFrameRateAttribute, Var()); |
98 AddAttribute(kVideoCaptureLatencyAttribute, Var()); | 98 AddAttribute(kVideoCaptureLatencyAttribute, Var()); |
99 AddAttribute(kVideoEncodeLatencyAttribute, Var()); | 99 AddAttribute(kVideoEncodeLatencyAttribute, Var()); |
100 AddAttribute(kVideoDecodeLatencyAttribute, Var()); | 100 AddAttribute(kVideoDecodeLatencyAttribute, Var()); |
101 AddAttribute(kVideoRenderLatencyAttribute, Var()); | 101 AddAttribute(kVideoRenderLatencyAttribute, Var()); |
102 AddAttribute(kRoundTripLatencyAttribute, Var()); | 102 AddAttribute(kRoundTripLatencyAttribute, Var()); |
103 | 103 |
104 AddMethod("connect", &ChromotingScriptableObject::DoConnect); | 104 AddMethod("connect", &ChromotingScriptableObject::DoConnect); |
105 AddMethod("disconnect", &ChromotingScriptableObject::DoDisconnect); | 105 AddMethod("disconnect", &ChromotingScriptableObject::DoDisconnect); |
106 AddMethod("setScaleToFit", &ChromotingScriptableObject::DoSetScaleToFit); | |
107 AddMethod("onIq", &ChromotingScriptableObject::DoOnIq); | 106 AddMethod("onIq", &ChromotingScriptableObject::DoOnIq); |
108 AddMethod("releaseAllKeys", &ChromotingScriptableObject::DoReleaseAllKeys); | 107 AddMethod("releaseAllKeys", &ChromotingScriptableObject::DoReleaseAllKeys); |
| 108 |
| 109 // Older versions of the web app expect a setScaleToFit method. |
| 110 AddMethod("setScaleToFit", &ChromotingScriptableObject::DoNothing); |
109 } | 111 } |
110 | 112 |
111 bool ChromotingScriptableObject::HasProperty(const Var& name, Var* exception) { | 113 bool ChromotingScriptableObject::HasProperty(const Var& name, Var* exception) { |
112 // TODO(ajwong): Check if all these name.is_string() sentinels are required. | 114 // TODO(ajwong): Check if all these name.is_string() sentinels are required. |
113 if (!name.is_string()) { | 115 if (!name.is_string()) { |
114 *exception = Var("HasProperty expects a string for the name."); | 116 *exception = Var("HasProperty expects a string for the name."); |
115 return false; | 117 return false; |
116 } | 118 } |
117 | 119 |
118 PropertyNameMap::const_iterator iter = property_names_.find(name.AsString()); | 120 PropertyNameMap::const_iterator iter = property_names_.find(name.AsString()); |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 return Var(); | 405 return Var(); |
404 } | 406 } |
405 | 407 |
406 Var ChromotingScriptableObject::DoDisconnect(const std::vector<Var>& args, | 408 Var ChromotingScriptableObject::DoDisconnect(const std::vector<Var>& args, |
407 Var* exception) { | 409 Var* exception) { |
408 VLOG(1) << "Disconnecting from host."; | 410 VLOG(1) << "Disconnecting from host."; |
409 instance_->Disconnect(); | 411 instance_->Disconnect(); |
410 return Var(); | 412 return Var(); |
411 } | 413 } |
412 | 414 |
413 Var ChromotingScriptableObject::DoSetScaleToFit(const std::vector<Var>& args, | 415 Var ChromotingScriptableObject::DoNothing(const std::vector<Var>& args, |
414 Var* exception) { | 416 Var* exception) { |
415 if (args.size() != 1) { | |
416 *exception = Var("Usage: setScaleToFit(scale_to_fit)"); | |
417 return Var(); | |
418 } | |
419 | |
420 if (!args[0].is_bool()) { | |
421 *exception = Var("scale_to_fit must be a boolean."); | |
422 return Var(); | |
423 } | |
424 | |
425 VLOG(1) << "Setting scale-to-fit."; | |
426 instance_->SetScaleToFit(args[0].AsBool()); | |
427 return Var(); | 417 return Var(); |
428 } | 418 } |
429 | 419 |
430 Var ChromotingScriptableObject::DoOnIq(const std::vector<Var>& args, | 420 Var ChromotingScriptableObject::DoOnIq(const std::vector<Var>& args, |
431 Var* exception) { | 421 Var* exception) { |
432 if (args.size() != 1) { | 422 if (args.size() != 1) { |
433 *exception = Var("Usage: onIq(response_xml)"); | 423 *exception = Var("Usage: onIq(response_xml)"); |
434 return Var(); | 424 return Var(); |
435 } | 425 } |
436 | 426 |
(...skipping 11 matching lines...) Expand all Loading... |
448 const std::vector<pp::Var>& args, pp::Var* exception) { | 438 const std::vector<pp::Var>& args, pp::Var* exception) { |
449 if (args.size() != 0) { | 439 if (args.size() != 0) { |
450 *exception = Var("Usage: DoReleaseAllKeys()"); | 440 *exception = Var("Usage: DoReleaseAllKeys()"); |
451 return Var(); | 441 return Var(); |
452 } | 442 } |
453 instance_->ReleaseAllKeys(); | 443 instance_->ReleaseAllKeys(); |
454 return Var(); | 444 return Var(); |
455 } | 445 } |
456 | 446 |
457 } // namespace remoting | 447 } // namespace remoting |
OLD | NEW |