public static final class EngineOptions.Builder
extends java.lang.Object
Builders are created by invoking EngineOptions.newBuilder(com.teamdev.jxbrowser.engine.RenderingMode)
. Each of the setter methods modifies the
state of the builder and returns the same instance. Builders are not thread-safe and should
not be used concurrently from multiple threads without external synchronization.
Modifier and Type | Method and Description |
---|---|
EngineOptions.Builder |
addSwitch(java.lang.String commandLineSwitch)
Adds the switch to the list of the switches that will be passed to the Chromium process.
|
EngineOptions.Builder |
allowFileAccessFromFiles()
Allows file access from files for the
Engine instance. |
EngineOptions |
build()
Creates an
EngineOptions instance. |
EngineOptions.Builder |
chromiumDir(java.nio.file.Path chromiumDir)
Sets the absolute path to the directory where Chromium binaries are located.
|
EngineOptions.Builder |
disableChromiumTraffic()
Disables Chromium services that cause additional traffic, such as Google Cloud Messaging,
Translate Ranker, Extensions Updater, Safe Browsing, etc.
|
EngineOptions.Builder |
disableGpu()
Disables GPU rendering for the
Engine instance. |
EngineOptions.Builder |
disableSandbox()
Disables the sandbox for the
Engine instance. |
EngineOptions.Builder |
disableTouchMenu()
Disables the touch popup menu for the
Engine instance. |
EngineOptions.Builder |
disableWebSecurity()
Disables the same-origin policy for the
Engine instance. |
EngineOptions.Builder |
diskCacheSize(long diskCacheSize)
Sets the disk cache size, in bytes.
|
EngineOptions.Builder |
enableAutoplay()
Allows automatically starting video and audio playbacks.
|
EngineOptions.Builder |
enableIncognito()
Enables the incognito mode for the
Engine instance. |
EngineOptions.Builder |
enableProprietaryFeature(ProprietaryFeature feature)
Enables the given proprietary feature for the
Engine instance. |
EngineOptions.Builder |
googleApiKey(java.lang.String googleApiKey)
Sets the Google API key.
|
EngineOptions.Builder |
googleDefaultClientId(java.lang.String googleDefaultClientId)
Sets the Google client ID.
|
EngineOptions.Builder |
googleDefaultClientSecret(java.lang.String googleDefaultClientSecret)
Sets the Google client secret.
|
EngineOptions.Builder |
language(Language language)
Sets the Chromium language that is used on the default error pages and the message
dialogs.
|
EngineOptions.Builder |
licenseKey(java.lang.String licenseKey)
Sets the licence key required to perform operations with the engine.
|
EngineOptions.Builder |
passwordStore(PasswordStore passwordStore)
Sets the password store type that specifies which storage backend to use to encrypt
cookies on Linux.
|
EngineOptions.Builder |
ppapiFlashPath(java.nio.file.Path ppapiFlashPath)
Sets the path to the PPAPI (Pepper) Flash.
|
EngineOptions.Builder |
ppapiFlashVersion(java.lang.String ppapiFlashVersion)
Sets the version of the PPAPI (Pepper) Flash.
|
EngineOptions.Builder |
remoteDebuggingPort(int remoteDebuggingPort)
Sets the remote debugging port.
|
EngineOptions.Builder |
treatInsecureOriginAsSecure(java.lang.String... origins)
Add the given
origins to the white list. |
EngineOptions.Builder |
userAgent(java.lang.String userAgent)
Sets the custom user agent string that is used to override the default user agent for the
Engine . |
EngineOptions.Builder |
userDataDir(java.nio.file.Path userDataDir)
Sets the absolute path to the directory where the user data is stored.
|
public EngineOptions.Builder userDataDir(java.nio.file.Path userDataDir)
If the directory with the given path does not exist, then the library will create this directory.
Types of stored data are 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.
public EngineOptions.Builder chromiumDir(java.nio.file.Path chromiumDir)
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 are not 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.
public EngineOptions.Builder licenseKey(java.lang.String licenseKey)
The license key can be set using the "jxbrowser.license.key" system property. This method allows you to override the license key specified in the system property with the given value.
java.lang.IllegalArgumentException
- when licenseKey
is empty or blankpublic EngineOptions.Builder userAgent(java.lang.String userAgent)
Engine
.
Has the same effect as adding the --user-agent
switch.
java.lang.IllegalArgumentException
- when userAgent
is empty or blankpublic EngineOptions.Builder googleApiKey(java.lang.String googleApiKey)
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 will not work.
java.lang.IllegalArgumentException
- when googleApiKey
is empty or blankpublic EngineOptions.Builder googleDefaultClientId(java.lang.String googleDefaultClientId)
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 will not work.
java.lang.IllegalArgumentException
- when googleDefaultClientId
is empty or blankpublic EngineOptions.Builder googleDefaultClientSecret(java.lang.String googleDefaultClientSecret)
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 will not work.
java.lang.IllegalArgumentException
- when googleDefaultClientSecret
is empty or
blankpublic EngineOptions.Builder ppapiFlashPath(java.nio.file.Path ppapiFlashPath)
Installation process of PPAPI Flash can be different depending on Linux distribution. If this parameter is not set on Linux, Chromium expects to find PPAPI Flash in following directories:
/usr/lib/pepflashplugin-installer/
/usr/lib/pepperflashplugin-nonfree/
/usr/lib/chromium/PepperFlash/
/usr/lib64/chromium/PepperFlash/
public EngineOptions.Builder ppapiFlashVersion(java.lang.String ppapiFlashVersion)
The version should be numbers separated by dots (e.g., "20.0.0.270").
java.lang.IllegalArgumentException
- when ppapiFlashVersion
is empty or blankpublic EngineOptions.Builder language(Language language)
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.
Has the same effect as adding the --lang
switch.
public EngineOptions.Builder remoteDebuggingPort(int remoteDebuggingPort)
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 web
pages that are currently loaded using Chrome DevTools. If you use the Google Chrome
browser for remote debugging, its version must be equal to the Chromium engine version
that is used in JxBrowser.
Has the same effect as adding the --remote-debugging-port
switch.
java.lang.IllegalArgumentException
- when remoteDebuggingPort
is negativepublic EngineOptions.Builder passwordStore(PasswordStore passwordStore)
By default, the encryption storage backend is chosen by the Chromium engine automatically.
Has the same effect as adding the --password-store
switch.
public EngineOptions.Builder diskCacheSize(long diskCacheSize)
Has the same effect as adding the --disk-cache-size
switch.
java.lang.IllegalArgumentException
- when diskCacheSize
is <= 0public EngineOptions.Builder disableTouchMenu()
Engine
instance.
By default, when user performs long press on the touch screen the popup menu is displayed. This method prevents showing of this menu.
Has the same effect as adding the --disable-touch-menu
switch.
public EngineOptions.Builder enableIncognito()
Engine
instance.
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
.
Has the same effect as adding the --incognito
switch.
public EngineOptions.Builder disableSandbox()
Engine
instance.
Has the same effect as adding the --no-sandbox
switch.
public EngineOptions.Builder disableWebSecurity()
Engine
instance.
Has the same effect as adding the --disable-web-security
switch.
public EngineOptions.Builder allowFileAccessFromFiles()
Engine
instance.
Allows the file://
URIs to read other file://
URIs.
Has the same effect as adding the --allow-file-access-from-files
switch.
public EngineOptions.Builder enableAutoplay()
Has the same effect as adding the --autoplay-policy=no-user-gesture-required
switch.
public EngineOptions.Builder disableGpu()
Engine
instance.
If software renderer is not in place, then the GPU process won't launch.
Has the same effect as adding the --disable-gpu
switch.
public EngineOptions.Builder treatInsecureOriginAsSecure(java.lang.String... origins)
origins
to the white list. These (insecure) origins will be treated
as secure origins.
Each origin passed to this method should be an origin or hostname pattern up to eTLD+1. For example, the list may contain "http://foo.com", "http://foo.com:8000", "*.foo.com", "*.foo.*.bar.com", and "http://*.foo.bar.com", but not "*.co.uk", "*.com", or "test.*.com". Hostname patterns must contain a wildcard somewhere (so "test.com" is not a valid pattern) and wildcards can only replace full components ("test*.foo.com" is not valid).
Has the same effect as adding the --unsafely-treat-insecure-origin-as-secure
switch.
public EngineOptions.Builder addSwitch(java.lang.String commandLineSwitch)
Important For advanced usage only. The library does not support all the possible Chromium switches, so there is no guarantee that the passed switches will work. All the supported switches can be set through the corresponding methods of this builder. Switches added using this method will overwrite the corresponding options configured through the methods of this builder.
For example, if you configure the remote debugging port using the remoteDebuggingPort(int)
method and then add the --remote-debugging-port
switch
using this method, the port from the switch will be used.
java.lang.IllegalArgumentException
- when the commandLineSwitch
is empty or blankpublic EngineOptions.Builder enableProprietaryFeature(ProprietaryFeature feature)
Engine
instance.
By default, all the proprietary features are disabled.
ProprietaryFeature
public EngineOptions.Builder disableChromiumTraffic()
By default, Chromium services that cause additional traffic are enabled
public EngineOptions build()
EngineOptions
instance.