summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorgarykac <garykac@chromium.org>2014-10-02 16:58:17 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-03 00:00:25 +0000
commitaafd6568093135c579f18fe4db9006e622dd1214 (patch)
treeffdde4aaee0bf014fdc5e6ed72cc8ca40752d78f /remoting
parent344272ddd4ca47fb56fd6a1ca6a4f1418df2c426 (diff)
downloadchromium_src-aafd6568093135c579f18fe4db9006e622dd1214.zip
chromium_src-aafd6568093135c579f18fe4db9006e622dd1214.tar.gz
chromium_src-aafd6568093135c579f18fe4db9006e622dd1214.tar.bz2
[Chromoting] Extract platform checks into platform.js
BUG= Review URL: https://codereview.chromium.org/618923002 Cr-Commit-Position: refs/heads/master@{#297953}
Diffstat (limited to 'remoting')
-rw-r--r--remoting/remoting_webapp_files.gypi1
-rw-r--r--remoting/webapp/platform.js41
-rw-r--r--remoting/webapp/remoting.js21
3 files changed, 42 insertions, 21 deletions
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