Class CookieManager
- All Implemented Interfaces:
Proxy
WebKitWebContext
.
The WebKitCookieManager defines how to set up and handle cookies.
You can get it from a WebKitWebsiteDataManager
with
webkit_website_data_manager_get_cookie_manager(), and use it to set where to
store cookies with webkit_cookie_manager_set_persistent_storage(),
or to set the acceptance policy, with webkit_cookie_manager_get_accept_policy().
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
CookieManager.Builder<B extends CookieManager.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theChangedCallback
callback.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionCookieManager
(MemorySegment address) Create a CookieManager proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCookie
(Cookie cookie, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously add aSoupCookie
to the underlying storage.boolean
addCookieFinish
(AsyncResult result) Finish an asynchronous operation started with webkit_cookie_manager_add_cookie().protected CookieManager
asParent()
Returns this instance as if it were its parent type.static CookieManager.Builder
<? extends CookieManager.Builder> builder()
ACookieManager.Builder
object constructs aCookieManager
with the specified properties.void
deleteCookie
(Cookie cookie, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously delete aSoupCookie
from the current session.boolean
deleteCookieFinish
(AsyncResult result) Finish an asynchronous operation started with webkit_cookie_manager_delete_cookie().void
Emits the "changed" signal.void
getAcceptPolicy
(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously get the cookie acceptance policy of this CookieManager.getAcceptPolicyFinish
(AsyncResult result) Finish an asynchronous operation started with webkit_cookie_manager_get_accept_policy().void
getAllCookies
(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously get a list ofSoupCookie
from this CookieManager.getAllCookiesFinish
(AsyncResult result) Finish an asynchronous operation started with webkit_cookie_manager_get_all_cookies().void
getCookies
(String uri, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously get a list ofSoupCookie
from this CookieManager.getCookiesFinish
(AsyncResult result) Finish an asynchronous operation started with webkit_cookie_manager_get_cookies().static Type
getType()
Get the GType of the CookieManager classonChanged
(CookieManager.ChangedCallback handler) This signal is emitted when cookies are added, removed or modified.void
replaceCookies
(List<Cookie> cookies, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously replace all cookies in this CookieManager with the given list ofcookies
.boolean
replaceCookiesFinish
(AsyncResult result) Finish an asynchronous operation started with webkit_cookie_manager_replace_cookies().void
setAcceptPolicy
(CookieAcceptPolicy policy) Set the cookie acceptance policy of this CookieManager aspolicy
.void
setPersistentStorage
(String filename, CookiePersistentStorage storage) Set non-session cookies.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
-
CookieManager
Create a CookieManager proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
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. -
addCookie
public void addCookie(Cookie cookie, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously add aSoupCookie
to the underlying storage.When the operation is finished,
callback
will be called. You can then call webkit_cookie_manager_add_cookie_finish() to get the result of the operation.- Parameters:
cookie
- theSoupCookie
to be addedcancellable
- aGCancellable
ornull
to ignorecallback
- aGAsyncReadyCallback
to call when the request is satisfied
-
addCookieFinish
Finish an asynchronous operation started with webkit_cookie_manager_add_cookie().- Parameters:
result
- aGAsyncResult
- Returns:
true
if the cookie was added orfalse
in case of error.- Throws:
GErrorException
- seeGError
-
deleteCookie
public void deleteCookie(Cookie cookie, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously delete aSoupCookie
from the current session.When the operation is finished,
callback
will be called. You can then call webkit_cookie_manager_delete_cookie_finish() to get the result of the operation.- Parameters:
cookie
- theSoupCookie
to be deletedcancellable
- aGCancellable
ornull
to ignorecallback
- aGAsyncReadyCallback
to call when the request is satisfied
-
deleteCookieFinish
Finish an asynchronous operation started with webkit_cookie_manager_delete_cookie().- Parameters:
result
- aGAsyncResult
- Returns:
true
if the cookie was deleted orfalse
in case of error.- Throws:
GErrorException
- seeGError
-
getAcceptPolicy
public void getAcceptPolicy(@Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously get the cookie acceptance policy of this CookieManager.Note that when policy was set to
CookieAcceptPolicy.NO_THIRD_PARTY
and ITP is enabled, this will returnCookieAcceptPolicy.ALWAYS
. See also webkit_website_data_manager_set_itp_enabled().When the operation is finished,
callback
will be called. You can then call webkit_cookie_manager_get_accept_policy_finish() to get the result of the operation.- Parameters:
cancellable
- aGCancellable
ornull
to ignorecallback
- aGAsyncReadyCallback
to call when the request is satisfied
-
getAcceptPolicyFinish
Finish an asynchronous operation started with webkit_cookie_manager_get_accept_policy().- Parameters:
result
- aGAsyncResult
- Returns:
- the cookie acceptance policy of this CookieManager as a
WebKitCookieAcceptPolicy
. - Throws:
GErrorException
- seeGError
-
getAllCookies
public void getAllCookies(@Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously get a list ofSoupCookie
from this CookieManager.When the operation is finished,
callback
will be called. You can then call webkit_cookie_manager_get_all_cookies_finish() to get the result of the operation.- Parameters:
cancellable
- aGCancellable
ornull
to ignorecallback
- (closure user_data): aGAsyncReadyCallback
to call when the request is satisfied
-
getAllCookiesFinish
Finish an asynchronous operation started with webkit_cookie_manager_get_all_cookies().The return value is a
GList
ofSoupCookie
instances which should be released with g_list_free_full() and soup_cookie_free().- Parameters:
result
- aGAsyncResult
- Returns:
- A
GList
ofSoupCookie
instances. - Throws:
GErrorException
- seeGError
-
getCookies
public void getCookies(String uri, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously get a list ofSoupCookie
from this CookieManager.Asynchronously get a list of
SoupCookie
from this CookieManager associated withuri
, which must be either an HTTP or an HTTPS URL.When the operation is finished,
callback
will be called. You can then call webkit_cookie_manager_get_cookies_finish() to get the result of the operation.- Parameters:
uri
- the URI associated to the cookies to be retrievedcancellable
- aGCancellable
ornull
to ignorecallback
- aGAsyncReadyCallback
to call when the request is satisfied
-
getCookiesFinish
Finish an asynchronous operation started with webkit_cookie_manager_get_cookies().The return value is a
GList
ofSoupCookie
instances which should be released with g_list_free_full() and soup_cookie_free().- Parameters:
result
- aGAsyncResult
- Returns:
- A
GList
ofSoupCookie
instances. - Throws:
GErrorException
- seeGError
-
replaceCookies
public void replaceCookies(List<Cookie> cookies, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously replace all cookies in this CookieManager with the given list ofcookies
.When the operation is finished,
callback
will be called. You can then call webkit_cookie_manager_replace_cookies_finish() to get the result of the operation.- Parameters:
cookies
- aGList
ofSoupCookie
to be addedcancellable
- aGCancellable
ornull
to ignorecallback
- (closure user_data): aGAsyncReadyCallback
to call when the request is satisfied
-
replaceCookiesFinish
Finish an asynchronous operation started with webkit_cookie_manager_replace_cookies().- Parameters:
result
- aGAsyncResult
- Returns:
true
if the cookies were added orfalse
in case of error.- Throws:
GErrorException
- seeGError
-
setAcceptPolicy
Set the cookie acceptance policy of this CookieManager aspolicy
.Note that ITP has its own way to handle third-party cookies, so when it's enabled, and
policy
is set toCookieAcceptPolicy.NO_THIRD_PARTY
,CookieAcceptPolicy.ALWAYS
will be used instead. Once disabled, the policy will be set back toCookieAcceptPolicy.NO_THIRD_PARTY
. See also webkit_website_data_manager_set_itp_enabled().- Parameters:
policy
- aWebKitCookieAcceptPolicy
-
setPersistentStorage
Set non-session cookies.Set the
filename
where non-session cookies are stored persistently usingstorage
as the format to read/write the cookies. Cookies are initially read fromfilename
to create an initial set of cookies. Then, non-session cookies will be written tofilename
when the WebKitCookieManager::changed signal is emitted. By default, this CookieManager doesn't store the cookies persistently, so you need to call this method to keep cookies saved across sessions.This method should never be called on a
WebKitCookieManager
associated to an ephemeralWebKitWebsiteDataManager
.- Parameters:
filename
- the filename to read to/write fromstorage
- aWebKitCookiePersistentStorage
-
onChanged
public SignalConnection<CookieManager.ChangedCallback> onChanged(CookieManager.ChangedCallback handler) This signal is emitted when cookies are added, removed or modified.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitChanged
public void emitChanged()Emits the "changed" signal. SeeonChanged(org.gnome.webkit.CookieManager.ChangedCallback)
. -
builder
ACookieManager.Builder
object constructs aCookieManager
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withCookieManager.Builder.build()
.
-