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 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Functions related to the 'client screen' for Chromoting. | 7 * Functions related to the 'client screen' for Chromoting. |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
11 | 11 |
12 /** @suppress {duplicate} */ | 12 /** @suppress {duplicate} */ |
13 var remoting = remoting || {}; | 13 var remoting = remoting || {}; |
14 | 14 |
15 /** | 15 /** |
16 * @type {remoting.SessionConnector} The connector object, set when a connection | 16 * @type {remoting.SessionConnector} The connector object, set when a |
17 * is initiated. | 17 * connection is initiated. |
18 */ | 18 */ |
19 remoting.connector = null; | 19 remoting.connector = null; |
20 | 20 |
21 /** | 21 /** |
22 * @type {remoting.ClientSession} The client session object, set once the | 22 * @type {remoting.ClientSession} The client session object, set once the |
23 * connector has invoked its onOk callback. | 23 * connector has invoked its onOk callback. |
24 */ | 24 */ |
25 remoting.clientSession = null; | 25 remoting.clientSession = null; |
26 | 26 |
27 /** | 27 /** |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 event.preventDefault(); | 273 event.preventDefault(); |
274 | 274 |
275 // Set the focus away from the password field. This has to be done | 275 // Set the focus away from the password field. This has to be done |
276 // before the password field gets hidden, to work around a Blink | 276 // before the password field gets hidden, to work around a Blink |
277 // clipboard-handling bug - http://crbug.com/281523. | 277 // clipboard-handling bug - http://crbug.com/281523. |
278 document.getElementById('pin-connect-button').focus(); | 278 document.getElementById('pin-connect-button').focus(); |
279 | 279 |
280 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); | 280 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); |
281 onPinFetched(pin); | 281 onPinFetched(pin); |
282 if (/** @type {boolean} */(rememberPinCheckbox.checked)) { | 282 if (/** @type {boolean} */(rememberPinCheckbox.checked)) { |
283 remoting.connector.pairingRequested = true; | 283 /** @type {boolean} */ |
| 284 remoting.pairingRequested = true; |
284 } | 285 } |
285 } else { | 286 } else { |
286 remoting.setMode(remoting.AppMode.HOME); | 287 remoting.setMode(remoting.AppMode.HOME); |
287 } | 288 } |
288 }; | 289 }; |
289 pinForm.addEventListener('submit', onSubmitOrCancel, false); | 290 pinForm.addEventListener('submit', onSubmitOrCancel, false); |
290 pinCancel.addEventListener('click', onSubmitOrCancel, false); | 291 pinCancel.addEventListener('click', onSubmitOrCancel, false); |
291 rememberPin.hidden = !supportsPairing; | 292 rememberPin.hidden = !supportsPairing; |
292 rememberPinCheckbox.checked = false; | 293 rememberPinCheckbox.checked = false; |
293 var message = document.getElementById('pin-message'); | 294 var message = document.getElementById('pin-message'); |
(...skipping 27 matching lines...) Expand all Loading... |
321 document.getElementById('access-code-entry').value = ''; | 322 document.getElementById('access-code-entry').value = ''; |
322 remoting.setMode(remoting.AppMode.IN_SESSION); | 323 remoting.setMode(remoting.AppMode.IN_SESSION); |
323 remoting.toolbar.center(); | 324 remoting.toolbar.center(); |
324 remoting.toolbar.preview(); | 325 remoting.toolbar.preview(); |
325 remoting.clipboard.startSession(); | 326 remoting.clipboard.startSession(); |
326 updateStatistics_(); | 327 updateStatistics_(); |
327 remoting.hangoutSessionEvents.raiseEvent( | 328 remoting.hangoutSessionEvents.raiseEvent( |
328 remoting.hangoutSessionEvents.sessionStateChanged, | 329 remoting.hangoutSessionEvents.sessionStateChanged, |
329 remoting.ClientSession.State.CONNECTED | 330 remoting.ClientSession.State.CONNECTED |
330 ); | 331 ); |
331 if (remoting.connector.pairingRequested) { | 332 if (remoting.pairingRequested) { |
332 /** | 333 /** |
333 * @param {string} clientId | 334 * @param {string} clientId |
334 * @param {string} sharedSecret | 335 * @param {string} sharedSecret |
335 */ | 336 */ |
336 var onPairingComplete = function(clientId, sharedSecret) { | 337 var onPairingComplete = function(clientId, sharedSecret) { |
337 var pairingInfo = { | 338 var pairingInfo = { |
338 pairingInfo: { | 339 pairingInfo: { |
339 clientId: clientId, | 340 clientId: clientId, |
340 sharedSecret: sharedSecret | 341 sharedSecret: sharedSecret |
341 } | 342 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 return remoting.clientSession.handleExtensionMessage(type, data); | 376 return remoting.clientSession.handleExtensionMessage(type, data); |
376 } | 377 } |
377 return false; | 378 return false; |
378 }; | 379 }; |
379 | 380 |
380 /** | 381 /** |
381 * Create a session connector if one doesn't already exist. | 382 * Create a session connector if one doesn't already exist. |
382 */ | 383 */ |
383 remoting.ensureSessionConnector_ = function() { | 384 remoting.ensureSessionConnector_ = function() { |
384 if (!remoting.connector) { | 385 if (!remoting.connector) { |
385 remoting.connector = new remoting.SessionConnector( | 386 remoting.connector = remoting.SessionConnector.factory.createConnector( |
386 document.getElementById('video-container'), | 387 document.getElementById('video-container'), |
387 remoting.onConnected, | 388 remoting.onConnected, |
388 showConnectError_, remoting.onExtensionMessage); | 389 showConnectError_, remoting.onExtensionMessage); |
389 } | 390 } |
390 }; | 391 }; |
OLD | NEW |