Interface PrivacyManager

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    
    public interface PrivacyManager
     implements AutoCloseable
                        

    Manages the lifecycle of privacy contexts, including permanent and temporary contexts. Permanent contexts have a long lifecycle and are never deleted, while temporary contexts are short-lived and discarded if a privacy leak is detected.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract String buildStatusString() Builds a status string summarizing the current state of active contexts.
      abstract Unit maintain(Boolean force) Performs maintenance tasks on the privacy manager.
      abstract Unit reset(String reason) Resets the privacy environment by closing all privacy contexts.
      abstract FetchResult run(FetchTask task, SuspendFunction2<FetchTask, WebDriver, FetchResult> fetchFun) Runs a fetch task within a privacy context.
      abstract PrivacyContext getOrCreate(BrowserProfile profile) Gets or creates a privacy context for the given browser profile.
      abstract PrivacyContext createUnmanagedContext(BrowserProfile profile) Creates an unmanaged privacy context for the given browser profile.
      abstract PrivacyContext createUnmanagedContext(BrowserProfile profile, WebDriverFetcher fetcher) Creates an unmanaged privacy context for the given browser profile and fetcher.
      abstract Unit close(PrivacyContext privacyContext) Closes a given privacy context, moving it from the active list to the zombie list.
      abstract Boolean isActive() Indicates whether the privacy manager is active.
      abstract Boolean isClosed() Indicates whether the privacy manager is closed.
      abstract ImmutableConfig getConf() The immutable configuration used by the privacy manager.
      • Methods inherited from class java.lang.AutoCloseable

        close
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • buildStatusString

         abstract String buildStatusString()

        Builds a status string summarizing the current state of active contexts.

        Returns:

        A string representation of the active contexts' status.

      • maintain

         abstract Unit maintain(Boolean force)

        Performs maintenance tasks on the privacy manager.

        Parameters:
        force - If true, forces maintenance tasks to run.
      • reset

         abstract Unit reset(String reason)

        Resets the privacy environment by closing all privacy contexts.

        Parameters:
        reason - The reason for resetting the privacy environment.
      • run

         abstract FetchResult run(FetchTask task, SuspendFunction2<FetchTask, WebDriver, FetchResult> fetchFun)

        Runs a fetch task within a privacy context.

        The privacy context is selected from the active privacy context pool, and it is supposed to have at least one ready web driver to run the task. If the chosen context is not ready to serve, the task will be canceled.

        Parameters:
        task - The fetch task to execute.
        fetchFun - The function to execute the fetch task.
        Returns:

        The result of the fetch task.

      • getOrCreate

         abstract PrivacyContext getOrCreate(BrowserProfile profile)

        Gets or creates a privacy context for the given browser profile.

        Parameters:
        profile - The browser profile associated with the context.
        Returns:

        The privacy context.

      • createUnmanagedContext

         abstract PrivacyContext createUnmanagedContext(BrowserProfile profile)

        Creates an unmanaged privacy context for the given browser profile.

        Parameters:
        profile - The browser profile associated with the context.
        Returns:

        The unmanaged privacy context.

      • createUnmanagedContext

         abstract PrivacyContext createUnmanagedContext(BrowserProfile profile, WebDriverFetcher fetcher)

        Creates an unmanaged privacy context for the given browser profile and fetcher.

        Parameters:
        profile - The browser profile associated with the context.
        fetcher - The web driver fetcher used to create the context.
        Returns:

        The unmanaged privacy context.

      • close

         abstract Unit close(PrivacyContext privacyContext)

        Closes a given privacy context, moving it from the active list to the zombie list.

        Parameters:
        privacyContext - The privacy context to close.
      • isActive

         abstract Boolean isActive()

        Indicates whether the privacy manager is active.

      • isClosed

         abstract Boolean isClosed()

        Indicates whether the privacy manager is closed.

      • getConf

         abstract ImmutableConfig getConf()

        The immutable configuration used by the privacy manager.