Class UserContentFilterStore

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public final class UserContentFilterStore extends GObject

Handles storage of user content filters on disk.

The WebKitUserContentFilterStore provides the means to import and save JSON rule sets, which can be loaded later in an efficient manner. Once filters are stored, the WebKitUserContentFilter objects which represent them can be added to a WebKitUserContentManager with webkit_user_content_manager_add_filter().

JSON rule sets are imported using webkit_user_content_filter_store_save() and stored on disk in an implementation defined format. The contents of a filter store must be managed using the WebKitUserContentFilterStore: a list of all the stored filters can be obtained with webkit_user_content_filter_store_fetch_identifiers(), webkit_user_content_filter_store_load() can be used to retrieve a previously saved filter, and removed from the store with webkit_user_content_filter_store_remove().

Since:
2.24
  • Constructor Details

    • UserContentFilterStore

      public UserContentFilterStore(MemorySegment address)
      Create a UserContentFilterStore instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • UserContentFilterStore

      public UserContentFilterStore(String storagePath)

      Create a new WebKitUserContentFilterStore to manipulate filters stored at storagePath.

      The path must point to a local filesystem, and will be created if needed.

      Parameters:
      storagePath - path where data for filters will be stored on disk
      Since:
      2.24
    • UserContentFilterStore

      public UserContentFilterStore()
      Create a new UserContentFilterStore.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the UserContentFilterStore class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected UserContentFilterStore asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • fetchIdentifiers

      public void fetchIdentifiers(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Asynchronously retrieve a list of the identifiers for all the stored filters.

      When the operation is finished, callback will be invoked, which then can use webkit_user_content_filter_store_fetch_identifiers_finish() to obtain the list of filter identifiers.

      Parameters:
      cancellable - a GCancellable or null to ignore
      callback - a GAsyncReadyCallback to call when the removal is completed
      Since:
      2.24
    • fetchIdentifiersFinish

      public String[] fetchIdentifiersFinish(AsyncResult result)

      Finishes an asynchronous fetch of the list of stored filters.

      Finishes an asynchronous fetch of the list of identifiers for the stored filters previously started with webkit_user_content_filter_store_fetch_identifiers().

      Parameters:
      result - a GAsyncResult
      Returns:
      a null-terminated list of filter identifiers.
      Since:
      2.24
    • getPath

      public String getPath()
      Gets the storage path for user content filters.
      Returns:
      path, as a string.
      Since:
      2.24
    • load

      public void load(String identifier, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Asynchronously load a content filter given its identifier.

      The filter must have been previously stored using webkit_user_content_filter_store_save().

      When the operation is finished, callback will be invoked, which then can use webkit_user_content_filter_store_load_finish() to obtain the resulting filter.

      Parameters:
      identifier - a filter identifier
      cancellable - a GCancellable or null to ignore
      callback - a GAsyncReadyCallback to call when the load is completed
      Since:
      2.24
    • loadFinish

      public UserContentFilter loadFinish(AsyncResult result) throws GErrorException
      Finishes an asynchronous filter load previously started with webkit_user_content_filter_store_load().
      Parameters:
      result - a GAsyncResult
      Returns:
      a WebKitUserContentFilter, or null if the load failed
      Throws:
      GErrorException - see GError
      Since:
      2.24
    • remove

      public void remove(String identifier, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Asynchronously remove a content filter given its identifier.

      When the operation is finished, callback will be invoked, which then can use webkit_user_content_filter_store_remove_finish() to check whether the removal was successful.

      Parameters:
      identifier - a filter identifier
      cancellable - a GCancellable or null to ignore
      callback - a GAsyncReadyCallback to call when the removal is completed
      Since:
      2.24
    • removeFinish

      public boolean removeFinish(AsyncResult result) throws GErrorException
      Finishes an asynchronous filter removal previously started with webkit_user_content_filter_store_remove().
      Parameters:
      result - a GAsyncResult
      Returns:
      whether the removal was successful
      Throws:
      GErrorException - see GError
      Since:
      2.24
    • save

      public void save(String identifier, byte[] source, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Asynchronously save a content filter from a set source rule.

      Asynchronously save a content filter from a source rule set in the WebKit content extesions JSON format.

      The identifier can be used afterwards to refer to the filter when using webkit_user_content_filter_store_remove() and webkit_user_content_filter_store_load(). When the identifier has been used in the past, the new filter source will replace the one saved beforehand for the same identifier.

      When the operation is finished, callback will be invoked, which then can use webkit_user_content_filter_store_save_finish() to obtain the resulting filter.

      Parameters:
      identifier - a string used to identify the saved filter
      source - GBytes containing the rule set in JSON format
      cancellable - a GCancellable or null to ignore
      callback - a GAsyncReadyCallback to call when saving is completed
      Since:
      2.24
    • saveFinish

      public UserContentFilter saveFinish(AsyncResult result) throws GErrorException
      Finishes an asynchronous filter save previously started with webkit_user_content_filter_store_save().
      Parameters:
      result - a GAsyncResult
      Returns:
      a WebKitUserContentFilter, or null if saving failed
      Throws:
      GErrorException - see GError
      Since:
      2.24
    • saveFromFile

      public void saveFromFile(String identifier, File file, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Asynchronously save a content filter from the contents of a file.

      Asynchronously save a content filter from the contents of a file, which must be native to the platform, as checked by g_file_is_native(). See webkit_user_content_filter_store_save() for more details.

      When the operation is finished, callback will be invoked, which then can use webkit_user_content_filter_store_save_finish() to obtain the resulting filter.

      Parameters:
      identifier - a string used to identify the saved filter
      file - a GFile containing the rule set in JSON format
      cancellable - a GCancellable or null to ignore
      callback - a GAsyncReadyCallback to call when saving is completed
      Since:
      2.24
    • saveFromFileFinish

      public UserContentFilter saveFromFileFinish(AsyncResult result) throws GErrorException
      Finishes and asynchronous filter save previously started with webkit_user_content_filter_store_save_from_file().
      Parameters:
      result - a GAsyncResult
      Returns:
      a WebKitUserContentFilter, or null if saving failed.
      Throws:
      GErrorException - see GError
      Since:
      2.24
    • builder

      A UserContentFilterStore.Builder object constructs a UserContentFilterStore with the specified properties. Use the various set...() methods to set properties, and finish construction with UserContentFilterStore.Builder.build().
      Returns:
      the builder object