Package com.vaadin.flow.server
Class WebBrowser
java.lang.Object
com.vaadin.flow.server.WebBrowser
- All Implemented Interfaces:
Serializable
Provides information about the web browser the user is using that is directly
available in the request, for instance browser name and version and IP
address.
Note! browser details rely on the user agent from the browser and thus the
details are not always correct.
- Since:
- 1.0.
- Author:
- Vaadin Ltd
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionGets the IP-address of the web browser, if available.Get the browser user-agent string.int
Gets the major version of the browser the user is using.int
Gets the minor version of the browser the user is using.Gets the locale reported by the browser.boolean
Tests if the browser is run on Android.boolean
isChrome()
Tests whether the user is using Chrome.boolean
Tests if the browser is run on ChromeOS (e.g.boolean
isEdge()
Tests whether the user is using Edge.boolean
Tests whether the user is using Firefox.boolean
isIE()
Tests whether the user is using Internet Explorer.boolean
isIPhone()
Tests if the browser is run on IPhone.boolean
isLinux()
Tests whether the user is using Linux.boolean
isMacOSX()
Tests whether the user is using Mac OS X.boolean
isOpera()
Tests whether the user is using Opera.boolean
isSafari()
Tests whether the user is using Safari.boolean
Checks if the connection was established using HTTPS.boolean
Tests whether the user is using Windows.boolean
Tests whether the user is using Windows Phone.
-
Method Details
-
getBrowserApplication
Get the browser user-agent string.- Returns:
- The raw browser userAgent string
-
getAddress
Gets the IP-address of the web browser, if available.- Returns:
- IP-address in 1.12.123.123 -format or null if the address is not available
-
getLocale
Gets the locale reported by the browser.- Returns:
- the browser reported locale
-
isSecureConnection
public boolean isSecureConnection()Checks if the connection was established using HTTPS.- Returns:
- true if HTTPS was used, false otherwise
-
isFirefox
public boolean isFirefox()Tests whether the user is using Firefox.- Returns:
- true if the user is using Firefox, false if the user is not using Firefox or if no information on the browser is present
-
isIE
public boolean isIE()Tests whether the user is using Internet Explorer.- Returns:
- true if the user is using Internet Explorer, false if the user is not using Internet Explorer or if no information on the browser is present
-
isEdge
public boolean isEdge()Tests whether the user is using Edge.- Returns:
- true if the user is using Edge, false if the user is not using Edge or if no information on the browser is present
-
isSafari
public boolean isSafari()Tests whether the user is using Safari. Note that Chrome on iOS is not detected as Safari but as Chrome although the underlying browser engine is the same.- Returns:
- true if the user is using Safari, false if the user is not using Safari or if no information on the browser is present
-
isOpera
public boolean isOpera()Tests whether the user is using Opera.- Returns:
- true if the user is using Opera, false if the user is not using Opera or if no information on the browser is present
-
isChrome
public boolean isChrome()Tests whether the user is using Chrome.- Returns:
- true if the user is using Chrome, false if the user is not using Chrome or if no information on the browser is present
-
getBrowserMajorVersion
public int getBrowserMajorVersion()Gets the major version of the browser the user is using.Note that Internet Explorer in IE7 compatibility mode might return 8 in some cases even though it should return 7.
- Returns:
- The major version of the browser or -1 if not known.
-
getBrowserMinorVersion
public int getBrowserMinorVersion()Gets the minor version of the browser the user is using.- Returns:
- The minor version of the browser or -1 if not known.
- See Also:
-
isLinux
public boolean isLinux()Tests whether the user is using Linux.- Returns:
- true if the user is using Linux, false if the user is not using Linux or if no information on the browser is present
-
isMacOSX
public boolean isMacOSX()Tests whether the user is using Mac OS X.- Returns:
- true if the user is using Mac OS X, false if the user is not using Mac OS X or if no information on the browser is present
-
isWindows
public boolean isWindows()Tests whether the user is using Windows.- Returns:
- true if the user is using Windows, false if the user is not using Windows or if no information on the browser is present
-
isWindowsPhone
public boolean isWindowsPhone()Tests whether the user is using Windows Phone.- Returns:
- true if the user is using Windows Phone, false if the user is not using Windows Phone or if no information on the browser is present
-
isAndroid
public boolean isAndroid()Tests if the browser is run on Android.- Returns:
- true if run on Android false if the user is not using Android or if no information on the browser is present
-
isIPhone
public boolean isIPhone()Tests if the browser is run on IPhone.- Returns:
- true if run on IPhone false if the user is not using IPhone or if no information on the browser is present
-
isChromeOS
public boolean isChromeOS()Tests if the browser is run on ChromeOS (e.g. a Chromebook).- Returns:
- true if run on ChromeOS false if the user is not using ChromeOS or if no information on the browser is present
-