Skip to content

Commit

Permalink
[Chromoting] Extract platform checks into platform.js
Browse files Browse the repository at this point in the history
BUG=

Review URL: https://codereview.chromium.org/618923002

Cr-Commit-Position: refs/heads/master@{#297953}
  • Loading branch information
garykac authored and Commit bot committed Oct 3, 2014
1 parent 344272d commit aafd656
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 21 deletions.
1 change: 1 addition & 0 deletions remoting/remoting_webapp_files.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
'webapp/base.js',
'webapp/error.js',
'webapp/event_handlers.js',
'webapp/platform.js',
'webapp/plugin_settings.js',
# TODO(garykac) Split out UI client stuff from remoting.js.
'webapp/remoting.js',
Expand Down
41 changes: 41 additions & 0 deletions remoting/webapp/platform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

'use strict';

/** @suppress {duplicate} */
var remoting = remoting || {};

/**
* Returns full Chrome version.
* @return {string?}
*/
remoting.getChromeVersion = function() {
var match = new RegExp('Chrome/([0-9.]*)').exec(navigator.userAgent);
if (match && (match.length >= 2)) {
return match[1];
}
return null;
};

/**
* Returns Chrome major version.
* @return {number}
*/
remoting.getChromeMajorVersion = function() {
var match = new RegExp('Chrome/([0-9]+)\.').exec(navigator.userAgent);
if (match && (match.length >= 2)) {
return parseInt(match[1], 10);
}
return 0;
};

/**
* Returns whether the app is running on ChromeOS.
*
* @return {boolean} True if the app is running on ChromeOS.
*/
remoting.runningOnChromeOS = function() {
return !!navigator.userAgent.match(/\bCrOS\b/);
}
21 changes: 0 additions & 21 deletions remoting/webapp/remoting.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,18 +336,6 @@ remoting.getExtensionInfo = function() {
}
};

/**
* Returns Chrome version.
* @return {string?}
*/
remoting.getChromeVersion = function() {
var match = new RegExp('Chrome/([0-9.]*)').exec(navigator.userAgent);
if (match && (match.length >= 2)) {
return match[1];
}
return null;
};

/**
* If an IT2Me client or host is active then prompt the user before closing.
* If a Me2Me client is active then don't bother, since closing the window is
Expand Down Expand Up @@ -383,15 +371,6 @@ remoting.signOut = function() {
document.getElementById('auth-dialog').hidden = false;
};

/**
* Returns whether the app is running on ChromeOS.
*
* @return {boolean} True if the app is running on ChromeOS.
*/
remoting.runningOnChromeOS = function() {
return !!navigator.userAgent.match(/\bCrOS\b/);
}

/**
* Callback function called when the browser window gets a paste operation.
*
Expand Down

0 comments on commit aafd656

Please sign in to comment.