Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: chrome/browser/resources/shared/js/cr.js

Issue 8695007: Replace TOUCH_UI condition in WebUI with dynamic flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tiny tweaks based on CR feedback Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 touchui build or not.
27 * @type {boolean}
28 */
29 const isTouch = /Touch/.test(navigator.userAgent);
30
31 /**
32 * Whether this is on vanilla Linux (not chromeOS). 26 * Whether this is on vanilla Linux (not chromeOS).
33 * @type {boolean} 27 * @type {boolean}
34 */ 28 */
35 const isLinux = /Linux/.test(navigator.userAgent); 29 const isLinux = /Linux/.test(navigator.userAgent);
36 30
37 /** 31 /**
38 * Whether this uses GTK or not. 32 * Whether this uses GTK or not.
39 * @type {boolean} 33 * @type {boolean}
40 */ 34 */
41 const isGTK = /GTK/.test(chrome.toolkit); 35 const isGTK = /GTK/.test(chrome.toolkit);
42 36
43 /** 37 /**
44 * Whether this uses the views toolkit or not. 38 * Whether this uses the views toolkit or not.
45 * @type {boolean} 39 * @type {boolean}
46 */ 40 */
47 const isViews = /views/.test(chrome.toolkit); 41 const isViews = /views/.test(chrome.toolkit);
48 42
49 /** 43 /**
44 * Whether this window is optimized for touch-based input.
45 * @type {boolean}
46 */
47 const isTouchOptimized = !!chrome.touchOptimized;
48
49 /**
50 * Sets the os and toolkit attributes in the <html> element so that platform 50 * Sets the os and toolkit attributes in the <html> element so that platform
51 * specific css rules can be applied. 51 * specific css rules can be applied.
52 */ 52 */
53 function enablePlatformSpecificCSSRules() { 53 function enablePlatformSpecificCSSRules() {
54 if (isMac) 54 if (isMac)
55 doc.documentElement.setAttribute('os', 'mac'); 55 doc.documentElement.setAttribute('os', 'mac');
56 if (isWindows) 56 if (isWindows)
57 doc.documentElement.setAttribute('os', 'windows'); 57 doc.documentElement.setAttribute('os', 'windows');
58 if (isChromeOS) 58 if (isChromeOS)
59 doc.documentElement.setAttribute('os', 'chromeos'); 59 doc.documentElement.setAttribute('os', 'chromeos');
60 if (isLinux) 60 if (isLinux)
61 doc.documentElement.setAttribute('os', 'linux'); 61 doc.documentElement.setAttribute('os', 'linux');
62 if (isGTK) 62 if (isGTK)
63 doc.documentElement.setAttribute('toolkit', 'gtk'); 63 doc.documentElement.setAttribute('toolkit', 'gtk');
64 if (isViews) 64 if (isViews)
65 doc.documentElement.setAttribute('toolkit', 'views'); 65 doc.documentElement.setAttribute('toolkit', 'views');
66 if (isTouchOptimized)
67 doc.documentElement.setAttribute('touch-optimized', '');
66 } 68 }
67 69
68 /** 70 /**
69 * Builds an object structure for the provided namespace path, 71 * Builds an object structure for the provided namespace path,
70 * ensuring that names that already exist are not overwritten. For 72 * ensuring that names that already exist are not overwritten. For
71 * example: 73 * example:
72 * "a.b.c" -> a = {};a.b={};a.b.c={}; 74 * "a.b.c" -> a = {};a.b={};a.b.c={};
73 * @param {string} name Name of the object that this file defines. 75 * @param {string} name Name of the object that this file defines.
74 * @param {*=} opt_object The object to expose at the end of the path. 76 * @param {*=} opt_object The object to expose at the end of the path.
75 * @param {Object=} opt_objectToExportTo The object to add the path to; 77 * @param {Object=} opt_objectToExportTo The object to add the path to;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 }; 367 };
366 } 368 }
367 369
368 return { 370 return {
369 addSingletonGetter: addSingletonGetter, 371 addSingletonGetter: addSingletonGetter,
370 isChromeOS: isChromeOS, 372 isChromeOS: isChromeOS,
371 isMac: isMac, 373 isMac: isMac,
372 isWindows: isWindows, 374 isWindows: isWindows,
373 isLinux: isLinux, 375 isLinux: isLinux,
374 isViews: isViews, 376 isViews: isViews,
375 isTouch: isTouch, 377 isTouchOptimized: isTouchOptimized,
376 enablePlatformSpecificCSSRules: enablePlatformSpecificCSSRules, 378 enablePlatformSpecificCSSRules: enablePlatformSpecificCSSRules,
377 define: define, 379 define: define,
378 defineProperty: defineProperty, 380 defineProperty: defineProperty,
379 PropertyKind: PropertyKind, 381 PropertyKind: PropertyKind,
380 createUid: createUid, 382 createUid: createUid,
381 getUid: getUid, 383 getUid: getUid,
382 dispatchSimpleEvent: dispatchSimpleEvent, 384 dispatchSimpleEvent: dispatchSimpleEvent,
383 dispatchPropertyChange: dispatchPropertyChange, 385 dispatchPropertyChange: dispatchPropertyChange,
384 386
385 /** 387 /**
386 * The document that we are currently using. 388 * The document that we are currently using.
387 * @type {!Document} 389 * @type {!Document}
388 */ 390 */
389 get doc() { 391 get doc() {
390 return doc; 392 return doc;
391 }, 393 },
392 withDoc: withDoc, 394 withDoc: withDoc,
393 Event: CrEvent 395 Event: CrEvent
394 }; 396 };
395 })(); 397 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/options_page.css ('k') | chrome/browser/resources/shared/js/cr/ui/card_slider.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698