Class NetworkSession
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classNetworkSession.Builder<B extends NetworkSession.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theDownloadStartedCallbackcallback.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new NetworkSession.NetworkSession(@Nullable String dataDirectory, @Nullable String cacheDirectory) Creates a newWebKitNetworkSessionwith a persistentWebKitWebsiteDataManager.NetworkSession(MemorySegment address) Create a NetworkSession proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidallowTlsCertificateForHost(TlsCertificate certificate, String host) Ignore further TLS errors on thehostfor the certificate present ininfo.protected NetworkSessionasParent()Returns this instance as if it were its parent type.static NetworkSession.Builder<? extends NetworkSession.Builder> builder()ANetworkSession.Builderobject constructs aNetworkSessionwith the specified properties.downloadUri(String uri) Requests downloading of the specified URI string.voidemitDownloadStarted(@Nullable Download download) Emits the "download-started" signal.static NetworkSessionCreates a newWebKitNetworkSessionwith an ephemeralWebKitWebsiteDataManager.Get theWebKitCookieManagerofsession.static NetworkSessionGet the default network session.booleanGet whether Intelligent Tracking Prevention (ITP) is enabled or not.voidgetItpSummary(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously get the list ofWebKitITPThirdPartyseen forsession.getItpSummaryFinish(AsyncResult result) Finish an asynchronous operation started with webkit_network_session_get_itp_summary().booleanGet whether persistent credential storage is enabled or not.Get the TLS errors policy ofsession.static @Nullable TypegetType()Get the GType of the NetworkSession classGet theWebKitWebsiteDataManagerofsession.booleanGet whether this NetworkSession is ephemeral.This signal is emitted when a new download request is made.voidprefetchDns(String hostname) Resolve the domain name of the givenhostnamein advance, so that if a URI ofhostnameis requested the load will be performed more quickly.voidsetItpEnabled(boolean enabled) Enable or disable Intelligent Tracking Prevention (ITP).static voidSetssettingsas theWebKitMemoryPressureSettings.voidsetPersistentCredentialStorageEnabled(boolean enabled) Enable or disable persistent credential storage.voidsetProxySettings(NetworkProxyMode proxyMode, @Nullable NetworkProxySettings proxySettings) Set the network proxy settings to be used by connections started in this NetworkSession session.voidsetTlsErrorsPolicy(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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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
Creates a newWebKitNetworkSessionwith a persistentWebKitWebsiteDataManager. The parametersdataDirectoryandcacheDirectorywill be used as construct properties of theWebKitWebsiteDataManagerof the network session. Note that ifnullis passed, the default directory will be passed toWebKitWebsiteDataManagerso 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, ornullcacheDirectory- a base directory for caches, ornull- Since:
- 2.40
-
NetworkSession
public NetworkSession()Creates a new NetworkSession.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, 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 newWebKitNetworkSessionwith an ephemeralWebKitWebsiteDataManager.- Returns:
- a new ephemeral
WebKitNetworkSession. - Since:
- 2.40
-
getDefault
Get the default network session. The default network session is created using webkit_network_session_new() and passingnullas data and cache directories.- Returns:
- a
WebKitNetworkSession - Since:
- 2.40
-
setMemoryPressureSettings
Setssettingsas theWebKitMemoryPressureSettings.Sets
settingsas theWebKitMemoryPressureSettingsto be used by the network process created by any instance ofWebKitNetworkSessionafter 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
nullas the value ofsettings.- Parameters:
settings- a WebKitMemoryPressureSettings.- Since:
- 2.40
-
allowTlsCertificateForHost
Ignore further TLS errors on thehostfor the certificate present ininfo.If
hostis an IPv6 address, it should not be surrounded by brackets. This expectation matches g_uri_get_host().- Parameters:
certificate- aGTlsCertificatehost- the host for which a certificate is to be allowed- Since:
- 2.40
-
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 particularWebKitWebViewuse webkit_web_view_download_uri() instead.- Parameters:
uri- the URI to download- Returns:
- a new
WebKitDownloadrepresenting the download operation. - Since:
- 2.40
-
getCookieManager
Get theWebKitCookieManagerofsession.- Returns:
- a
WebKitCookieManager - Since:
- 2.40
-
getItpEnabled
public boolean getItpEnabled()Get whether Intelligent Tracking Prevention (ITP) is enabled or not.- Returns:
trueif ITP is enabled, orfalseotherwise.- Since:
- 2.40
-
getItpSummary
Asynchronously get the list ofWebKitITPThirdPartyseen forsession.Every
WebKitITPThirdPartycontains the list ofWebKitITPFirstPartyunder which it has been seen.When the operation is finished,
callbackwill be called. You can then call webkit_network_session_get_itp_summary_finish() to get the result of the operation.- Parameters:
cancellable- aGCancellableornullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.40
-
getItpSummaryFinish
Finish an asynchronous operation started with webkit_network_session_get_itp_summary().- Parameters:
result- aGAsyncResult- Returns:
- a
GListofWebKitITPThirdParty. You must free theGListwith g_list_free() and unref theWebKitITPThirdParty<!-- -->s with webkit_itp_third_party_unref() when you're done with them. - Throws:
GErrorException- seeGError- Since:
- 2.40
-
getPersistentCredentialStorageEnabled
public boolean getPersistentCredentialStorageEnabled()Get whether persistent credential storage is enabled or not.See also webkit_network_session_set_persistent_credential_storage_enabled().
- Returns:
trueif persistent credential storage is enabled, orfalseotherwise.- Since:
- 2.40
-
getTlsErrorsPolicy
Get the TLS errors policy ofsession.- Returns:
- a
WebKitTLSErrorsPolicy - Since:
- 2.40
-
getWebsiteDataManager
Get theWebKitWebsiteDataManagerofsession.- Returns:
- a
WebKitWebsiteDataManager - Since:
- 2.40
-
isEphemeral
public boolean isEphemeral()Get whether this NetworkSession is ephemeral. AWebKitNetworkSessionis ephemeral when itsWebKitWebsiteDataManageris ephemeral. SeeWebKitWebsiteDataManager:is-ephemeral for more details.- Returns:
trueif this NetworkSession is pehmeral, orfalseotherwise- Since:
- 2.40
-
prefetchDns
Resolve the domain name of the givenhostnamein advance, so that if a URI ofhostnameis requested the load will be performed more quickly.- Parameters:
hostname- a hostname to be resolved- Since:
- 2.40
-
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_PARTYis ignored andCookieAcceptPolicy.ALWAYSis used instead. See also webkit_cookie_session_set_accept_policy().- Parameters:
enabled- value to set- Since:
- 2.40
-
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- Since:
- 2.40
-
setProxySettings
public void setProxySettings(NetworkProxyMode proxyMode, @Nullable NetworkProxySettings proxySettings) Set the network proxy settings to be used by connections started in this NetworkSession session.By default
NetworkProxyMode.DEFAULTis 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_PROXYto make sure no proxies are used at all, orNetworkProxyMode.CUSTOMto provide your own proxy settings. WhenproxyModeisNetworkProxyMode.CUSTOMproxySettingsmust be a validWebKitNetworkProxySettings; otherwise,proxySettingsmust benull.- Parameters:
proxyMode- aWebKitNetworkProxyModeproxySettings- aWebKitNetworkProxySettings, ornull- Since:
- 2.40
-
setTlsErrorsPolicy
Set the TLS errors policy of this NetworkSession aspolicy.- Parameters:
policy- aWebKitTLSErrorsPolicy- Since:
- 2.40
-
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
- Since:
- 2.40
- See Also:
-
emitDownloadStarted
Emits the "download-started" signal. SeeonDownloadStarted(org.webkitgtk.NetworkSession.DownloadStartedCallback). -
builder
ANetworkSession.Builderobject constructs aNetworkSessionwith the specified properties. Use the variousset...()methods to set properties, and finish construction withNetworkSession.Builder.build().- Returns:
- the builder object
-