public class BrowserPreferences
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CHROMIUM_DIR_PROPERTY |
static java.lang.String |
TEMP_DIR_PROPERTY |
static java.lang.String |
USER_AGENT_PROPERTY |
Constructor and Description |
---|
BrowserPreferences() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getChromiumDir()
Returns path to the directory where Chromium binaries are located or empty string if there's no such path.
返回Chromium二进制文件所在目录的路径,如果没有这样的路径,则返回空字符串。 |
static java.util.List<java.lang.String> |
getChromiumSwitches()
Returns copy of the Chromium switches that were set via the
返回通过setChromiumSwitches(String ...)方法设置的Chromium开关的副本。 setChromiumSwitches(String...) method.
|
static java.util.Map<java.lang.String,java.lang.String> |
getChromiumVariables()
Returns copy of Chromium environment variables set vis
返回设置为setChromiumVariable(String,String)的Chromium环境变量的副本;如果未设置任何环境变量,则返回空映射。 setChromiumVariable(String, String) or empty map if no environment variables were set.
|
static java.lang.String |
getDefaultAcceptLanguage()
Returns a string that represents default accept language (e.g.
返回代表默认接受语言的字符串(例如 |
static java.lang.String |
getDefaultCacheDir() |
static java.lang.String |
getDefaultChromiumDir()
Returns a string that represents absolute path to the directory where Chromium binaries will be extracted by default and where Chromium profile directory will be created.
返回一个字符串,该字符串表示默认情况下将提取Chromium二进制文件和将在其中创建Chromium配置文件目录的目录的绝对路径。 |
static java.lang.String |
getDefaultDataDir()
Returns the path to the directory where user data files (e.g.
返回用户数据文件所在目录的路径(例如 |
java.lang.String |
getDefaultEncoding() |
static java.lang.String |
getDefaultMemoryDir() |
static java.lang.String |
getTempDir() |
static java.lang.String |
getUserAgent()
Returns the user agent string which was set using the
返回使用setUserAgent(String)方法设置的用户代理字符串。 setUserAgent(String) method.
|
WebRTCIPHandlingPolicy |
getWebRTCIPHandlingPolicy() |
boolean |
isAllowDisplayingInsecureContent()
Deprecated.
已过时。 |
boolean |
isAllowRunningInsecureContent() |
boolean |
isAllowScriptsToCloseWindows() |
boolean |
isApplicationCacheEnabled() |
boolean |
isDatabasesEnabled() |
boolean |
isImagesEnabled() |
boolean |
isJavaScriptCanAccessClipboard() |
boolean |
isJavaScriptCanOpenWindowsAutomatically() |
boolean |
isJavaScriptEnabled() |
boolean |
isLoadsImagesAutomatically() |
boolean |
isLocalStorageEnabled() |
boolean |
isPluginsEnabled() |
boolean |
isTransparentBackground() |
boolean |
isUnifiedTextcheckerEnabled()
Deprecated.
已过时。 |
boolean |
isWebAudioEnabled()
Deprecated.
已过时。 |
void |
setAllowDisplayingInsecureContent(boolean allowDisplayingInsecureContent)
Deprecated.
已过时。 |
void |
setAllowRunningInsecureContent(boolean allowRunningInsecureContent) |
void |
setAllowScriptsToCloseWindows(boolean allowScriptsToCloseWindows) |
void |
setApplicationCacheEnabled(boolean applicationCacheEnabled) |
static void |
setChromiumDir(java.lang.String chromiumDir)
Configures the directory where Browser component will be looking for Chromium binaries.
配置浏览器组件将在其中查找Chromium二进制文件的目录。 |
static void |
setChromiumSwitches(java.lang.String... switches)
Configures Chromium engine to use the command line flags (
将Chromium引擎配置为使用命令行标志(开关)以启用特定功能或修改默认功能。 switches ) in order to enable particular features or modify default functionality.
|
static void |
setChromiumVariable(java.lang.String name, java.lang.String value)
Sets Chromium environment variables that will be passed to each Chromium process.
设置将传递给每个Chromium进程的Chromium环境变量。 |
void |
setDatabasesEnabled(boolean databasesEnabled) |
void |
setDefaultEncoding(java.lang.String defaultEncoding)
Deprecated.
已过时。此方法不执行任何操作。自版本55起,Chromium自动检测编码,并忽略编码设置。
This method does nothing. Chromium auto-detects encoding and ignores encoding settings since version 55.
|
void |
setImagesEnabled(boolean imagesEnabled) |
void |
setJavaScriptCanAccessClipboard(boolean javaScriptCanAccessClipboard) |
void |
setJavaScriptCanOpenWindowsAutomatically(boolean javaScriptCanOpenWindowsAutomatically)
Deprecated.
已过时。此方法不执行任何操作。从版本60开始,Chromium在阻止弹出窗口时不依赖此设置。有关实际弹出窗口的阻止,请参阅Browser.setPopupHandler(PopupHandler)}。
This method does nothing. Chromium does not rely on this setting when blocking popups since version 60. For actual popup blocking see
Browser.setPopupHandler(PopupHandler) }.
|
void |
setJavaScriptEnabled(boolean javascriptEnabled) |
void |
setLoadsImagesAutomatically(boolean loadsImagesAutomatically) |
void |
setLocalStorageEnabled(boolean localStorageEnabled) |
void |
setPluginsEnabled(boolean pluginsEnabled) |
void |
setTransparentBackground(boolean transparentBackground) |
void |
setUnifiedTextcheckerEnabled(boolean unifiedTextcheckerEnabled)
Deprecated.
已过时。 |
static void |
setUserAgent(java.lang.String userAgent)
Configures the user agent string for all Browser instances.
为所有浏览器实例配置用户代理字符串。 |
void |
setWebAudioEnabled(boolean webAudioEnabled)
Deprecated.
已过时。 |
void |
setWebRTCIPHandlingPolicy(WebRTCIPHandlingPolicy webRTCIPHandlingPolicy) |
public static final java.lang.String USER_AGENT_PROPERTY
public static final java.lang.String CHROMIUM_DIR_PROPERTY
public static final java.lang.String TEMP_DIR_PROPERTY
public static java.lang.String getChromiumDir()
setChromiumDir(String)
method, then this method returns default value via the
getDefaultChromiumDir()
method.
public static void setChromiumDir(java.lang.String chromiumDir)
chromiumDir
folder.
By default Chromium binaries for Windows platform are located inside
jxbrowser-win-*.jar
, for Mac OS X inside
jxbrowser-mac-*.jar
that you can find in the
lib
folder of JxBrowser distribution package.
chromiumDir
- the directory where the Chromium binaries are located.
-Chromium二进制文件所在的目录。
java.lang.IllegalArgumentException
- when
chromiumDir
is
null
or empty.
public static java.lang.String getUserAgent()
setUserAgent(String)
method. Can return
null
if the user agent string wasn't provided via the
setUserAgent(String)
method. This method cannot be used to receive a default user agent string.
setUserAgent(String)
method.
使用该方法设置的用户代理字符串。
public static void setUserAgent(java.lang.String userAgent)
userAgent
- a new user agent string.
-新的用户代理字符串。
java.lang.IllegalArgumentException
- when
userAgent
is
null
or empty.
public static java.lang.String getDefaultChromiumDir()
C:\Users\<user_name>\AppData\Local\JxBrowser
directory.
public static java.lang.String getDefaultDataDir()
public static java.lang.String getDefaultCacheDir()
public static java.lang.String getDefaultMemoryDir()
public static java.lang.String getTempDir()
public static java.lang.String getDefaultAcceptLanguage()
Locale.getDefault()
public static java.util.List<java.lang.String> getChromiumSwitches()
setChromiumSwitches(String...)
method.
public static void setChromiumSwitches(java.lang.String... switches)
switches
) in order to enable particular features or modify default functionality.
It is important to note that using these switches is not supported or recommended. They should only be used for temporary cases and may break in the future.
Current switches may be found at
http://peter.sh/examples/?/chromium-switches.html
switches
- a list of command line flags (switches).
-命令行标志(开关)列表。
java.lang.IllegalArgumentException
- when
switches
is
null
.
public static void setChromiumVariable(java.lang.String name, java.lang.String value)
name
- a string representation of the variable name. Cannot be
null
.
-变量名称的字符串表示形式。不可能是 。
value
- a string representation of the variable value. Cannot be
null
.
-变量值的字符串表示形式。不可能是 。
java.lang.IllegalArgumentException
- when
name
or
value
is
null
.
public static java.util.Map<java.lang.String,java.lang.String> getChromiumVariables()
setChromiumVariable(String, String)
or empty map if no environment variables were set.
public java.lang.String getDefaultEncoding()
@Deprecated public void setDefaultEncoding(java.lang.String defaultEncoding)
public boolean isJavaScriptEnabled()
public void setJavaScriptEnabled(boolean javascriptEnabled)
public boolean isJavaScriptCanOpenWindowsAutomatically()
@Deprecated public void setJavaScriptCanOpenWindowsAutomatically(boolean javaScriptCanOpenWindowsAutomatically)
Browser.setPopupHandler(PopupHandler)
}.
public boolean isLoadsImagesAutomatically()
public void setLoadsImagesAutomatically(boolean loadsImagesAutomatically)
public boolean isImagesEnabled()
public void setImagesEnabled(boolean imagesEnabled)
public boolean isPluginsEnabled()
public void setPluginsEnabled(boolean pluginsEnabled)
public boolean isAllowScriptsToCloseWindows()
public void setAllowScriptsToCloseWindows(boolean allowScriptsToCloseWindows)
public boolean isJavaScriptCanAccessClipboard()
public void setJavaScriptCanAccessClipboard(boolean javaScriptCanAccessClipboard)
public boolean isLocalStorageEnabled()
public void setLocalStorageEnabled(boolean localStorageEnabled)
public boolean isDatabasesEnabled()
public void setDatabasesEnabled(boolean databasesEnabled)
@Deprecated public boolean isWebAudioEnabled()
@Deprecated public void setWebAudioEnabled(boolean webAudioEnabled)
public boolean isApplicationCacheEnabled()
public void setApplicationCacheEnabled(boolean applicationCacheEnabled)
@Deprecated public boolean isAllowDisplayingInsecureContent()
@Deprecated public void setAllowDisplayingInsecureContent(boolean allowDisplayingInsecureContent)
public boolean isAllowRunningInsecureContent()
public void setAllowRunningInsecureContent(boolean allowRunningInsecureContent)
@Deprecated public boolean isUnifiedTextcheckerEnabled()
@Deprecated public void setUnifiedTextcheckerEnabled(boolean unifiedTextcheckerEnabled)
public boolean isTransparentBackground()
public void setTransparentBackground(boolean transparentBackground)
public WebRTCIPHandlingPolicy getWebRTCIPHandlingPolicy()
public void setWebRTCIPHandlingPolicy(WebRTCIPHandlingPolicy webRTCIPHandlingPolicy)