Allow only one bookmark to be added for multiple fast starring
[chromium-blink-merge.git] / chrome / browser / resources / chromeos / chromevox / common / platform_util.js
blobc1c67ed380704c5ab65be26fbfe44507c0d326d7
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 /**
6 * @fileoverview Utilities for working with platforms.
7 */
10 goog.provide('cvox.PlatformFilter');
11 goog.provide('cvox.PlatformUtil');
13 goog.require('cvox.ChromeVox');
15 /**
16 * @enum
18 cvox.PlatformFilter = {
19 NONE: 0,
20 WINDOWS: 1,
21 MAC: 2,
22 LINUX: 4,
23 WML: 7,
24 CHROMEOS: 8,
25 ANDROID: 16
29 /**
30 *Checks whether the given filter matches the current platform. An undefined
31 * filter always matches the current platform.
32 * @param {undefined|cvox.PlatformFilter|number} filter The filter.
33 * @return {boolean} Whether the filter matches the current platform.
35 cvox.PlatformUtil.matchesPlatform = function(filter) {
36 var uA = navigator.userAgent;
37 if (filter == undefined) {
38 return true;
39 } else if (uA.indexOf('Android') != -1) {
40 return (filter & cvox.PlatformFilter.ANDROID) != 0;
41 } else if (uA.indexOf('Win') != -1) {
42 return (filter & cvox.PlatformFilter.WINDOWS) != 0;
43 } else if (uA.indexOf('Mac') != -1) {
44 return (filter & cvox.PlatformFilter.MAC) != 0;
45 } else if (uA.indexOf('Linux') != -1) {
46 return (filter & cvox.PlatformFilter.LINUX) != 0;
47 } else if (uA.indexOf('CrOS') != -1) {
48 return (filter & cvox.PlatformFilter.CHROMEOS) != 0;
50 return false;