public final class BrowserContextParams
extends java.lang.Object
BrowserContext
instance. Using
BrowserContextParams
you can configure
BrowserContext
with different settings such as Chromium data directory, default accept language, proxy settings, etc.
Constructor and Description |
---|
BrowserContextParams(java.lang.String dataDir)
Constructs a new
BrowserContextParams instance with specified
dataDir and default accept language obtained via
BrowserPreferences.getDefaultAcceptLanguage() method.
|
BrowserContextParams(java.lang.String dataDir, java.lang.String acceptLanguage)
Constructs a new
BrowserContextParams instance with specified
dataDir and
acceptLanguage .
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getAcceptLanguage()
Returns a string that represents accept language.
返回表示接受语言的字符串。 |
java.lang.String |
getCacheDir()
Returns absolute path to the directory where cache files will be stored.
返回将要存储缓存文件的目录的绝对路径。 |
java.lang.String |
getDataDir()
Returns absolute path to the directory where user data files will be stored.
返回将要存储用户数据文件的目录的绝对路径。 |
java.lang.String |
getMemoryDir()
Returns absolute path to the directory where shared memory files will be stored.
返回将存储共享内存文件的目录的绝对路径。 |
ProxyConfig |
getProxyConfig()
Returns proxy configuration of the current browser instance or
返回当前浏览器实例的代理配置;如果在浏览器实例实例化期间未提供代理配置,则返回null。 null if no proxy configuration was provided during Browser instance instantiation.
|
StorageType |
getStorageType()
Returns data storage type that defines how to store all the data such as cache, cookies, HTML5 WebStorage files, etc.
返回定义如何存储所有数据的数据存储类型,例如缓存,cookie,HTML5 WebStorage文件等。 |
void |
setAcceptLanguage(java.lang.String acceptLanguage)
Sets default accept language (e.g.
设置默认的接受语言(例如 |
void |
setCacheDir(java.lang.String cacheDir)
Sets absolute path to the directory where Chromium engine will store cache.
设置Chromium引擎将存储缓存的目录的绝对路径。 |
void |
setMemoryDir(java.lang.String memoryDir)
Sets absolute path to the directory where Chromium engine will store memory mapped files for transferring rendered images in Mac OS X and Linux environments.
将绝对路径设置为Chromium引擎将在其中存储用于在Mac OS X和Linux环境中传输渲染图像的内存映射文件的目录。 |
void |
setProxyConfig(AutoDetectProxyConfig proxyConfig)
Sets proxy configuration where the connection automatically detects proxy settings.
设置代理配置,其中连接自动检测代理设置。 |
void |
setProxyConfig(CustomProxyConfig proxyConfig)
Sets custom user proxy settings.
设置自定义用户代理设置。 |
void |
setProxyConfig(DirectProxyConfig proxyConfig)
Sets proxy configuration that doesn't use a proxy server.
设置不使用代理服务器的代理配置。 |
void |
setProxyConfig(URLProxyConfig proxyConfig)
Sets proxy configuration that obtains proxy settings from proxy auto-config (PAC) file, which is located at the specific predefined address.
设置代理配置,该配置从位于特定预定义地址的代理自动配置(PAC)文件获取代理设置。 |
void |
setStorageType(StorageType storageType)
Sets storage type that defines how to store all Chromium data such as cache, cookies, HTML5 WebStorage files, etc.
设置存储类型,该存储类型定义如何存储所有Chromium数据,例如缓存,Cookie,HTML5 WebStorage文件等。 |
public BrowserContextParams(java.lang.String dataDir)
BrowserContextParams
instance with specified
dataDir
and default accept language obtained via
BrowserPreferences.getDefaultAcceptLanguage()
method. The instance will automatically set cache and memory directory relative to the
dataDir
location. Proxy settings will be configured to use system proxy.
No user data is written to the dataDir
directory when StorageType.MEMORY
data storage type is used. By default, On Mac OS X and Linux platforms memory directory where Chromium engine will store memory mapped files for transferring rendered images will be constructed based on the specified dataDir
.
dataDir
- absolute or relative location of the directory where Chromium will store data files. In case of relative path, the location will be taken relative to the current Java App working directory. Cannot be
null
or empty.
-Chromium将在其中存储数据文件的目录的绝对或相对位置。如果是相对路径,则位置将相对于当前Java App工作目录。不能为空。
java.lang.IllegalArgumentException
- when
dataDir
parameter is
null
or empty.
public BrowserContextParams(java.lang.String dataDir, java.lang.String acceptLanguage)
BrowserContextParams
instance with specified
dataDir
and
acceptLanguage
. The instance will automatically set cache and memory directory relative to the
dataDir
location. Proxy settings will be configured to use system proxy.
No user data is written to the dataDir
directory when StorageType.MEMORY
data storage type is used. By default, On Mac OS X and Linux platforms memory directory where Chromium engine will store memory mapped files for transferring rendered images will be constructed based on the specified dataDir
.
dataDir
- absolute or relative location of the directory where Chromium will store data files. In case of relative path, the location will be taken relative to the current Java App working directory. Cannot be
null
or empty.
-Chromium将在其中存储数据文件的目录的绝对或相对位置。如果是相对路径,则位置将相对于当前Java App工作目录。不能为空。
acceptLanguage
- a string that represents default accept language (e.g. en-us). Cannot be
null
or empty.
-代表默认接受语言的字符串(例如en-us)。不能为空。
java.lang.IllegalArgumentException
- when
dataDir
parameter is
null
or empty.
java.lang.IllegalArgumentException
- when
acceptLanguage
parameter is
null
or empty.
public void setProxyConfig(AutoDetectProxyConfig proxyConfig)
public void setProxyConfig(CustomProxyConfig proxyConfig)
public void setProxyConfig(DirectProxyConfig proxyConfig)
public StorageType getStorageType()
public void setStorageType(StorageType storageType)
java.lang.IllegalArgumentException
- when
storageType
is
null
.
public java.lang.String getCacheDir()
public void setCacheDir(java.lang.String cacheDir)
cacheDir
- absolute path to the directory where Chromium engine will store cache. Cannot be
null
or empty.
-Chromium引擎将存储缓存的目录的绝对路径。不能为空。
java.lang.IllegalArgumentException
- when
cacheDir
is
null
or empty.
public java.lang.String getMemoryDir()
public void setMemoryDir(java.lang.String memoryDir)
memoryDir
- absolute path to the directory where Chromium engine will store memory mapped files. Cannot be
null
or empty.
-Chromium引擎将存储内存映射文件的目录的绝对路径。不能为空。
java.lang.IllegalArgumentException
- when
memoryDir
is
null
or empty.
public java.lang.String getAcceptLanguage()
public void setAcceptLanguage(java.lang.String acceptLanguage)
BrowserPreferences.getDefaultAcceptLanguage()
static method to get default accept language in your environments. The accept language is used in browser's user-agent string.
acceptLanguage
- a string that represents default accept language. Cannot be
null
or empty.
-表示默认接受语言的字符串。不能为空。
java.lang.IllegalArgumentException
- when
acceptLanguage
is
null
or empty.
public ProxyConfig getProxyConfig()
null
if no proxy configuration was provided during Browser instance instantiation.
public void setProxyConfig(URLProxyConfig proxyConfig)
public java.lang.String getDataDir()