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
Nested ClassesModifier and TypeClassDescriptionstatic classCookieManager.Builder<B extends CookieManager.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theChangedCallbackcallback.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new CookieManager.CookieManager(MemorySegment address) Create a CookieManager proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCookie(Cookie cookie, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously add aSoupCookieto the underlying storage.booleanaddCookieFinish(AsyncResult result) Finish an asynchronous operation started with webkit_cookie_manager_add_cookie().protected CookieManagerasParent()Returns this instance as if it were its parent type.static CookieManager.Builder<? extends CookieManager.Builder> builder()ACookieManager.Builderobject constructs aCookieManagerwith the specified properties.voiddeleteCookie(Cookie cookie, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously delete aSoupCookiefrom the current session.booleandeleteCookieFinish(AsyncResult result) Finish an asynchronous operation started with webkit_cookie_manager_delete_cookie().voidEmits the "changed" signal.voidgetAcceptPolicy(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously get the cookie acceptance policy ofcookieManager.getAcceptPolicyFinish(AsyncResult result) Finish an asynchronous operation started with webkit_cookie_manager_get_accept_policy().voidgetAllCookies(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously get a list ofSoupCookiefromcookieManager.getAllCookiesFinish(AsyncResult result) Finish an asynchronous operation started with webkit_cookie_manager_get_all_cookies().voidgetCookies(String uri, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously get a list ofSoupCookiefromcookieManager.getCookiesFinish(AsyncResult result) Finish an asynchronous operation started with webkit_cookie_manager_get_cookies().static @Nullable TypegetType()Get the GType of the CookieManager classonChanged(CookieManager.ChangedCallback handler) This signal is emitted when cookies are added, removed or modified.voidreplaceCookies(List<Cookie> cookies, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously replace all cookies in this CookieManager with the given list ofcookies.booleanreplaceCookiesFinish(AsyncResult result) Finish an asynchronous operation started with webkit_cookie_manager_replace_cookies().voidsetAcceptPolicy(CookieAcceptPolicy policy) Set the cookie acceptance policy of this CookieManager aspolicy.voidsetPersistentStorage(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, 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
-
CookieManager
Create a CookieManager proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
CookieManager
public CookieManager()Creates a new CookieManager.
-
-
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. -
addCookie
public void addCookie(Cookie cookie, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously add aSoupCookieto the underlying storage.When the operation is finished,
callbackwill be called. You can then call webkit_cookie_manager_add_cookie_finish() to get the result of the operation.- Parameters:
cookie- theSoupCookieto be addedcancellable- aGCancellableornullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.20
-
addCookieFinish
Finish an asynchronous operation started with webkit_cookie_manager_add_cookie().- Parameters:
result- aGAsyncResult- Returns:
trueif the cookie was added orfalsein case of error.- Throws:
GErrorException- seeGError- Since:
- 2.20
-
deleteCookie
public void deleteCookie(Cookie cookie, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously delete aSoupCookiefrom the current session.When the operation is finished,
callbackwill be called. You can then call webkit_cookie_manager_delete_cookie_finish() to get the result of the operation.- Parameters:
cookie- theSoupCookieto be deletedcancellable- aGCancellableornullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.20
-
deleteCookieFinish
Finish an asynchronous operation started with webkit_cookie_manager_delete_cookie().- Parameters:
result- aGAsyncResult- Returns:
trueif the cookie was deleted orfalsein case of error.- Throws:
GErrorException- seeGError- Since:
- 2.20
-
getAcceptPolicy
public void getAcceptPolicy(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously get the cookie acceptance policy ofcookieManager.Note that when policy was set to
CookieAcceptPolicy.NO_THIRD_PARTYand ITP is enabled, this will returnCookieAcceptPolicy.ALWAYS. See also webkit_website_data_manager_set_itp_enabled().When the operation is finished,
callbackwill be called. You can then call webkit_cookie_manager_get_accept_policy_finish() to get the result of the operation.- Parameters:
cancellable- aGCancellableornullto ignorecallback- aGAsyncReadyCallbackto 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
Asynchronously get a list ofSoupCookiefromcookieManager.When the operation is finished,
callbackwill be called. You can then call webkit_cookie_manager_get_all_cookies_finish() to get the result of the operation.- Parameters:
cancellable- aGCancellableornullto ignorecallback- (closure user_data): aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.42
-
getAllCookiesFinish
Finish an asynchronous operation started with webkit_cookie_manager_get_all_cookies().The return value is a
GListofSoupCookieinstances which should be released with g_list_free_full() and soup_cookie_free().- Parameters:
result- aGAsyncResult- Returns:
- A
GListofSoupCookieinstances. - Throws:
GErrorException- seeGError- Since:
- 2.42
-
getCookies
public void getCookies(String uri, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously get a list ofSoupCookiefromcookieManager.Asynchronously get a list of
SoupCookiefrom this CookieManager associated withuri,which must be either an HTTP or an HTTPS URL.When the operation is finished,
callbackwill 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- aGCancellableornullto ignorecallback- aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.20
-
getCookiesFinish
Finish an asynchronous operation started with webkit_cookie_manager_get_cookies().The return value is a
GListofSoupCookieinstances which should be released with g_list_free_full() and soup_cookie_free().- Parameters:
result- aGAsyncResult- Returns:
- A
GListofSoupCookieinstances. - Throws:
GErrorException- seeGError- Since:
- 2.20
-
replaceCookies
public void replaceCookies(List<Cookie> cookies, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously replace all cookies in this CookieManager with the given list ofcookies.When the operation is finished,
callbackwill be called. You can then call webkit_cookie_manager_replace_cookies_finish() to get the result of the operation.- Parameters:
cookies- aGListofSoupCookieto be addedcancellable- aGCancellableornullto ignorecallback- (closure user_data): aGAsyncReadyCallbackto call when the request is satisfied- Since:
- 2.42
-
replaceCookiesFinish
Finish an asynchronous operation started with webkit_cookie_manager_replace_cookies().- Parameters:
result- aGAsyncResult- Returns:
trueif the cookies were added orfalsein case of error.- Throws:
GErrorException- seeGError- Since:
- 2.42
-
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
policyis set toCookieAcceptPolicy.NO_THIRD_PARTY,CookieAcceptPolicy.ALWAYSwill 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
filenamewhere non-session cookies are stored persistently usingstorageas the format to read/write the cookies. Cookies are initially read fromfilenameto create an initial set of cookies. Then, non-session cookies will be written tofilenamewhen 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
WebKitCookieManagerassociated 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.webkitgtk.CookieManager.ChangedCallback). -
builder
ACookieManager.Builderobject constructs aCookieManagerwith the specified properties. Use the variousset...()methods to set properties, and finish construction withCookieManager.Builder.build().- Returns:
- the builder object
-