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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
| 8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
| 9 | 9 |
| 10 /** @type {remoting.HostSession} */ remoting.hostSession = null; | 10 /** @type {remoting.HostSession} */ remoting.hostSession = null; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 * @param {string} email The user's email address. | 118 * @param {string} email The user's email address. |
| 119 * @return {void} Nothing. | 119 * @return {void} Nothing. |
| 120 */ | 120 */ |
| 121 remoting.onEmail = function(email) { | 121 remoting.onEmail = function(email) { |
| 122 document.getElementById('current-email').innerText = email; | 122 document.getElementById('current-email').innerText = email; |
| 123 document.getElementById('get-started-it2me').disabled = false; | 123 document.getElementById('get-started-it2me').disabled = false; |
| 124 document.getElementById('get-started-me2me').disabled = false; | 124 document.getElementById('get-started-me2me').disabled = false; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 /** | 127 /** |
| 128 * Returns whether or not IT2Me is supported via the host NPAPI plugin. | |
| 129 * | |
| 130 * @return {boolean} | |
| 131 */ | |
| 132 function isIt2MeSupported_() { | |
|
Jamie
2013/05/07 19:39:23
Nit: IT should be capitalized.
Lambros
2013/05/07 21:59:32
Done.
| |
| 133 var container = document.getElementById('host-plugin-container'); | |
| 134 /** @type {remoting.HostPlugin} */ | |
| 135 var plugin = remoting.HostSession.createPlugin(); | |
| 136 container.appendChild(plugin); | |
| 137 var result = plugin.hasOwnProperty('REQUESTED_ACCESS_CODE'); | |
| 138 container.removeChild(plugin); | |
| 139 return result; | |
| 140 } | |
| 141 | |
| 142 /** | |
| 128 * initHomeScreenUi is called if the app is not starting up in session mode, | 143 * initHomeScreenUi is called if the app is not starting up in session mode, |
| 129 * and also if the user cancels pin entry or the connection in session mode. | 144 * and also if the user cancels pin entry or the connection in session mode. |
| 130 */ | 145 */ |
| 131 remoting.initHomeScreenUi = function() { | 146 remoting.initHomeScreenUi = function() { |
| 132 remoting.hostController = new remoting.HostController(); | 147 remoting.hostController = new remoting.HostController(); |
| 133 document.getElementById('share-button').disabled = | 148 document.getElementById('share-button').disabled = !isIt2MeSupported_(); |
| 134 !remoting.hostController.isPluginSupported(); | 149 |
| 135 remoting.setMode(remoting.AppMode.HOME); | 150 remoting.setMode(remoting.AppMode.HOME); |
| 136 if (!remoting.oauth2.isAuthenticated()) { | 151 if (!remoting.oauth2.isAuthenticated()) { |
| 137 document.getElementById('auth-dialog').hidden = false; | 152 document.getElementById('auth-dialog').hidden = false; |
| 138 } | 153 } |
| 139 remoting.hostSetupDialog = | 154 remoting.hostSetupDialog = |
| 140 new remoting.HostSetupDialog(remoting.hostController); | 155 new remoting.HostSetupDialog(remoting.hostController); |
| 141 // Display the cached host list, then asynchronously update and re-display it. | 156 // Display the cached host list, then asynchronously update and re-display it. |
| 142 remoting.updateLocalHostState(); | 157 remoting.updateLocalHostState(); |
| 143 remoting.hostList.refresh(remoting.updateLocalHostState); | 158 remoting.hostList.refresh(remoting.updateLocalHostState); |
| 144 remoting.initSurvey(); | 159 remoting.initSurvey(); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 /** | 401 /** |
| 387 * Generate a nonce, to be used as an xsrf protection token. | 402 * Generate a nonce, to be used as an xsrf protection token. |
| 388 * | 403 * |
| 389 * @return {string} A URL-Safe Base64-encoded 128-bit random value. */ | 404 * @return {string} A URL-Safe Base64-encoded 128-bit random value. */ |
| 390 remoting.generateXsrfToken = function() { | 405 remoting.generateXsrfToken = function() { |
| 391 var random = new Uint8Array(16); | 406 var random = new Uint8Array(16); |
| 392 window.crypto.getRandomValues(random); | 407 window.crypto.getRandomValues(random); |
| 393 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); | 408 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); |
| 394 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); | 409 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); |
| 395 }; | 410 }; |
| OLD | NEW |