Class EngineOptions

java.lang.Object
com.teamdev.jxbrowser.engine.EngineOptions

public final class EngineOptions extends Object
The options that are used to configure Engine instances.
  • Method Details

    • newBuilder

      public static EngineOptions.Builder newBuilder(RenderingMode renderingMode)
      Creates a new EngineOptions builder.
      Parameters:
      renderingMode - the rendering mode that indicates how the content of the web pages will be rendered
    • userDataDir

      public Path userDataDir()
      Returns an absolute path to the directory where the user data is stored.

      The user data directory stores the data such as cache, cookies, history, GPU cache, local storage, visited links, web data, spell checking dictionary files, etc.

      Important: the user data directory cannot be used at the same time by multiple Engine instances running in a single or different applications.

    • chromiumDir

      public Path chromiumDir()
      Returns an absolute path to the directory where Chromium binaries are located or the empty string if it was not set.

      If the directory contains the Chromium binaries, the library will check them and make sure that they are compatible with the current library version. If the directory does not contain the Chromium binaries, or the binaries aren't compatible with the current library version, the library will search for the binaries inside the JAR files from the application classpath and extract them into the given directory programmatically. It might take some time to extract the Chromium binaries from a JAR archive. The time depends on the hardware (CPU and SSD/HDD) performance.

    • licenseKey

      public Optional<String> licenseKey()
      Returns an Optional that contains a string representing the license key or an empty Optional if the license key was not set.

      The license key can be set via the "jxbrowser.license.key" system property or individually for every Engine using the EngineOptions.Builder.licenseKey(String) method.

    • userAgent

      public Optional<String> userAgent()
      Returns an Optional that contains a string that is used to override the default user agent or an empty Optional if the custom user agent string was not set.
    • googleApiKey

      public Optional<String> googleApiKey()
      Returns an Optional that contains a string representing the Google API key or an empty Optional if the Google API key was not set.

      Some Chromium features such as Geolocation, Spelling, Speech, etc. use Google APIs, and to access those APIs, an API Key, OAuth 2.0 client ID, and client secret are required. Setting up API keys is optional. If you do not do it, the specific APIs using Google services won't work.

    • googleDefaultClientId

      public Optional<String> googleDefaultClientId()
      Returns an Optional that contains a string representing the Google client ID or an empty Optional if the Google client ID was not set.

      Some Chromium features such as Geolocation, Spelling, Speech, etc. use Google APIs, and to access those APIs, an API Key, OAuth 2.0 client ID, and client secret are required. Setting up API keys is optional. If you do not do it, the specific APIs using Google services won't work.

    • googleDefaultClientSecret

      public Optional<String> googleDefaultClientSecret()
      Returns an Optional that contains a string representing the Google client secret or an empty Optional if the Google client secret was not set.

      Some Chromium features such as Geolocation, Spelling, Speech, etc. use Google APIs, and to access those APIs, an API Key, OAuth 2.0 client ID, and client secret are required. Setting up API keys is optional. If you do not do it, the specific APIs using Google services won't work.

    • renderingMode

      public RenderingMode renderingMode()
      Returns the rendering mode indicating how the content of the web pages will be rendered.
    • language

      public Language language()
      Returns the Chromium language that is used on the default error pages and message dialogs.

      By default, the language is dynamically configured according to the default locale of the application. If the list of supported languages does not contain the language obtained from the application locale, then the US English language is used. The current option allows you to override the default behavior and configure the Chromium engine with the given language.

    • remoteDebuggingPort

      public Optional<Integer> remoteDebuggingPort()
      Returns an Optional that contains the number representing the remote debugging port or an empty Optional if the remote debugging port was not set.

      This option enables remote debugging over HTTP at the specific port. When remote debugging is enabled, you can navigate to the http://localhost:<port> address from another Browser instance or from the Google Chrome browser and debug the loaded web pages using Chrome DevTools. If you use Google Chrome browser for remote debugging, its version must be equal to the Chromium engine version that is used in JxBrowser.

    • rendererHangTimeout

      public Duration rendererHangTimeout()
      Returns how many seconds JavaScript can block the page before it is considered hanged.

      By default, it can block for 15 seconds.

      See Also:
    • passwordStore

      public Optional<PasswordStore> passwordStore()
      Returns an Optional that contains the password store type or an empty Optional if the password store type was not set. The password store type specifies which storage backend should be used to encrypt cookies on Linux.

      If the password store type was not set, then the encryption storage backend is chosen by Chromium engine automatically.

    • diskCacheSize

      public Optional<Long> diskCacheSize()
      Returns an Optional that contains the disk cache size in bytes or an empty Optional if the disk cache size was not set.

      If the disk cache size was not set, then it will be calculated automatically. The size depends on the available disk space in the volume where the disk cache is located.

    • isIncognitoEnabled

      public boolean isIncognitoEnabled()
      Indicates whether the default profile of the Engine instance is incognito.

      In the incognito mode the user data such as browsing history, cookies, site data, and the information entered in forms are stored in memory and released once you close the Engine.

    • isMediaRoutingEnabled

      public boolean isMediaRoutingEnabled()
      Indicates whether media routing is enabled for the Engine instance.

      By default, it is disabled.

      Since:
      7.29
    • isSandboxDisabled

      public boolean isSandboxDisabled()
      Indicates whether the sandbox is disabled.
    • isWebSecurityDisabled

      public boolean isWebSecurityDisabled()
      Indicates whether the same-origin policy is disabled.
    • isFileAccessFromFilesAllowed

      public boolean isFileAccessFromFilesAllowed()
      Indicates whether file access from files is allowed.
    • isAutoplayEnabled

      public boolean isAutoplayEnabled()
      Indicates whether video playback will automatically start after page loading.
    • isGpuDisabled

      public boolean isGpuDisabled()
      Indicates whether GPU is disabled.
    • isDnsQuickCheckDisabled

      public boolean isDnsQuickCheckDisabled()
      Indicates whether DNS Quick Check is disabled in proxy resolution.

      By default, it is enabled.

      This is a performance optimization for WPAD (Web Proxy Auto-Discovery) which places a 1-second timeout on resolving the DNS for PAC script URLs.

      For instance, if the DNS resolution for WPAD takes longer than 1 second, auto-detection will give up and fallback to the next proxy configuration (which could be manually configured proxy server rules, or an implicit fallback to ProxyType.DIRECT connections).

      Since:
      7.29
    • isTouchMenuDisabled

      public boolean isTouchMenuDisabled()
      Indicates whether touch popup menu is disabled.
      Since:
      7.1
    • isChromiumTrafficDisabled

      public boolean isChromiumTrafficDisabled()
      Indicates whether Chromium services that cause additional traffic are disabled.
      Since:
      7.10
    • isProprietaryFeatureEnabled

      public boolean isProprietaryFeatureEnabled(ProprietaryFeature feature)
      Indicates whether the given proprietary feature is enabled.

      By default, all the proprietary features are disabled.

      Parameters:
      feature - an instance of ProprietaryFeature representing the feature to check
      Since:
      7.4
    • proprietaryFeatures

      public Set<ProprietaryFeature> proprietaryFeatures()
      Returns a set of enabled proprietary features.
      Since:
      7.8
    • secureOriginWhiteList

      public List<String> secureOriginWhiteList()
      Returns an immutable list of the insecure origins that will be treated as secure.
      Since:
      7.2
    • switches

      public List<String> switches()
      Returns an immutable list of the Chromium switches that will be passed to the Chromium Main process.

      The library does not support all the possible Chromium switches, so there is no guarantee that the passed switches will work. The switches from this list will overwrite the corresponding options configured through the EngineOptions.Builder.

      For example, if you configure the remote debugging port using the EngineOptions.Builder.remoteDebuggingPort(int) method and then add the --remote-debugging-port switch using the EngineOptions.Builder.addSwitch(String) method, then the port from the switch will be used.

    • schemes

      Returns an immutable map of the schemes that will be intercepted.