| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 var manifest = chrome.runtime.getManifest(); | 319 var manifest = chrome.runtime.getManifest(); |
| 320 if (manifest && manifest.version) { | 320 if (manifest && manifest.version) { |
| 321 var name = chrome.i18n.getMessage('PRODUCT_NAME'); | 321 var name = chrome.i18n.getMessage('PRODUCT_NAME'); |
| 322 return name + ' version: ' + manifest.version + v2OrLegacy; | 322 return name + ' version: ' + manifest.version + v2OrLegacy; |
| 323 } else { | 323 } else { |
| 324 return 'Failed to get product version. Corrupt manifest?'; | 324 return 'Failed to get product version. Corrupt manifest?'; |
| 325 } | 325 } |
| 326 }; | 326 }; |
| 327 | 327 |
| 328 /** | 328 /** |
| 329 * Returns Chrome version. |
| 330 * @return {string?} |
| 331 */ |
| 332 remoting.getChromeVersion = function() { |
| 333 var match = new RegExp('Chrome/([0-9.]*)').exec(navigator.userAgent); |
| 334 if (match && (match.length >= 2)) { |
| 335 return match[1]; |
| 336 } |
| 337 return null; |
| 338 }; |
| 339 |
| 340 /** |
| 329 * If an IT2Me client or host is active then prompt the user before closing. | 341 * If an IT2Me client or host is active then prompt the user before closing. |
| 330 * If a Me2Me client is active then don't bother, since closing the window is | 342 * If a Me2Me client is active then don't bother, since closing the window is |
| 331 * the more intuitive way to end a Me2Me session, and re-connecting is easy. | 343 * the more intuitive way to end a Me2Me session, and re-connecting is easy. |
| 332 */ | 344 */ |
| 333 remoting.promptClose = function() { | 345 remoting.promptClose = function() { |
| 334 if (!remoting.clientSession || | 346 if (!remoting.clientSession || |
| 335 remoting.clientSession.getMode() == remoting.ClientSession.Mode.ME2ME) { | 347 remoting.clientSession.getMode() == remoting.ClientSession.Mode.ME2ME) { |
| 336 return null; | 348 return null; |
| 337 } | 349 } |
| 338 switch (remoting.currentMode) { | 350 switch (remoting.currentMode) { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 /** | 540 /** |
| 529 * Generate a nonce, to be used as an xsrf protection token. | 541 * Generate a nonce, to be used as an xsrf protection token. |
| 530 * | 542 * |
| 531 * @return {string} A URL-Safe Base64-encoded 128-bit random value. */ | 543 * @return {string} A URL-Safe Base64-encoded 128-bit random value. */ |
| 532 remoting.generateXsrfToken = function() { | 544 remoting.generateXsrfToken = function() { |
| 533 var random = new Uint8Array(16); | 545 var random = new Uint8Array(16); |
| 534 window.crypto.getRandomValues(random); | 546 window.crypto.getRandomValues(random); |
| 535 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); | 547 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); |
| 536 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); | 548 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); |
| 537 }; | 549 }; |
| OLD | NEW |