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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
9 // TODO(wez): Remove this when crbug.com/86353 is complete. | 9 // TODO(wez): Remove this when crbug.com/86353 is complete. |
10 #include "ppapi/cpp/private/var_private.h" | 10 #include "ppapi/cpp/private/var_private.h" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 if (properties_[width_index].attribute.AsInt() != width || | 265 if (properties_[width_index].attribute.AsInt() != width || |
266 properties_[height_index].attribute.AsInt() != height) { | 266 properties_[height_index].attribute.AsInt() != height) { |
267 properties_[width_index].attribute = Var(width); | 267 properties_[width_index].attribute = Var(width); |
268 properties_[height_index].attribute = Var(height); | 268 properties_[height_index].attribute = Var(height); |
269 SignalDesktopSizeChange(); | 269 SignalDesktopSizeChange(); |
270 } | 270 } |
271 | 271 |
272 LOG(INFO) << "Update desktop size to: " << width << " x " << height; | 272 LOG(INFO) << "Update desktop size to: " << width << " x " << height; |
273 } | 273 } |
274 | 274 |
| 275 void ChromotingScriptableObject::SignalLoginChallenge() { |
| 276 plugin_message_loop_->PostTask( |
| 277 FROM_HERE, task_factory_.NewRunnableMethod( |
| 278 &ChromotingScriptableObject::DoSignalLoginChallenge)); |
| 279 } |
| 280 |
| 281 void ChromotingScriptableObject::AttachXmppProxy(PepperXmppProxy* xmpp_proxy) { |
| 282 xmpp_proxy_ = xmpp_proxy; |
| 283 } |
| 284 |
| 285 void ChromotingScriptableObject::SendIq(const std::string& message_xml) { |
| 286 plugin_message_loop_->PostTask( |
| 287 FROM_HERE, task_factory_.NewRunnableMethod( |
| 288 &ChromotingScriptableObject::DoSendIq, message_xml)); |
| 289 } |
| 290 |
275 void ChromotingScriptableObject::AddAttribute(const std::string& name, | 291 void ChromotingScriptableObject::AddAttribute(const std::string& name, |
276 Var attribute) { | 292 Var attribute) { |
277 property_names_[name] = properties_.size(); | 293 property_names_[name] = properties_.size(); |
278 properties_.push_back(PropertyDescriptor(name, attribute)); | 294 properties_.push_back(PropertyDescriptor(name, attribute)); |
279 } | 295 } |
280 | 296 |
281 void ChromotingScriptableObject::AddMethod(const std::string& name, | 297 void ChromotingScriptableObject::AddMethod(const std::string& name, |
282 MethodHandler handler) { | 298 MethodHandler handler) { |
283 property_names_[name] = properties_.size(); | 299 property_names_[name] = properties_.size(); |
284 properties_.push_back(PropertyDescriptor(name, handler)); | 300 properties_.push_back(PropertyDescriptor(name, handler)); |
285 } | 301 } |
286 | 302 |
287 void ChromotingScriptableObject::SignalConnectionInfoChange() { | 303 void ChromotingScriptableObject::SignalConnectionInfoChange() { |
288 plugin_message_loop_->PostTask( | 304 plugin_message_loop_->PostTask( |
289 FROM_HERE, task_factory_.NewRunnableMethod( | 305 FROM_HERE, task_factory_.NewRunnableMethod( |
290 &ChromotingScriptableObject::DoSignalConnectionInfoChange)); | 306 &ChromotingScriptableObject::DoSignalConnectionInfoChange)); |
291 } | 307 } |
292 | 308 |
293 void ChromotingScriptableObject::SignalDesktopSizeChange() { | 309 void ChromotingScriptableObject::SignalDesktopSizeChange() { |
294 plugin_message_loop_->PostTask( | 310 plugin_message_loop_->PostTask( |
295 FROM_HERE, task_factory_.NewRunnableMethod( | 311 FROM_HERE, task_factory_.NewRunnableMethod( |
296 &ChromotingScriptableObject::DoSignalDesktopSizeChange)); | 312 &ChromotingScriptableObject::DoSignalDesktopSizeChange)); |
297 } | 313 } |
298 | 314 |
299 void ChromotingScriptableObject::SignalLoginChallenge() { | |
300 plugin_message_loop_->PostTask( | |
301 FROM_HERE, task_factory_.NewRunnableMethod( | |
302 &ChromotingScriptableObject::DoSignalLoginChallenge)); | |
303 } | |
304 | |
305 void ChromotingScriptableObject::DoSignalConnectionInfoChange() { | 315 void ChromotingScriptableObject::DoSignalConnectionInfoChange() { |
306 Var exception; | 316 Var exception; |
307 VarPrivate cb = GetProperty(Var(kConnectionInfoUpdate), &exception); | 317 VarPrivate cb = GetProperty(Var(kConnectionInfoUpdate), &exception); |
308 | 318 |
309 // Var() means call the object directly as a function rather than calling | 319 // |this| must not be touched after Call() returns. |
310 // a method in the object. | |
311 cb.Call(Var(), &exception); | 320 cb.Call(Var(), &exception); |
312 | 321 |
313 if (!exception.is_undefined()) | 322 if (!exception.is_undefined()) |
314 LOG(ERROR) << "Exception when invoking connectionInfoUpdate JS callback."; | 323 LOG(ERROR) << "Exception when invoking connectionInfoUpdate JS callback."; |
315 } | 324 } |
316 | 325 |
317 | |
318 void ChromotingScriptableObject::DoSignalDesktopSizeChange() { | 326 void ChromotingScriptableObject::DoSignalDesktopSizeChange() { |
319 Var exception; | 327 Var exception; |
320 VarPrivate cb = GetProperty(Var(kDesktopSizeUpdate), &exception); | 328 VarPrivate cb = GetProperty(Var(kDesktopSizeUpdate), &exception); |
321 | 329 |
322 // Var() means call the object directly as a function rather than calling | 330 // |this| must not be touched after Call() returns. |
323 // a method in the object. | |
324 cb.Call(Var(), &exception); | 331 cb.Call(Var(), &exception); |
325 | 332 |
326 if (!exception.is_undefined()) { | 333 if (!exception.is_undefined()) { |
327 LOG(ERROR) << "Exception when invoking JS callback" | 334 LOG(ERROR) << "Exception when invoking JS callback" |
328 << exception.DebugString(); | 335 << exception.DebugString(); |
329 } | 336 } |
330 } | 337 } |
331 | 338 |
332 void ChromotingScriptableObject::DoSignalLoginChallenge() { | 339 void ChromotingScriptableObject::DoSignalLoginChallenge() { |
333 Var exception; | 340 Var exception; |
334 VarPrivate cb = GetProperty(Var(kLoginChallenge), &exception); | 341 VarPrivate cb = GetProperty(Var(kLoginChallenge), &exception); |
335 | 342 |
336 // Var() means call the object directly as a function rather than calling | 343 // |this| must not be touched after Call() returns. |
337 // a method in the object. | |
338 cb.Call(Var(), &exception); | 344 cb.Call(Var(), &exception); |
339 | 345 |
340 if (!exception.is_undefined()) | 346 if (!exception.is_undefined()) |
341 LOG(ERROR) << "Exception when invoking loginChallenge JS callback."; | 347 LOG(ERROR) << "Exception when invoking loginChallenge JS callback."; |
342 } | 348 } |
343 | 349 |
344 void ChromotingScriptableObject::AttachXmppProxy(PepperXmppProxy* xmpp_proxy) { | 350 void ChromotingScriptableObject::DoSendIq(const std::string& message_xml) { |
345 xmpp_proxy_ = xmpp_proxy; | |
346 } | |
347 | |
348 void ChromotingScriptableObject::SendIq(const std::string& message_xml) { | |
349 Var exception; | 351 Var exception; |
350 VarPrivate cb = GetProperty(Var(kSendIq), &exception); | 352 VarPrivate cb = GetProperty(Var(kSendIq), &exception); |
351 | 353 |
352 // Var() means call the object directly as a function rather than calling | 354 // |this| must not be touched after Call() returns. |
353 // a method in the object. | |
354 cb.Call(Var(), Var(message_xml), &exception); | 355 cb.Call(Var(), Var(message_xml), &exception); |
355 | 356 |
356 if (!exception.is_undefined()) | 357 if (!exception.is_undefined()) |
357 LOG(ERROR) << "Exception when invoking sendiq JS callback."; | 358 LOG(ERROR) << "Exception when invoking sendiq JS callback."; |
358 } | 359 } |
359 | 360 |
360 Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args, | 361 Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args, |
361 Var* exception) { | 362 Var* exception) { |
362 // Parameter order is: | 363 // Parameter order is: |
363 // host_jid | 364 // host_jid |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 const std::vector<pp::Var>& args, pp::Var* exception) { | 481 const std::vector<pp::Var>& args, pp::Var* exception) { |
481 if (args.size() != 0) { | 482 if (args.size() != 0) { |
482 *exception = Var("Usage: DoReleaseAllKeys()"); | 483 *exception = Var("Usage: DoReleaseAllKeys()"); |
483 return Var(); | 484 return Var(); |
484 } | 485 } |
485 instance_->ReleaseAllKeys(); | 486 instance_->ReleaseAllKeys(); |
486 return Var(); | 487 return Var(); |
487 } | 488 } |
488 | 489 |
489 } // namespace remoting | 490 } // namespace remoting |
OLD | NEW |