Class NetworkSession
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
NetworkSession.Builder<B extends NetworkSession.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theDownloadStartedCallback
callback.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionNetworkSession
(@Nullable String dataDirectory, @Nullable String cacheDirectory) Creates a newWebKitNetworkSession
with a persistentWebKitWebsiteDataManager
.NetworkSession
(MemorySegment address) Create a NetworkSession proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
allowTlsCertificateForHost
(TlsCertificate certificate, String host) Ignore further TLS errors on thehost
for the certificate present ininfo
.protected NetworkSession
asParent()
Returns this instance as if it were its parent type.static NetworkSession.Builder
<? extends NetworkSession.Builder> builder()
ANetworkSession.Builder
object constructs aNetworkSession
with the specified properties.downloadUri
(String uri) Requests downloading of the specified URI string.void
emitDownloadStarted
(Download download) Emits the "download-started" signal.static NetworkSession
Creates a newWebKitNetworkSession
with an ephemeralWebKitWebsiteDataManager
.Get theWebKitCookieManager
of this NetworkSession.static NetworkSession
Get the default network session.boolean
Get whether Intelligent Tracking Prevention (ITP) is enabled or not.void
getItpSummary
(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously get the list ofWebKitITPThirdParty
seen for this NetworkSession.getItpSummaryFinish
(AsyncResult result) Finish an asynchronous operation started with webkit_network_session_get_itp_summary().boolean
Get whether persistent credential storage is enabled or not.Get the TLS errors policy of this NetworkSession.static Type
getType()
Get the GType of the NetworkSession classGet theWebKitWebsiteDataManager
of this NetworkSession.boolean
Get whether this NetworkSession is ephemeral.This signal is emitted when a new download request is made.void
prefetchDns
(String hostname) Resolve the domain name of the givenhostname
in advance, so that if a URI ofhostname
is requested the load will be performed more quickly.void
setItpEnabled
(boolean enabled) Enable or disable Intelligent Tracking Prevention (ITP).static void
Setssettings
as theWebKitMemoryPressureSettings
.void
setPersistentCredentialStorageEnabled
(boolean enabled) Enable or disable persistent credential storage.void
setProxySettings
(NetworkProxyMode proxyMode, @Nullable NetworkProxySettings proxySettings) Set the network proxy settings to be used by connections started in this NetworkSession session.void
setTlsErrorsPolicy
(TLSErrorsPolicy policy) Set the TLS errors policy of this NetworkSession aspolicy
.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
NetworkSession
Create a NetworkSession proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
NetworkSession
public NetworkSession(@Nullable @Nullable String dataDirectory, @Nullable @Nullable String cacheDirectory) throws UnsupportedPlatformException Creates a newWebKitNetworkSession
with a persistentWebKitWebsiteDataManager
. The parametersdataDirectory
andcacheDirectory
will be used as construct properties of theWebKitWebsiteDataManager
of the network session. Note that ifnull
is passed, the default directory will be passed toWebKitWebsiteDataManager
so that webkit_website_data_manager_get_base_data_directory() and webkit_website_data_manager_get_base_cache_directory() always return a value for non ephemeral sessions.It must be passed as construct parameter of a
WebKitWebView
.- Parameters:
dataDirectory
- a base directory for data, ornull
cacheDirectory
- a base directory for caches, ornull
- Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
ephemeral
Creates a newWebKitNetworkSession
with an ephemeralWebKitWebsiteDataManager
.- Returns:
- a new ephemeral
WebKitNetworkSession
. - Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
getDefault
Get the default network session. The default network session is created using webkit_network_session_new() and passingnull
as data and cache directories.- Returns:
- a
WebKitNetworkSession
- Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
setMemoryPressureSettings
public static void setMemoryPressureSettings(MemoryPressureSettings settings) throws UnsupportedPlatformException Setssettings
as theWebKitMemoryPressureSettings
.Sets
settings
as theWebKitMemoryPressureSettings
to be used by the network process created by any instance ofWebKitNetworkSession
after this function is called.Be sure to call this function before creating any
WebKitNetworkSession
.The periodic check for used memory is disabled by default on network processes. This will be enabled only if custom settings have been set using this function. After that, in order to remove the custom settings and disable the periodic check, this function must be called passing
null
as the value ofsettings
.- Parameters:
settings
- a WebKitMemoryPressureSettings.- Throws:
UnsupportedPlatformException
- when run on a platform other than linux
-
allowTlsCertificateForHost
Ignore further TLS errors on thehost
for the certificate present ininfo
.If
host
is an IPv6 address, it should not be surrounded by brackets. This expectation matches g_uri_get_host().- Parameters:
certificate
- aGTlsCertificate
host
- the host for which a certificate is to be allowed
-
downloadUri
Requests downloading of the specified URI string.The download operation will not be associated to any
WebKitWebView
, if you are interested in starting a download from a particularWebKitWebView
use webkit_web_view_download_uri() instead.- Parameters:
uri
- the URI to download- Returns:
- a new
WebKitDownload
representing the download operation.
-
getCookieManager
Get theWebKitCookieManager
of this NetworkSession.- Returns:
- a
WebKitCookieManager
-
getItpEnabled
public boolean getItpEnabled()Get whether Intelligent Tracking Prevention (ITP) is enabled or not.- Returns:
true
if ITP is enabled, orfalse
otherwise.
-
getItpSummary
public void getItpSummary(@Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously get the list ofWebKitITPThirdParty
seen for this NetworkSession.Every
WebKitITPThirdParty
contains the list ofWebKitITPFirstParty
under which it has been seen.When the operation is finished,
callback
will be called. You can then call webkit_network_session_get_itp_summary_finish() to get the result of the operation.- Parameters:
cancellable
- aGCancellable
ornull
to ignorecallback
- aGAsyncReadyCallback
to call when the request is satisfied
-
getItpSummaryFinish
Finish an asynchronous operation started with webkit_network_session_get_itp_summary().- Parameters:
result
- aGAsyncResult
- Returns:
- a
GList
ofWebKitITPThirdParty
. You must free theGList
with g_list_free() and unref theWebKitITPThirdParty
<!-- -->s with webkit_itp_third_party_unref() when you're done with them. - Throws:
GErrorException
- seeGError
-
getPersistentCredentialStorageEnabled
public boolean getPersistentCredentialStorageEnabled()Get whether persistent credential storage is enabled or not.See also webkit_network_session_set_persistent_credential_storage_enabled().
- Returns:
true
if persistent credential storage is enabled, orfalse
otherwise.
-
getTlsErrorsPolicy
Get the TLS errors policy of this NetworkSession.- Returns:
- a
WebKitTLSErrorsPolicy
-
getWebsiteDataManager
Get theWebKitWebsiteDataManager
of this NetworkSession.- Returns:
- a
WebKitWebsiteDataManager
-
isEphemeral
public boolean isEphemeral()Get whether this NetworkSession is ephemeral. AWebKitNetworkSession
is ephemeral when itsWebKitWebsiteDataManager
is ephemeral. SeeWebKitWebsiteDataManager
:is-ephemeral for more details.- Returns:
true
if this NetworkSession is pehmeral, orfalse
otherwise
-
prefetchDns
Resolve the domain name of the givenhostname
in advance, so that if a URI ofhostname
is requested the load will be performed more quickly.- Parameters:
hostname
- a hostname to be resolved
-
setItpEnabled
public void setItpEnabled(boolean enabled) Enable or disable Intelligent Tracking Prevention (ITP).When ITP is enabled resource load statistics are collected and used to decide whether to allow or block third-party cookies and prevent user tracking. Note that while ITP is enabled the accept policy
CookieAcceptPolicy.NO_THIRD_PARTY
is ignored andCookieAcceptPolicy.ALWAYS
is used instead. See also webkit_cookie_session_set_accept_policy().- Parameters:
enabled
- value to set
-
setPersistentCredentialStorageEnabled
public void setPersistentCredentialStorageEnabled(boolean enabled) Enable or disable persistent credential storage.When enabled, which is the default for non-ephemeral sessions, the network process will try to read and write HTTP authentiacation credentials from persistent storage.
- Parameters:
enabled
- value to set
-
setProxySettings
public void setProxySettings(NetworkProxyMode proxyMode, @Nullable @Nullable NetworkProxySettings proxySettings) Set the network proxy settings to be used by connections started in this NetworkSession session.By default
NetworkProxyMode.DEFAULT
is used, which means that the system settings will be used (g_proxy_resolver_get_default()). If you want to override the system default settings, you can either useNetworkProxyMode.NO_PROXY
to make sure no proxies are used at all, orNetworkProxyMode.CUSTOM
to provide your own proxy settings. WhenproxyMode
isNetworkProxyMode.CUSTOM
proxySettings
must be a validWebKitNetworkProxySettings
; otherwise,proxySettings
must benull
.- Parameters:
proxyMode
- aWebKitNetworkProxyMode
proxySettings
- aWebKitNetworkProxySettings
, ornull
-
setTlsErrorsPolicy
Set the TLS errors policy of this NetworkSession aspolicy
.- Parameters:
policy
- aWebKitTLSErrorsPolicy
-
onDownloadStarted
public SignalConnection<NetworkSession.DownloadStartedCallback> onDownloadStarted(NetworkSession.DownloadStartedCallback handler) This signal is emitted when a new download request is made.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDownloadStarted
Emits the "download-started" signal. SeeonDownloadStarted(org.gnome.webkit.NetworkSession.DownloadStartedCallback)
. -
builder
ANetworkSession.Builder
object constructs aNetworkSession
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withNetworkSession.Builder.build()
.
-