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 // Var() means call the object directly as a function rather than calling |
310 // a method in the object. | 320 // a method in the object. |
311 cb.Call(Var(), &exception); | 321 cb.Call(Var(), &exception); |
312 | 322 |
313 if (!exception.is_undefined()) | 323 if (!exception.is_undefined()) |
314 LOG(ERROR) << "Exception when invoking connectionInfoUpdate JS callback."; | 324 LOG(ERROR) << "Exception when invoking connectionInfoUpdate JS callback."; |
315 } | 325 } |
316 | 326 |
317 | |
318 void ChromotingScriptableObject::DoSignalDesktopSizeChange() { | 327 void ChromotingScriptableObject::DoSignalDesktopSizeChange() { |
319 Var exception; | 328 Var exception; |
320 VarPrivate cb = GetProperty(Var(kDesktopSizeUpdate), &exception); | 329 VarPrivate cb = GetProperty(Var(kDesktopSizeUpdate), &exception); |
321 | 330 |
322 // Var() means call the object directly as a function rather than calling | 331 // Var() means call the object directly as a function rather than calling |
323 // a method in the object. | 332 // a method in the object. |
324 cb.Call(Var(), &exception); | 333 cb.Call(Var(), &exception); |
325 | 334 |
326 if (!exception.is_undefined()) { | 335 if (!exception.is_undefined()) { |
327 LOG(ERROR) << "Exception when invoking JS callback" | 336 LOG(ERROR) << "Exception when invoking JS callback" |
328 << exception.DebugString(); | 337 << exception.DebugString(); |
329 } | 338 } |
330 } | 339 } |
331 | 340 |
332 void ChromotingScriptableObject::DoSignalLoginChallenge() { | 341 void ChromotingScriptableObject::DoSignalLoginChallenge() { |
333 Var exception; | 342 Var exception; |
334 VarPrivate cb = GetProperty(Var(kLoginChallenge), &exception); | 343 VarPrivate cb = GetProperty(Var(kLoginChallenge), &exception); |
335 | 344 |
336 // Var() means call the object directly as a function rather than calling | 345 // Var() means call the object directly as a function rather than calling |
337 // a method in the object. | 346 // a method in the object. |
338 cb.Call(Var(), &exception); | 347 cb.Call(Var(), &exception); |
339 | 348 |
340 if (!exception.is_undefined()) | 349 if (!exception.is_undefined()) |
341 LOG(ERROR) << "Exception when invoking loginChallenge JS callback."; | 350 LOG(ERROR) << "Exception when invoking loginChallenge JS callback."; |
342 } | 351 } |
343 | 352 |
344 void ChromotingScriptableObject::AttachXmppProxy(PepperXmppProxy* xmpp_proxy) { | 353 void ChromotingScriptableObject::DoSendIq(const std::string& message_xml) { |
Wez
2011/08/24 20:44:45
It's probably worth replacing the "Var() means..."
Sergey Ulanov
2011/08/24 22:42:22
Done.
| |
345 xmpp_proxy_ = xmpp_proxy; | |
346 } | |
347 | |
348 void ChromotingScriptableObject::SendIq(const std::string& message_xml) { | |
349 Var exception; | 354 Var exception; |
350 VarPrivate cb = GetProperty(Var(kSendIq), &exception); | 355 VarPrivate cb = GetProperty(Var(kSendIq), &exception); |
351 | 356 |
352 // Var() means call the object directly as a function rather than calling | 357 // Var() means call the object directly as a function rather than calling |
353 // a method in the object. | 358 // a method in the object. |
354 cb.Call(Var(), Var(message_xml), &exception); | 359 cb.Call(Var(), Var(message_xml), &exception); |
355 | 360 |
356 if (!exception.is_undefined()) | 361 if (!exception.is_undefined()) |
357 LOG(ERROR) << "Exception when invoking sendiq JS callback."; | 362 LOG(ERROR) << "Exception when invoking sendiq JS callback."; |
358 } | 363 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 const std::vector<pp::Var>& args, pp::Var* exception) { | 485 const std::vector<pp::Var>& args, pp::Var* exception) { |
481 if (args.size() != 0) { | 486 if (args.size() != 0) { |
482 *exception = Var("Usage: DoReleaseAllKeys()"); | 487 *exception = Var("Usage: DoReleaseAllKeys()"); |
483 return Var(); | 488 return Var(); |
484 } | 489 } |
485 instance_->ReleaseAllKeys(); | 490 instance_->ReleaseAllKeys(); |
486 return Var(); | 491 return Var(); |
487 } | 492 } |
488 | 493 |
489 } // namespace remoting | 494 } // namespace remoting |
OLD | NEW |