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.
6 * @fileoverview Utilities for working with platforms.
10 goog.provide('cvox.PlatformFilter');
11 goog.provide('cvox.PlatformUtil');
13 goog.require('cvox.ChromeVox');
18 cvox.PlatformFilter = {
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) {
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;