Class StorageController
Retrieve an instance via GeckoRuntime.getStorageController()
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Flags used for data clearing operations.static @interface
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclearData
(long flags) Clear data for all hosts.void
clearDataForSessionContext
(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.getPermissions
(String uri) Get all currently stored permissions for a given URI and default (unset) context ID.getPermissions
(String uri, String contextId) Get all currently stored permissions for a given URI and context ID.void
setPermission
(String uri, int type, int value) Add or modify a permission for a URI given by String.void
setPermission
(String uri, String contextId, boolean privateMode, int type, int value) Add or modify a permission for a URI given by String.void
setPermission
(GeckoSession.PermissionDelegate.ContentPermission perm, int value) Set a new value for an existing permission.void
setPrivateBrowsingPermanentPermission
(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
GeckoResult
that 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
GeckoResult
that 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
GeckoResult
that 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
GeckoResult
that will complete with a list of all currently storedGeckoSession.PermissionDelegate.ContentPermission
s.
-
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.- Parameters:
uri
- A String representing the URI to get permissions for.- Returns:
- A
GeckoResult
that will complete with a list of all currently storedGeckoSession.PermissionDelegate.ContentPermission
s for the URI.
-
getPermissions
@AnyThread @NonNull public GeckoResult<List<GeckoSession.PermissionDelegate.ContentPermission>> getPermissions(@NonNull String uri, @Nullable String contextId) 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.- Returns:
- A
GeckoResult
that will complete with a list of all currently storedGeckoSession.PermissionDelegate.ContentPermission
s 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.ContentPermission
that 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.ContentPermission
that you wish to update the value of.value
- The new value for the permission.- See Also:
-
setPermission
@AnyThread @DeprecationSchedule(id="setpermission-string", version=93) public void setPermission(@NonNull String uri, int type, int value) Add or modify a permission for a URI given by String. Assumes default context ID and regular (non-private) browsing mode.- Parameters:
uri
- A String representing the URI for which you are adding/modifying permissions.type
- An int representing the permission you wish to add/modify.value
- The new value for the permission.
-
setPermission
@AnyThread @DeprecationSchedule(id="setpermission-string", version=93) public void setPermission(@NonNull String uri, @Nullable String contextId, boolean privateMode, int type, int value) Add or modify a permission for a URI given by String.- Parameters:
uri
- A String representing the URI for which you are adding/modifying permissions.contextId
- A String specifying the context ID under which the permission will apply.privateMode
- A boolean indicating whether this permission should apply in private mode or normal mode.type
- An int representing the permission you wish to add/modify.value
- The new value for the permission.
-