Chromium Code Reviews| 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 'host screen' for Chromoting. | 7 * Functions related to the 'host 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 {boolean} Whether or not the last share was cancelled by the user. | 16 * @type {boolean} Whether or not the last share was cancelled by the user. |
| 17 * This controls what screen is shown when the host plugin signals | 17 * This controls what screen is shown when the host plugin signals |
| 18 * completion. | 18 * completion. |
| 19 * @private | 19 * @private |
| 20 */ | 20 */ |
| 21 var lastShareWasCancelled_ = false; | 21 var lastShareWasCancelled_ = false; |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * Start a host session. This is the main entry point for the host screen, | 24 * Start a host session. This is the main entry point for the host screen, |
| 25 * called directly from the onclick action of a button on the home screen. | 25 * called directly from the onclick action of a button on the home screen. |
| 26 */ | 26 */ |
| 27 remoting.tryShare = function() { | 27 remoting.tryShare = function() { |
| 28 console.log('Attempting to share...'); | 28 console.log('Attempting to share...'); |
| 29 remoting.oauth2.callWithToken(remoting.tryShareWithToken_, | 29 remoting.identity.callWithToken(remoting.tryShareWithToken_, |
| 30 remoting.showErrorMessage); | 30 remoting.showErrorMessage); |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * @param {string} token The OAuth access token. | 34 * @param {string} token The OAuth access token. |
| 35 * @private | 35 * @private |
| 36 */ | 36 */ |
| 37 remoting.tryShareWithToken_ = function(token) { | 37 remoting.tryShareWithToken_ = function(token) { |
| 38 lastShareWasCancelled_ = false; | 38 lastShareWasCancelled_ = false; |
| 39 onNatTraversalPolicyChanged_(true); // Hide warning by default. | 39 onNatTraversalPolicyChanged_(true); // Hide warning by default. |
| 40 remoting.setMode(remoting.AppMode.HOST_WAITING_FOR_CODE); | 40 remoting.setMode(remoting.AppMode.HOST_WAITING_FOR_CODE); |
| 41 document.getElementById('cancel-share-button').disabled = false; | 41 document.getElementById('cancel-share-button').disabled = false; |
| 42 disableTimeoutCountdown_(); | 42 disableTimeoutCountdown_(); |
| 43 | 43 |
| 44 var div = document.getElementById('host-plugin-container'); | 44 var div = document.getElementById('host-plugin-container'); |
| 45 remoting.hostSession = new remoting.HostSession(); | 45 remoting.hostSession = new remoting.HostSession(); |
| 46 remoting.hostSession.createPluginAndConnect( | 46 remoting.hostSession.createPluginAndConnect( |
| 47 document.getElementById('host-plugin-container'), | 47 document.getElementById('host-plugin-container'), |
| 48 /** @type {string} */(remoting.oauth2.getCachedEmail()), | 48 /** @type {string} */(remoting.identity.getCachedEmail()), |
|
Wez
2013/01/05 00:04:24
nit: Do we still need this type annotation here?
Jamie
2013/01/05 01:32:54
Yes, getCachedEmail can return null if we're not a
| |
| 49 token, | 49 token, |
| 50 onNatTraversalPolicyChanged_, | 50 onNatTraversalPolicyChanged_, |
| 51 onHostStateChanged_, | 51 onHostStateChanged_, |
| 52 logDebugInfo_); | 52 logDebugInfo_); |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Callback for the host plugin to notify the web app of state changes. | 56 * Callback for the host plugin to notify the web app of state changes. |
| 57 * @param {remoting.HostSession.State} state The new state of the plugin. | 57 * @param {remoting.HostSession.State} state The new state of the plugin. |
| 58 */ | 58 */ |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 * @return {void} Nothing. | 267 * @return {void} Nothing. |
| 268 */ | 268 */ |
| 269 function onNatTraversalPolicyChanged_(enabled) { | 269 function onNatTraversalPolicyChanged_(enabled) { |
| 270 var natBox = document.getElementById('nat-box'); | 270 var natBox = document.getElementById('nat-box'); |
| 271 if (enabled) { | 271 if (enabled) { |
| 272 natBox.classList.add('traversal-enabled'); | 272 natBox.classList.add('traversal-enabled'); |
| 273 } else { | 273 } else { |
| 274 natBox.classList.remove('traversal-enabled'); | 274 natBox.classList.remove('traversal-enabled'); |
| 275 } | 275 } |
| 276 } | 276 } |
| OLD | NEW |