diff --git a/remoting/remoting_webapp_files.gypi b/remoting/remoting_webapp_files.gypi index c94108309a03..6ab3afe25dff 100644 --- a/remoting/remoting_webapp_files.gypi +++ b/remoting/remoting_webapp_files.gypi @@ -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', diff --git a/remoting/webapp/platform.js b/remoting/webapp/platform.js new file mode 100644 index 000000000000..ab01cc7443cc --- /dev/null +++ b/remoting/webapp/platform.js @@ -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/); +} diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js index 249d49a2ff6e..037921ce4b7b 100644 --- a/remoting/webapp/remoting.js +++ b/remoting/webapp/remoting.js @@ -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 @@ -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. *