| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(jacobr): cache these results. | 5 // TODO(jacobr): cache these results. |
| 6 // TODO(jacobr): figure out how to test this. | 6 // TODO(jacobr): figure out how to test this. |
| 7 /** | 7 /** |
| 8 * Utils for device detection. | 8 * Utils for device detection. |
| 9 */ | 9 */ |
| 10 class Device { | 10 class Device { |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * The regular expression for detecting an iPhone or iPod. | 13 * The regular expression for detecting an iPhone or iPod. |
| 14 */ | 14 */ |
| 15 static final _IPHONE_REGEX = new RegExp('iPhone|iPod'); | 15 static const _IPHONE_REGEX = const RegExp('iPhone|iPod'); |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * The regular expression for detecting an iPhone or iPod or iPad. | 18 * The regular expression for detecting an iPhone or iPod or iPad. |
| 19 */ | 19 */ |
| 20 static final _MOBILE_SAFARI_REGEX = new RegExp('iPhone|iPod|iPad'); | 20 static const _MOBILE_SAFARI_REGEX = const RegExp('iPhone|iPod|iPad'); |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * The regular expression for detecting an iPhone or iPod or iPad simulator. | 23 * The regular expression for detecting an iPhone or iPod or iPad simulator. |
| 24 */ | 24 */ |
| 25 static final _APPLE_SIM_REGEX = new RegExp('iP.*Simulator'); | 25 static const _APPLE_SIM_REGEX = const RegExp('iP.*Simulator'); |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * Gets the browser's user agent. Using this function allows tests to inject | 28 * Gets the browser's user agent. Using this function allows tests to inject |
| 29 * the user agent. | 29 * the user agent. |
| 30 * Returns the user agent. | 30 * Returns the user agent. |
| 31 */ | 31 */ |
| 32 static String get userAgent => window.navigator.userAgent; | 32 static String get userAgent => window.navigator.userAgent; |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * Determines if the current device is an iPhone or iPod. | 35 * Determines if the current device is an iPhone or iPod. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 static bool get isWebOs => userAgent.contains("webOS", 0); | 73 static bool get isWebOs => userAgent.contains("webOS", 0); |
| 74 | 74 |
| 75 static bool _supportsTouch; | 75 static bool _supportsTouch; |
| 76 static bool get supportsTouch { | 76 static bool get supportsTouch { |
| 77 if (_supportsTouch == null) { | 77 if (_supportsTouch == null) { |
| 78 _supportsTouch = isMobileSafari || isAndroid; | 78 _supportsTouch = isMobileSafari || isAndroid; |
| 79 } | 79 } |
| 80 return _supportsTouch; | 80 return _supportsTouch; |
| 81 } | 81 } |
| 82 } | 82 } |
| OLD | NEW |