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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 | 166 |
| 167 // Verify if the plugin was loaded successfully. | 167 // Verify if the plugin was loaded successfully. |
| 168 if (!plugin.hasOwnProperty('REQUESTED_ACCESS_CODE')) { | 168 if (!plugin.hasOwnProperty('REQUESTED_ACCESS_CODE')) { |
| 169 container.removeChild(plugin); | 169 container.removeChild(plugin); |
| 170 return null; | 170 return null; |
| 171 } | 171 } |
| 172 | 172 |
| 173 return /** @type {remoting.HostPlugin} */ (plugin); | 173 return /** @type {remoting.HostPlugin} */ (plugin); |
| 174 }; | 174 }; |
| 175 | 175 |
| 176 // TODO(sergeyu): We want to show Me2Me host controls only on some Linux | |
| 177 // distributions that we know work properly with the chromoting host. Implement | |
| 178 // dome detection mechanism and apply it here. | |
| 179 /** @type {boolean} */ | |
| 180 remoting.supportedLinuxDistibutionDetected_ = false; | |
| 181 | |
| 182 /** | 176 /** |
| 177 * Returns true if the current platform is fully supported. It's only used when | |
| 178 * we detect that host native messaging components are not installed. In that | |
| 179 * case the result of this function determines if the webapp should show the | |
| 180 * controls that allow to install and enable Me2Me host. | |
|
Jamie
2014/02/12 23:00:12
You've changed the semantics of this methods witho
Sergey Ulanov
2014/02/13 00:44:11
Done.
| |
| 181 * | |
| 183 * @return {boolean} | 182 * @return {boolean} |
| 184 */ | 183 */ |
| 185 remoting.isMe2MeSupported = function isMe2MeSupported() { | 184 remoting.isMe2MeSupported = function isMe2MeSupported() { |
| 186 /** @type {string} */ | 185 /** @type {string} */ |
| 187 var platform = navigator.platform; | 186 var platform = navigator.platform; |
| 188 | 187 return platform == 'Win32' || platform == 'MacIntel'; |
| 189 // Currently Me2Me is supported on Windows, OSX and some versions of Linux. | |
| 190 return platform == 'Win32' || platform == 'MacIntel' || | |
| 191 ((platform == 'Linux x86_64' || platform == 'Linux i386') && | |
| 192 remoting.supportedLinuxDistibutionDetected_ && | |
| 193 !remoting.runningOnChromeOS()); | |
| 194 } | 188 } |
| 195 | 189 |
| 196 /** | 190 /** |
| 197 * Display the user's email address and allow access to the rest of the app, | 191 * Display the user's email address and allow access to the rest of the app, |
| 198 * including parsing URL parameters. | 192 * including parsing URL parameters. |
| 199 * | 193 * |
| 200 * @param {string} email The user's email address. | 194 * @param {string} email The user's email address. |
| 201 * @return {void} Nothing. | 195 * @return {void} Nothing. |
| 202 */ | 196 */ |
| 203 remoting.onEmail = function(email) { | 197 remoting.onEmail = function(email) { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 231 remoting.updateLocalHostState(); | 225 remoting.updateLocalHostState(); |
| 232 remoting.hostList.refresh(remoting.updateLocalHostState); | 226 remoting.hostList.refresh(remoting.updateLocalHostState); |
| 233 remoting.butterBar = new remoting.ButterBar(); | 227 remoting.butterBar = new remoting.ButterBar(); |
| 234 }; | 228 }; |
| 235 | 229 |
| 236 /** | 230 /** |
| 237 * Fetches local host state and updates the DOM accordingly. | 231 * Fetches local host state and updates the DOM accordingly. |
| 238 */ | 232 */ |
| 239 remoting.updateLocalHostState = function() { | 233 remoting.updateLocalHostState = function() { |
| 240 /** | 234 /** |
| 241 * @param {string?} hostId Host id. | 235 * @param {remoting.HostController.State} state Host state. |
| 242 */ | 236 */ |
| 243 var onHostId = function(hostId) { | 237 var onHostState = function(state) { |
| 244 remoting.hostController.getLocalHostState(onHostState.bind(null, hostId)); | 238 if (state == remoting.HostController.State.STARTED) { |
| 239 remoting.hostController.getLocalHostId(onHostId.bind(null, state)); | |
| 240 } else { | |
| 241 onHostId(state, null); | |
| 242 } | |
| 245 }; | 243 }; |
| 246 | 244 |
| 247 /** | 245 /** |
| 246 * @param {remoting.HostController.State} state Host state. | |
| 248 * @param {string?} hostId Host id. | 247 * @param {string?} hostId Host id. |
| 249 * @param {remoting.HostController.State} state Host state. | |
| 250 */ | 248 */ |
| 251 var onHostState = function(hostId, state) { | 249 var onHostId = function(state, hostId) { |
| 252 remoting.hostList.setLocalHostStateAndId(state, hostId); | 250 remoting.hostList.setLocalHostStateAndId(state, hostId); |
| 253 remoting.hostList.display(); | 251 remoting.hostList.display(); |
| 254 }; | 252 }; |
| 255 | 253 |
| 256 /** | 254 /** |
| 257 * @param {boolean} response True if the feature is present. | 255 * @param {boolean} response True if the feature is present. |
| 258 */ | 256 */ |
| 259 var onHasFeatureResponse = function(response) { | 257 var onHasFeatureResponse = function(response) { |
| 260 /** | 258 /** |
| 261 * @param {remoting.Error} error | 259 * @param {remoting.Error} error |
| 262 */ | 260 */ |
| 263 var onError = function(error) { | 261 var onError = function(error) { |
| 264 console.error('Failed to get pairing status: ' + error); | 262 console.error('Failed to get pairing status: ' + error); |
| 265 remoting.pairedClientManager.setPairedClients([]); | 263 remoting.pairedClientManager.setPairedClients([]); |
| 266 }; | 264 }; |
| 267 | 265 |
| 268 if (response) { | 266 if (response) { |
| 269 remoting.hostController.getPairedClients( | 267 remoting.hostController.getPairedClients( |
| 270 remoting.pairedClientManager.setPairedClients.bind( | 268 remoting.pairedClientManager.setPairedClients.bind( |
| 271 remoting.pairedClientManager), | 269 remoting.pairedClientManager), |
| 272 onError); | 270 onError); |
| 273 } else { | 271 } else { |
| 274 console.log('Pairing registry not supported by host.'); | 272 console.log('Pairing registry not supported by host.'); |
| 275 remoting.pairedClientManager.setPairedClients([]); | 273 remoting.pairedClientManager.setPairedClients([]); |
| 276 } | 274 } |
| 277 }; | 275 }; |
| 278 | 276 |
| 279 remoting.hostController.hasFeature( | 277 remoting.hostController.hasFeature( |
| 280 remoting.HostController.Feature.PAIRING_REGISTRY, onHasFeatureResponse); | 278 remoting.HostController.Feature.PAIRING_REGISTRY, onHasFeatureResponse); |
| 281 remoting.hostController.getLocalHostId(onHostId); | 279 remoting.hostController.getLocalHostState(onHostState); |
| 282 }; | 280 }; |
| 283 | 281 |
| 284 /** | 282 /** |
| 285 * Log information about the current extension. | 283 * Log information about the current extension. |
| 286 * The extension manifest is parsed to extract this info. | 284 * The extension manifest is parsed to extract this info. |
| 287 */ | 285 */ |
| 288 remoting.logExtensionInfo_ = function() { | 286 remoting.logExtensionInfo_ = function() { |
| 289 var v2OrLegacy = remoting.isAppsV2 ? " (v2)" : " (legacy)"; | 287 var v2OrLegacy = remoting.isAppsV2 ? " (v2)" : " (legacy)"; |
| 290 var manifest = chrome.runtime.getManifest(); | 288 var manifest = chrome.runtime.getManifest(); |
| 291 if (manifest && manifest.version) { | 289 if (manifest && manifest.version) { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 499 /** | 497 /** |
| 500 * Generate a nonce, to be used as an xsrf protection token. | 498 * Generate a nonce, to be used as an xsrf protection token. |
| 501 * | 499 * |
| 502 * @return {string} A URL-Safe Base64-encoded 128-bit random value. */ | 500 * @return {string} A URL-Safe Base64-encoded 128-bit random value. */ |
| 503 remoting.generateXsrfToken = function() { | 501 remoting.generateXsrfToken = function() { |
| 504 var random = new Uint8Array(16); | 502 var random = new Uint8Array(16); |
| 505 window.crypto.getRandomValues(random); | 503 window.crypto.getRandomValues(random); |
| 506 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); | 504 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); |
| 507 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); | 505 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); |
| 508 }; | 506 }; |
| OLD | NEW |