Class StorageController

Object
org.mozilla.geckoview.StorageController

public final class StorageController extends Object
Manage runtime storage data.

Retrieve an instance via GeckoRuntime.getStorageController().

  • Constructor Details

    • StorageController

      public StorageController()
  • Method Details

    • clearData

      @AnyThread @NonNull public GeckoResult<Void> clearData(long flags)
      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 of StorageController.ClearFlags.
      Returns:
      A GeckoResult that will complete when clearing has finished.
    • clearDataFromHost

      @AnyThread @NonNull public GeckoResult<Void> clearDataFromHost(@NonNull String host, long flags)
      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 of StorageController.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 of StorageController.ClearFlags.
      Returns:
      A GeckoResult that will complete when clearing has finished.
    • clearDataForSessionContext

      @AnyThread public void clearDataForSessionContext(@NonNull String contextId)
      Clear data for the given context ID. Use GeckoSessionSettings.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 stored GeckoSession.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.
      Parameters:
      uri - A String representing the URI to get permissions for.
      Returns:
      A GeckoResult that will complete with a list of all currently stored GeckoSession.PermissionDelegate.ContentPermissions 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 stored GeckoSession.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 - A GeckoSession.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 - A GeckoSession.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.