OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 const cr = (function() { | 5 const cr = (function() { |
6 | 6 |
7 /** | 7 /** |
8 * Whether we are using a Mac or not. | 8 * Whether we are using a Mac or not. |
9 * @type {boolean} | 9 * @type {boolean} |
10 */ | 10 */ |
11 const isMac = /Mac/.test(navigator.platform); | 11 const isMac = /Mac/.test(navigator.platform); |
12 | 12 |
13 /** | 13 /** |
14 * Whether this is on the Windows platform or not. | 14 * Whether this is on the Windows platform or not. |
15 * @type {boolean} | 15 * @type {boolean} |
16 */ | 16 */ |
17 const isWindows = /Win/.test(navigator.platform); | 17 const isWindows = /Win/.test(navigator.platform); |
18 | 18 |
19 /** | 19 /** |
20 * Whether this is on chromeOS or not. | 20 * Whether this is on chromeOS or not. |
21 * @type {boolean} | 21 * @type {boolean} |
22 */ | 22 */ |
23 const isChromeOS = /CrOS/.test(navigator.userAgent); | 23 const isChromeOS = /CrOS/.test(navigator.userAgent); |
24 | 24 |
25 /** | 25 /** |
| 26 * Whether this is on vanilla Linux (not chromeOS). |
| 27 * @type {boolean} |
| 28 */ |
| 29 const isLinux = /Linux/.test(navigator.userAgent); |
| 30 |
| 31 /** |
26 * Whether this uses the views toolkit or not. | 32 * Whether this uses the views toolkit or not. |
27 * @type {boolean} | 33 * @type {boolean} |
28 */ | 34 */ |
29 const isViews = isWindows || isChromeOS; | 35 const isViews = isWindows || isChromeOS; |
30 | 36 |
31 /** | 37 /** |
32 * Builds an object structure for the provided namespace path, | 38 * Builds an object structure for the provided namespace path, |
33 * ensuring that names that already exist are not overwritten. For | 39 * ensuring that names that already exist are not overwritten. For |
34 * example: | 40 * example: |
35 * "a.b.c" -> a = {};a.b={};a.b.c={}; | 41 * "a.b.c" -> a = {};a.b={};a.b.c={}; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 ctor.getInstance = function() { | 324 ctor.getInstance = function() { |
319 return ctor.instance_ || (ctor.instance_ = new ctor()); | 325 return ctor.instance_ || (ctor.instance_ = new ctor()); |
320 }; | 326 }; |
321 } | 327 } |
322 | 328 |
323 return { | 329 return { |
324 addSingletonGetter: addSingletonGetter, | 330 addSingletonGetter: addSingletonGetter, |
325 isChromeOS: isChromeOS, | 331 isChromeOS: isChromeOS, |
326 isMac: isMac, | 332 isMac: isMac, |
327 isWindows: isWindows, | 333 isWindows: isWindows, |
| 334 isLinux: isLinux, |
| 335 isViews: isViews, |
328 define: define, | 336 define: define, |
329 defineProperty: defineProperty, | 337 defineProperty: defineProperty, |
330 PropertyKind: PropertyKind, | 338 PropertyKind: PropertyKind, |
331 createUid: createUid, | 339 createUid: createUid, |
332 getUid: getUid, | 340 getUid: getUid, |
333 dispatchSimpleEvent: dispatchSimpleEvent, | 341 dispatchSimpleEvent: dispatchSimpleEvent, |
334 dispatchPropertyChange: dispatchPropertyChange, | 342 dispatchPropertyChange: dispatchPropertyChange, |
335 | 343 |
336 /** | 344 /** |
337 * The document that we are currently using. | 345 * The document that we are currently using. |
338 * @type {!Document} | 346 * @type {!Document} |
339 */ | 347 */ |
340 get doc() { | 348 get doc() { |
341 return doc; | 349 return doc; |
342 }, | 350 }, |
343 withDoc: withDoc, | 351 withDoc: withDoc, |
344 Event: CrEvent | 352 Event: CrEvent |
345 }; | 353 }; |
346 })(); | 354 })(); |
OLD | NEW |