Class ContentBlocking.Settings

Object
org.mozilla.geckoview.RuntimeSettings
org.mozilla.geckoview.ContentBlocking.Settings
All Implemented Interfaces:
Parcelable
Enclosing class:
ContentBlocking

@AnyThread public static class ContentBlocking.Settings extends RuntimeSettings
  • Field Details

  • Method Details

    • updatePrefs

      protected void updatePrefs(@NonNull RuntimeSettings settings)
      Description copied from class: RuntimeSettings
      Update the prefs based on the provided settings.
      Overrides:
      updatePrefs in class RuntimeSettings
      Parameters:
      settings - Copy from this settings.
    • getSafeBrowsingProviders

      @NonNull public Collection<ContentBlocking.SafeBrowsingProvider> getSafeBrowsingProviders()
      Get the collection of ContentBlocking.SafeBrowsingProvider for this runtime.
      Returns:
      an unmodifiable collection of ContentBlocking.SafeBrowsingProvider
      See Also:
    • setSafeBrowsingProviders

      @NonNull public ContentBlocking.Settings setSafeBrowsingProviders(@NonNull ContentBlocking.SafeBrowsingProvider... providers)
      Sets the collection of ContentBlocking.SafeBrowsingProvider for this runtime.

      By default the collection is composed of ContentBlocking.GOOGLE_LEGACY_SAFE_BROWSING_PROVIDER and ContentBlocking.GOOGLE_SAFE_BROWSING_PROVIDER.

      Parameters:
      providers - ContentBlocking.SafeBrowsingProvider instances for this runtime.
      Returns:
      the ContentBlocking.Settings instance.
      See Also:
    • getSafeBrowsingPhishingTable

      @NonNull public String[] getSafeBrowsingPhishingTable()
      Get the table for SafeBrowsing Phishing. The identifiers present in this table must match one of the identifiers present in ContentBlocking.SafeBrowsingProvider.getLists().
      Returns:
      an array of identifiers for SafeBrowsing's Phishing feature
      See Also:
    • setSafeBrowsingPhishingTable

      @NonNull public ContentBlocking.Settings setSafeBrowsingPhishingTable(@NonNull String... table)
      Sets the table for SafeBrowsing Phishing.
      Parameters:
      table - an array of identifiers for SafeBrowsing's Phishing feature.
      Returns:
      this ContentBlocking.Settings instance.
      See Also:
    • getSafeBrowsingMalwareTable

      @NonNull public String[] getSafeBrowsingMalwareTable()
      Get the table for SafeBrowsing Malware. The identifiers present in this table must match one of the identifiers present in ContentBlocking.SafeBrowsingProvider.getLists().
      Returns:
      an array of identifiers for SafeBrowsing's Malware feature
      See Also:
    • setQueryParameterStrippingAllowList

      @NonNull public ContentBlocking.Settings setQueryParameterStrippingAllowList(@NonNull String... list)
      Sets the allowed list for the query parameter stripping feature.
      Parameters:
      list - an array of identifiers for the allowed list of the query parameter's stripping feature.
      Returns:
      this ContentBlocking.Settings instance.
    • getQueryParameterStrippingAllowList

      @NonNull public String[] getQueryParameterStrippingAllowList()
      Get the allowed list for the query parameter stripping feature.
      Returns:
      an array of identifiers for the allowed list for the query parameter stripping feature.
    • setQueryParameterStrippingStripList

      @NonNull public ContentBlocking.Settings setQueryParameterStrippingStripList(@NonNull String... list)
      Sets the strip list for the query parameter stripping feature.
      Parameters:
      list - an array of identifiers for the strip list of the query parameter's stripping feature.
      Returns:
      this ContentBlocking.Settings instance.
    • getQueryParameterStrippingStripList

      @NonNull public String[] getQueryParameterStrippingStripList()
      Get the strip list for the query parameter stripping feature
      Returns:
      an array of identifiers for the allowed list for the query parameter stripping feature.
    • setSafeBrowsingMalwareTable

      @NonNull public ContentBlocking.Settings setSafeBrowsingMalwareTable(@NonNull String... table)
      Sets the table for SafeBrowsing Malware.
      Parameters:
      table - an array of identifiers for SafeBrowsing's Malware feature.
      Returns:
      this ContentBlocking.Settings instance.
      See Also:
    • setAntiTracking

      @NonNull public ContentBlocking.Settings setAntiTracking(int cat)
      Set anti-tracking categories.
      Parameters:
      cat - The categories of resources that should be blocked. Use one or more of the ContentBlocking.AntiTracking flags.
      Returns:
      This Settings instance.
    • setEnhancedTrackingProtectionLevel

      @NonNull public ContentBlocking.Settings setEnhancedTrackingProtectionLevel(int level)
      Set the ETP behavior level.
      Parameters:
      level - The level of ETP blocking to use; must be one of ContentBlocking.EtpLevel flags. Only takes effect if the cookie behavior is ContentBlocking.CookieBehavior.ACCEPT_NON_TRACKERS or ContentBlocking.CookieBehavior.ACCEPT_FIRST_PARTY_AND_ISOLATE_OTHERS.
      Returns:
      This Settings instance.
    • setStrictSocialTrackingProtection

      @NonNull public ContentBlocking.Settings setStrictSocialTrackingProtection(boolean enabled)
      Set whether or not strict social tracking protection is enabled (ie, whether to block content or just cookies). Will only block if social tracking protection lists are supplied to setAntiTracking(int).
      Parameters:
      enabled - A boolean indicating whether or not to enable strict social tracking protection.
      Returns:
      This Settings instance.
    • setSafeBrowsing

      @NonNull public ContentBlocking.Settings setSafeBrowsing(int cat)
      Set safe browsing categories.
      Parameters:
      cat - The categories of resources that should be blocked. Use one or more of the ContentBlocking.SafeBrowsing flags.
      Returns:
      This Settings instance.
    • getAntiTrackingCategories

      public int getAntiTrackingCategories()
      Get the set anti-tracking categories.
      Returns:
      The categories of resources to be blocked.
    • getEnhancedTrackingProtectionLevel

      public int getEnhancedTrackingProtectionLevel()
      Get the set ETP behavior level.
      Returns:
      The current ETP level; one of ContentBlocking.EtpLevel.
    • getStrictSocialTrackingProtection

      public boolean getStrictSocialTrackingProtection()
      Get whether or not strict social tracking protection is enabled.
      Returns:
      A boolean indicating whether or not strict social tracking protection is enabled.
    • getSafeBrowsingCategories

      public int getSafeBrowsingCategories()
      Get the set safe browsing categories.
      Returns:
      The categories of resources to be blocked.
    • getCookieBehavior

      public int getCookieBehavior()
      Get the assigned cookie storage behavior.
      Returns:
      The assigned behavior, as one of ContentBlocking.CookieBehavior flags.
    • setCookieBehavior

      @NonNull public ContentBlocking.Settings setCookieBehavior(int behavior)
      Set cookie storage behavior.
      Parameters:
      behavior - The storage behavior that should be applied. Use one of the ContentBlocking.CookieBehavior flags.
      Returns:
      This Settings instance.
    • getCookieBehaviorPrivateMode

      public int getCookieBehaviorPrivateMode()
      Get the assigned private mode cookie storage behavior.
      Returns:
      The assigned behavior, as one of ContentBlocking.CookieBehavior flags.
    • setCookieBehaviorPrivateMode

      @NonNull public ContentBlocking.Settings setCookieBehaviorPrivateMode(int behavior)
      Set cookie storage behavior for private browsing mode.
      Parameters:
      behavior - The storage behavior that should be applied. Use one of the ContentBlocking.CookieBehavior flags.
      Returns:
      This Settings instance.
    • getCookiePurging

      public boolean getCookiePurging()
      Get whether or not cookie purging is enabled.
      Returns:
      A boolean indicating whether or not cookie purging is enabled.
    • setCookiePurging

      @NonNull public ContentBlocking.Settings setCookiePurging(boolean enabled)
      Enable or disable cookie purging. This will automatically purge cookies from tracking sites that have no recent user interaction, provided the cookie behavior is set to ContentBlocking.CookieBehavior.ACCEPT_NON_TRACKERS or ContentBlocking.CookieBehavior.ACCEPT_FIRST_PARTY_AND_ISOLATE_OTHERS.
      Parameters:
      enabled - A boolean indicating whether to enable cookie purging.
      Returns:
      This Settings instance.
    • setCookieBannerMode

      @NonNull public ContentBlocking.Settings setCookieBannerMode(int mode)
      Set the Cookie Banner Handling Mode to the new provided ContentBlocking.CBCookieBannerMode value.
      Parameters:
      mode - Integer indicating the new mode.
      Returns:
      This Settings instance.
    • setCookieBannerDetectOnlyMode

      @NonNull public ContentBlocking.Settings setCookieBannerDetectOnlyMode(boolean enabled)
      When set to true, cookie banners are detected and detection events are dispatched, but they will not be handled. Requires the service to be enabled for the desired mode via setCookieBannerMode.
      Parameters:
      enabled - A boolean indicating whether to enable cookie banners.
      Returns:
      This Settings instance.
    • setCookieBannerGlobalRulesEnabled

      @NonNull public ContentBlocking.Settings setCookieBannerGlobalRulesEnabled(boolean enabled)
      Enables/disables the use of global CookieBannerRules, which apply to all sites. This enable handling of CMPs across sites without the use of site-specific rules.
      Parameters:
      enabled - A boolean indicating whether or not to enable.
      Returns:
      This Settings instance.
    • getCookieBannerGlobalRulesEnabled

      public boolean getCookieBannerGlobalRulesEnabled()
      Indicates if global CookieBannerRules is enabled or not.
      Returns:
      Indicates if global CookieBannerRule is enabled or disabled.
    • setCookieBannerGlobalRulesSubFramesEnabled

      @NonNull public ContentBlocking.Settings setCookieBannerGlobalRulesSubFramesEnabled(boolean enabled)
      Whether global rules are allowed to run in sub-frames. Running query selectors in every sub-frame may negatively impact performance, but is required for some CMPs.
      Parameters:
      enabled - A boolean indicating whether or not to enable.
      Returns:
      This Settings instance.
    • getEmailTrackerBlockingPrivateBrowsingEnabled

      @NonNull public Boolean getEmailTrackerBlockingPrivateBrowsingEnabled()
      Indicates if email tracker blocking is enabled in private mode.
      Returns:
      Indicates if email tracker blocking is enabled or disabled in private mode.
    • setEmailTrackerBlockingPrivateBrowsing

      @NonNull public ContentBlocking.Settings setEmailTrackerBlockingPrivateBrowsing(boolean enabled)
      Sets whether email tracker blocking is enabled in private mode.
      Parameters:
      enabled - A boolean indicating whether or not to enable.
      Returns:
      This Settings instance.
    • setQueryParameterStrippingEnabled

      @NonNull public ContentBlocking.Settings setQueryParameterStrippingEnabled(boolean enabled)
      Sets whether query parameter stripping is enabled in normal mode.
      Parameters:
      enabled - A boolean indicating whether or not to enable.
      Returns:
      This Settings instance.
    • getQueryParameterStrippingEnabled

      public boolean getQueryParameterStrippingEnabled()
      Indicates if query parameter stripping is enabled in normal mode.
      Returns:
      Indicates if query parameter stripping is enabled or disabled in normal mode.
    • setQueryParameterStrippingPrivateBrowsingEnabled

      @NonNull public ContentBlocking.Settings setQueryParameterStrippingPrivateBrowsingEnabled(boolean enabled)
      Sets Whether query parameter stripping is enabled in private mode.
      Parameters:
      enabled - A boolean indicating whether or not to enable in private mode.
      Returns:
      This Settings instance.
    • getQueryParameterStrippingPrivateBrowsingEnabled

      public boolean getQueryParameterStrippingPrivateBrowsingEnabled()
      Indicates if query parameter stripping is enabled in private mode.
      Returns:
      Indicates if global CookieBannerRules is enabled or disabled in sub-frames.
    • getCookieBannerGlobalRulesSubFramesEnabled

      public boolean getCookieBannerGlobalRulesSubFramesEnabled()
      Indicates if global CookieBannerRules is enabled or not in sub-frames.
      Returns:
      Indicates if global CookieBannerRules is enabled or disabled in sub-frames.
    • getCookieBannerDetectOnlyMode

      public boolean getCookieBannerDetectOnlyMode()
      Indicates if cookie banner handling detect only mode is enabled.
      Returns:
      boolean indicating if the cookie banner handling detect only mode setting is enabled.
    • getCookieBannerMode

      public int getCookieBannerMode()
      Gets the current cookie banner handling mode.
      Returns:
      int the current cookie banner handling mode, one of the ContentBlocking.CBCookieBannerMode.
    • setCookieBannerModePrivateBrowsing

      @NonNull public ContentBlocking.Settings setCookieBannerModePrivateBrowsing(int mode)
      Set the Cookie Banner Handling Mode for private browsing to the new provided ContentBlocking.CBCookieBannerMode value.
      Parameters:
      mode - Integer indicating the new mode.
      Returns:
      This Settings instance.
    • getCookieBannerModePrivateBrowsing

      public int getCookieBannerModePrivateBrowsing()
      Gets the current cookie banner handling mode for private browsing.
      Returns:
      int the current cookie banner handling mode, one of the ContentBlocking.CBCookieBannerMode.