From aafd6568093135c579f18fe4db9006e622dd1214 Mon Sep 17 00:00:00 2001 From: garykac Date: Thu, 2 Oct 2014 16:58:17 -0700 Subject: [Chromoting] Extract platform checks into platform.js BUG= Review URL: https://codereview.chromium.org/618923002 Cr-Commit-Position: refs/heads/master@{#297953} --- remoting/remoting_webapp_files.gypi | 1 + remoting/webapp/platform.js | 41 +++++++++++++++++++++++++++++++++++++ remoting/webapp/remoting.js | 21 ------------------- 3 files changed, 42 insertions(+), 21 deletions(-) create mode 100644 remoting/webapp/platform.js (limited to 'remoting') diff --git a/remoting/remoting_webapp_files.gypi b/remoting/remoting_webapp_files.gypi index c941083..6ab3afe 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 0000000..ab01cc7 --- /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 249d49a..037921c 100644 --- a/remoting/webapp/remoting.js +++ b/remoting/webapp/remoting.js @@ -337,18 +337,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 * the more intuitive way to end a Me2Me session, and re-connecting is easy. @@ -384,15 +372,6 @@ remoting.signOut = function() { }; /** - * 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. * * @param {Event} eventUncast -- cgit v1.1