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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 remoting.generateXsrfToken = function() { | 522 remoting.generateXsrfToken = function() { |
| 523 var random = new Uint8Array(16); | 523 var random = new Uint8Array(16); |
| 524 window.crypto.getRandomValues(random); | 524 window.crypto.getRandomValues(random); |
| 525 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); | 525 var base64Token = window.btoa(String.fromCharCode.apply(null, random)); |
| 526 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); | 526 return base64Token.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, ''); |
| 527 }; | 527 }; |
| 528 | 528 |
| 529 /** | 529 /** |
| 530 * Tests whether we are running on Mac. | 530 * Tests whether we are running on Mac. |
| 531 * | 531 * |
| 532 * @return {bool} True if the platform is Mac. | 532 * @return {boolean} True if the platform is Mac. |
| 533 */ | 533 */ |
| 534 remoting.platformIsMac = function() { | 534 remoting.platformIsMac = function() { |
| 535 return navigator.platform.indexOf('Mac') != -1; | 535 return navigator.platform.indexOf('Mac') != -1; |
| 536 } | 536 } |
| 537 | 537 |
| 538 /** | 538 /** |
| 539 * Tests whether we are running on Windows. | 539 * Tests whether we are running on Windows. |
| 540 * | 540 * |
| 541 * @return {bool} True if the platform is Windows. | 541 * @return {boolean} True if the platform is Windows. |
| 542 */ | 542 */ |
| 543 remoting.platformIsWindows = function() { | 543 remoting.platformIsWindows = function() { |
| 544 return navigator.platform.indexOf('Win32') != -1; | 544 return navigator.platform.indexOf('Win32') != -1; |
| 545 } | 545 } |
| 546 | 546 |
| 547 /** | 547 /** |
| 548 * Tests whether we are running on Linux. | 548 * Tests whether we are running on Linux. |
| 549 * | 549 * |
| 550 * @return {bool} True if the platform is Linux. | 550 * @return {boolean} True if the platform is Linux. |
| 551 */ | 551 */ |
| 552 remoting.platformIsLinux = function() { | 552 remoting.platformIsLinux = function() { |
| 553 return (navigator.platform.indexOf('Linux') != -1) && | 553 return (navigator.platform.indexOf('Linux') != -1) && |
| 554 !remoting.platformIsChromeOS(); | 554 !remoting.platformIsChromeOS(); |
| 555 } | 555 } |
| 556 | 556 |
| 557 /** | 557 /** |
| 558 * Tests whether we are running on ChromeOS. | 558 * Tests whether we are running on ChromeOS. |
| 559 * | 559 * |
| 560 * @return {bool} True if the platform is ChromeOS. | 560 * @return {boolean} True if the platform is ChromeOS. |
| 561 */ | 561 */ |
| 562 remoting.platformIsChromeOS = function() { | 562 remoting.platformIsChromeOS = function() { |
| 563 return navigator.userAgent.match(/\bCrOS\b/); | 563 return navigator.userAgent.match(/\bCrOS\b/) != null; |
|
Wez
2014/08/05 00:42:27
Is this the preferred pattern, versus !!foo?
Jamie
2014/08/05 01:03:10
I don't think there's a consensus. I think I prefe
| |
| 564 } | 564 } |
| OLD | NEW |