Class WebBrowser

java.lang.Object
com.vaadin.flow.server.WebBrowser
All Implemented Interfaces:
Serializable

public class WebBrowser extends Object implements 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 Details

    • getUserAgent

      public String getUserAgent()
      Get the User-Agent header for handling. Could be used with ua-parser/uap-java for instance.
      Returns:
      request User-Agent header
    • getBrowserApplication

      @Deprecated(since="25.0") public String getBrowserApplication()
      Deprecated.
      use getUserAgent() method to get user-agent string
      Get the browser user-agent string.
      Returns:
      The raw browser userAgent string
    • getAddress

      public 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

      public Locale 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

      @Deprecated(since="25.0") public boolean isFirefox()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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

      @Deprecated(since="25.0") public boolean isIE()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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

      @Deprecated(since="25.0") public boolean isEdge()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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

      @Deprecated(since="25.0") public boolean isSafari()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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

      @Deprecated(since="25.0") public boolean isOpera()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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

      @Deprecated(since="25.0") public boolean isChrome()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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

      @Deprecated(since="25.0") public int getBrowserMajorVersion()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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

      @Deprecated(since="25.0") public int getBrowserMinorVersion()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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

      @Deprecated(since="25.0") public boolean isLinux()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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

      @Deprecated(since="25.0") public boolean isMacOSX()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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

      @Deprecated(since="25.0") public boolean isWindows()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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

      @Deprecated(since="25.0") public boolean isWindowsPhone()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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

      @Deprecated(since="25.0") public boolean isAndroid()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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

      @Deprecated(since="25.0") public boolean isChromeOS()
      Deprecated.
      use a parsing library like ua-parser/uap-java to parse the user agent from getUserAgent()
      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