Class StorageController
Retrieve an instance via GeckoRuntime.getStorageController().
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFlags used for data clearing operations.static @interfaceClear flags for storage controller operations. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclearData(long flags) Clear data for all hosts.voidclearDataForSessionContext(String contextId) Clear data for the given context ID.clearDataFromBaseDomain(String baseDomain, long flags) Clear data owned by the given base domain (eTLD+1).clearDataFromHost(String host, long flags) Clear data owned by the given host.Get all currently stored permissions.getCookieBannerModeForDomain(String uri, boolean isPrivateBrowsing) Gets the actualContentBlocking.CBCookieBannerModefor the given uri and browsing mode.getPermissions(String uri) Get all currently stored permissions for a given URI and default (unset) context ID, in normal mode This API will be deprecated in the future https://bugzilla.mozilla.org/show_bug.cgi?id=1797379getPermissions(String uri, boolean privateMode) Get all currently stored permissions for a given URI and default (unset) context ID.getPermissions(String uri, String contextId, boolean privateMode) Get all currently stored permissions for a given URI and context ID.removeCookieBannerModeForDomain(String uri, boolean isPrivateBrowsing) Removes aContentBlocking.CBCookieBannerModefor the given uri and and browsing mode.setCookieBannerModeAndPersistInPrivateBrowsingForDomain(String uri, int mode) Set a permanentContentBlocking.CBCookieBannerModefor the given uri in private mode.setCookieBannerModeForDomain(String uri, int mode, boolean isPrivateBrowsing) Set a permanentContentBlocking.CBCookieBannerModefor the given uri and browsing mode.voidsetPermission(GeckoSession.PermissionDelegate.ContentPermission perm, int value) Set a new value for an existing permission.voidsetPrivateBrowsingPermanentPermission(GeckoSession.PermissionDelegate.ContentPermission perm, int value) Set a permanent value for a permission in a private browsing session.
-
Constructor Details
-
StorageController
public StorageController()
-
-
Method Details
-
clearData
Clear data for all hosts.Note: Any open session may re-accumulate previously cleared data. To ensure that no persistent data is left behind, you need to close all sessions prior to clearing data.
- Parameters:
flags- Combination ofStorageController.ClearFlags.- Returns:
- A
GeckoResultthat will complete when clearing has finished.
-
clearDataFromHost
Clear data owned by the given host. Clearing data for a host will not clear data created by its third-party origins.Note: Any open session may re-accumulate previously cleared data. To ensure that no persistent data is left behind, you need to close all sessions prior to clearing data.
- Parameters:
host- The host to be used.flags- Combination ofStorageController.ClearFlags.- Returns:
- A
GeckoResultthat will complete when clearing has finished.
-
clearDataFromBaseDomain
@AnyThread @NonNull public GeckoResult<Void> clearDataFromBaseDomain(@NonNull String baseDomain, long flags) Clear data owned by the given base domain (eTLD+1). Clearing data for a base domain will also clear any associated third-party storage. This includes clearing for third-parties embedded by the domain and for the given domain embedded under other sites.Note: Any open session may re-accumulate previously cleared data. To ensure that no persistent data is left behind, you need to close all sessions prior to clearing data.
- Parameters:
baseDomain- The base domain to be used.flags- Combination ofStorageController.ClearFlags.- Returns:
- A
GeckoResultthat will complete when clearing has finished.
-
clearDataForSessionContext
Clear data for the given context ID. UseGeckoSessionSettings.Builder.contextId(java.lang.String).to set a context ID for a session.Note: Any open session may re-accumulate previously cleared data. To ensure that no persistent data is left behind, you need to close all sessions for the given context prior to clearing data.
- Parameters:
contextId- The context ID for the storage data to be deleted.
-
getAllPermissions
@AnyThread @NonNull public GeckoResult<List<GeckoSession.PermissionDelegate.ContentPermission>> getAllPermissions()Get all currently stored permissions.- Returns:
- A
GeckoResultthat will complete with a list of all currently storedGeckoSession.PermissionDelegate.ContentPermissions.
-
getPermissions
@AnyThread @NonNull public GeckoResult<List<GeckoSession.PermissionDelegate.ContentPermission>> getPermissions(@NonNull String uri) Get all currently stored permissions for a given URI and default (unset) context ID, in normal mode This API will be deprecated in the future https://bugzilla.mozilla.org/show_bug.cgi?id=1797379- Parameters:
uri- A String representing the URI to get permissions for.- Returns:
- A
GeckoResultthat will complete with a list of all currently storedGeckoSession.PermissionDelegate.ContentPermissions for the URI.
-
getPermissions
@AnyThread @NonNull public GeckoResult<List<GeckoSession.PermissionDelegate.ContentPermission>> getPermissions(@NonNull String uri, boolean privateMode) Get all currently stored permissions for a given URI and default (unset) context ID.- Parameters:
uri- A String representing the URI to get permissions for.privateMode- indicate where theGeckoSession.PermissionDelegate.ContentPermissions should be in private or normal mode.- Returns:
- A
GeckoResultthat will complete with a list of all currently storedGeckoSession.PermissionDelegate.ContentPermissions for the URI.
-
getPermissions
@AnyThread @NonNull public GeckoResult<List<GeckoSession.PermissionDelegate.ContentPermission>> getPermissions(@NonNull String uri, @Nullable String contextId, boolean privateMode) Get all currently stored permissions for a given URI and context ID.- Parameters:
uri- A String representing the URI to get permissions for.contextId- A String specifying the context ID.privateMode- indicate where theGeckoSession.PermissionDelegate.ContentPermissions should be in private or normal mode- Returns:
- A
GeckoResultthat will complete with a list of all currently storedGeckoSession.PermissionDelegate.ContentPermissions for the URI.
-
setPermission
@AnyThread public void setPermission(@NonNull GeckoSession.PermissionDelegate.ContentPermission perm, int value) Set a new value for an existing permission.Note: in private browsing, this value will only be cleared at the end of the session to add permanent permissions in private browsing, you can use
setPrivateBrowsingPermanentPermission(org.mozilla.geckoview.GeckoSession.PermissionDelegate.ContentPermission, int).- Parameters:
perm- AGeckoSession.PermissionDelegate.ContentPermissionthat you wish to update the value of.value- The new value for the permission.
-
setPrivateBrowsingPermanentPermission
@AnyThread public void setPrivateBrowsingPermanentPermission(@NonNull GeckoSession.PermissionDelegate.ContentPermission perm, int value) Set a permanent value for a permission in a private browsing session.Normally permissions in private browsing are cleared at the end of the session. This method allows you to set a permanent permission bypassing this behavior.
Note: permanent permissions in private browsing are web discoverable and might make the user more easily trackable.
- Parameters:
perm- AGeckoSession.PermissionDelegate.ContentPermissionthat you wish to update the value of.value- The new value for the permission.- See Also:
-
setCookieBannerModeForDomain
@AnyThread @NonNull public GeckoResult<Void> setCookieBannerModeForDomain(@NonNull String uri, int mode, boolean isPrivateBrowsing) Set a permanentContentBlocking.CBCookieBannerModefor the given uri and browsing mode.- Parameters:
uri- An uri for which you want change theContentBlocking.CBCookieBannerModevalue.mode- A newContentBlocking.CBCookieBannerModefor the given uri.isPrivateBrowsing- Indicates in which browsing mode the givenContentBlocking.CBCookieBannerModeshould be applied.- Returns:
- A
GeckoResultthat will complete when the mode has been set.
-
setCookieBannerModeAndPersistInPrivateBrowsingForDomain
@AnyThread @NonNull public GeckoResult<Void> setCookieBannerModeAndPersistInPrivateBrowsingForDomain(@NonNull String uri, int mode) Set a permanentContentBlocking.CBCookieBannerModefor the given uri in private mode.- Parameters:
uri- for which you want to change theContentBlocking.CBCookieBannerModevalue.mode- A newContentBlocking.CBCookieBannerModefor the given uri.- Returns:
- A
GeckoResultthat will complete when the mode has been set.
-
removeCookieBannerModeForDomain
@AnyThread @NonNull public GeckoResult<Void> removeCookieBannerModeForDomain(@NonNull String uri, boolean isPrivateBrowsing) Removes aContentBlocking.CBCookieBannerModefor the given uri and and browsing mode.- Parameters:
uri- An uri for which you want change theContentBlocking.CBCookieBannerModevalue.isPrivateBrowsing- Indicates in which mode the given mode should be applied.- Returns:
- A
GeckoResultthat will complete when the mode has been removed.
-
getCookieBannerModeForDomain
@AnyThread @NonNull public GeckoResult<Integer> getCookieBannerModeForDomain(@NonNull String uri, boolean isPrivateBrowsing) Gets the actualContentBlocking.CBCookieBannerModefor the given uri and browsing mode.- Parameters:
uri- An uri for which you want get theContentBlocking.CBCookieBannerMode.isPrivateBrowsing- Indicates in which browsing mode the given uri should be.- Returns:
- A
GeckoResultthat resolves to aContentBlocking.CBCookieBannerModefor the given uri and browsing mode.
-