com.vaadin.terminal.gwt.client.
Class BrowserInfo
java.lang.Object
com.vaadin.terminal.gwt.client.BrowserInfo
- extends Object
public class BrowserInfo
Class used to query information about web browser. Browser details are detected only once and those are stored in this singleton class.
Field Summary | |
---|---|
static String |
ENGINE_GECKO
|
static String |
ENGINE_PRESTO
|
static String |
ENGINE_TRIDENT
|
static String |
ENGINE_WEBKIT
|
Method Summary | |
---|---|
static BrowserInfo |
get()
Singleton method to get BrowserInfo object. |
int |
getBrowserMajorVersion()
Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome 4, 8 for Internet Explorer 8. |
int |
getBrowserMinorVersion()
Returns the browser minor version e.g., 5 for Firefox 3.5. |
static String |
getBrowserString()
|
String |
getCSSClass()
Returns a string representing the browser in use, for use in CSS classnames. |
Date |
getCurrentDate()
Returns the current date and time of the browser. |
int |
getDSTSavings()
Gets the difference in minutes between the browser's GMT timezone and DST. |
float |
getGeckoVersion()
Returns the Gecko version if the browser is Gecko based. |
float |
getIEVersion()
|
float |
getOperaVersion()
|
int |
getRawTimezoneOffset()
Gets the timezone offset from GMT in minutes, as reported by the browser AND adjusted to ignore daylight savings time. |
int |
getScreenHeight()
|
int |
getScreenWidth()
|
int |
getTimezoneOffset()
Get's the timezone offset from GMT in minutes, as reported by the browser. |
float |
getWebkitVersion()
Returns the WebKit version if the browser is WebKit based. |
boolean |
isAndroid()
Checks if the browser is run on Android |
boolean |
isAndroidWithBrokenScrollTop()
Tests if this is an Android devices with a broken scrollTop implementation |
boolean |
isBrowserVersionNewerOrEqual(int majorVersion,
int minorVersion)
Checks if the browser version is newer or equal to the given major+minor version. |
boolean |
isChrome()
|
boolean |
isDSTInEffect()
Determines whether daylight savings time (DST) is currently in effect in the region of the browser or not. |
boolean |
isFF2()
|
boolean |
isFF3()
|
boolean |
isFF4()
|
boolean |
isFirefox()
|
boolean |
isGecko()
|
boolean |
isIE()
|
boolean |
isIE6()
|
boolean |
isIE7()
|
boolean |
isIE8()
|
boolean |
isIE9()
|
boolean |
isIOS()
Checks if the browser is run on iOS |
boolean |
isIOS6()
Checks if the browser is run on iOS 6. |
boolean |
isOpera()
|
boolean |
isOpera10()
|
boolean |
isOpera11()
|
boolean |
isSafari()
|
boolean |
isSafari4()
|
boolean |
isTouchDevice()
|
boolean |
isWebkit()
|
boolean |
requiresTouchScrollDelegate()
Checks if the browser is capable of handling scrolling natively or if a touch scroll helper is needed for scrolling. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
ENGINE_GECKO
public static final String ENGINE_GECKO
See Also:
ENGINE_WEBKIT
public static final String ENGINE_WEBKIT
See Also:
ENGINE_PRESTO
public static final String ENGINE_PRESTO
See Also:
ENGINE_TRIDENT
public static final String ENGINE_TRIDENT
See Also:
Method Detail |
---|
get
public static BrowserInfo get()
- Returns:
- instance of BrowserInfo object
Singleton method to get BrowserInfo object.
getCSSClass
public String getCSSClass()
- Returns:
Returns a string representing the browser in use, for use in CSS classnames. The classnames will be space separated abbreviations, optionally with a version appended. Abbreviations: Firefox: ff Internet Explorer: ie Safari: sa Opera: op Browsers that CSS-wise behave like each other will get the same abbreviation (this usually depends on the rendering engine). This is quite simple at the moment, more heuristics will be added when needed. Examples: Internet Explorer 6: ".v-ie .v-ie6 .v-ie60", Firefox 3.0.4: ".v-ff .v-ff3 .v-ff30", Opera 9.60: ".v-op .v-op9 .v-op960", Opera 10.10: ".v-op .v-op10 .v-op1010"
isIE
public boolean isIE()
isFirefox
public boolean isFirefox()
isSafari
public boolean isSafari()
isSafari4
public boolean isSafari4()
isIE6
public boolean isIE6()
isIE7
public boolean isIE7()
isIE8
public boolean isIE8()
isIE9
public boolean isIE9()
isChrome
public boolean isChrome()
isGecko
public boolean isGecko()
isWebkit
public boolean isWebkit()
isFF2
public boolean isFF2()
isFF3
public boolean isFF3()
isFF4
public boolean isFF4()
getGeckoVersion
public float getGeckoVersion()
- Returns:
- The Gecko version or -1 if the browser is not Gecko based
Returns the Gecko version if the browser is Gecko based. The Gecko version for Firefox 2 is 1.8 and 1.9 for Firefox 3.
getWebkitVersion
public float getWebkitVersion()
- Returns:
- The WebKit version or -1 if the browser is not WebKit based
Returns the WebKit version if the browser is WebKit based. The WebKit version returned is the major version e.g., 523.
getIEVersion
public float getIEVersion()
getOperaVersion
public float getOperaVersion()
isOpera
public boolean isOpera()
isOpera10
public boolean isOpera10()
isOpera11
public boolean isOpera11()
getBrowserString
public static String getBrowserString()
getScreenWidth
public int getScreenWidth()
getScreenHeight
public int getScreenHeight()
getTimezoneOffset
public int getTimezoneOffset()
- Returns:
- offset to GMT in minutes
Get's the timezone offset from GMT in minutes, as reported by the browser. DST affects this value.
getRawTimezoneOffset
public int getRawTimezoneOffset()
- Returns:
- offset to GMT in minutes
Gets the timezone offset from GMT in minutes, as reported by the browser AND adjusted to ignore daylight savings time. DST does not affect this value.
getDSTSavings
public int getDSTSavings()
- Returns:
- the amount of minutes that the timezone shifts when DST is in effect
Gets the difference in minutes between the browser's GMT timezone and DST.
isDSTInEffect
public boolean isDSTInEffect()
- Returns:
- true if the browser resides at a location that currently is in DST
Determines whether daylight savings time (DST) is currently in effect in the region of the browser or not.
getCurrentDate
public Date getCurrentDate()
- Returns:
- the current date and time of the browser.
Returns the current date and time of the browser. This will not be entirely accurate due to varying network latencies, but should provide a close-enough value for most cases.
isTouchDevice
public boolean isTouchDevice()
- Returns:
- true if the browser runs on a touch based device.
isIOS
public boolean isIOS()
- Returns:
- true if the browser is run on iOS, false otherwise
Checks if the browser is run on iOS
isIOS6
public boolean isIOS6()
- Returns:
- true if the browser is run on iOS 6, false otherwise
Checks if the browser is run on iOS 6.
isAndroid
public boolean isAndroid()
- Returns:
- true if the browser is run on Android, false otherwise
Checks if the browser is run on Android
requiresTouchScrollDelegate
public boolean requiresTouchScrollDelegate()
- Returns:
- true if browser needs a touch scroll helper, false if the browser can handle scrolling natively
Checks if the browser is capable of handling scrolling natively or if a touch scroll helper is needed for scrolling.
isAndroidWithBrokenScrollTop
public boolean isAndroidWithBrokenScrollTop()
- Returns:
- true if scrollTop cannot be trusted on this device, false otherwise
Tests if this is an Android devices with a broken scrollTop implementation
getBrowserMajorVersion
public int getBrowserMajorVersion()
- Returns:
- The major version of the browser.
Returns the browser major version e.g., 3 for Firefox 3.5, 4 for Chrome 4, 8 for Internet Explorer 8.
Note that Internet Explorer 8 and newer will return the document mode so IE8 rendering as IE7 will return 7.
getBrowserMinorVersion
public int getBrowserMinorVersion()
- Returns:
- The minor version of the browser, or -1 if not known/parsed.
- See Also:
getBrowserMajorVersion()
Returns the browser minor version e.g., 5 for Firefox 3.5.
isBrowserVersionNewerOrEqual
public boolean isBrowserVersionNewerOrEqual(int majorVersion,
int minorVersion)
- Parameters:
majorVersion
- The major version to check forminorVersion
- The minor version to check for- Returns:
- true if the browser version is newer or equal to the given version
Checks if the browser version is newer or equal to the given major+minor version.