Class GeckoRuntimeSettings

Object
org.mozilla.geckoview.RuntimeSettings
org.mozilla.geckoview.GeckoRuntimeSettings
All Implemented Interfaces:
Parcelable

@AnyThread public final class GeckoRuntimeSettings extends RuntimeSettings
  • Field Details

    • COLOR_SCHEME_LIGHT

      public static final int COLOR_SCHEME_LIGHT
      A light theme for web content is preferred.
      See Also:
    • COLOR_SCHEME_DARK

      public static final int COLOR_SCHEME_DARK
      A dark theme for web content is preferred.
      See Also:
    • COLOR_SCHEME_SYSTEM

      public static final int COLOR_SCHEME_SYSTEM
      The preferred color scheme will be based on system settings.
      See Also:
    • ALLOW_ALL

      public static final int ALLOW_ALL
      Allow all insecure connections
      See Also:
    • HTTPS_ONLY_PRIVATE

      public static final int HTTPS_ONLY_PRIVATE
      Allow insecure connections in normal browsing, but only HTTPS in private browsing.
      See Also:
    • HTTPS_ONLY

      public static final int HTTPS_ONLY
      Only allow HTTPS connections.
      See Also:
    • TRR_MODE_OFF

      public static final int TRR_MODE_OFF
      Off (default). Use native DNS resolution by default.
      See Also:
    • TRR_MODE_FIRST

      public static final int TRR_MODE_FIRST
      First. Use TRR first, and only if the name resolve fails use the native resolver as a fallback.
      See Also:
    • TRR_MODE_ONLY

      public static final int TRR_MODE_ONLY
      Only. Only use TRR, never use the native resolver.
      See Also:
    • TRR_MODE_DISABLED

      public static final int TRR_MODE_DISABLED
      Off by choice. This is the same as 0 but marks it as done by choice and not done by default.
      See Also:
    • CREATOR

      public static final Parcelable.Creator<GeckoRuntimeSettings> CREATOR
  • Method Details

    • getContentBlocking

      @NonNull public ContentBlocking.Settings getContentBlocking()
    • getRuntime

      @Nullable public GeckoRuntime getRuntime()
    • getArguments

      @NonNull public String[] getArguments()
      Get the custom Gecko process arguments.
      Returns:
      The Gecko process arguments.
    • getExtras

      @NonNull public Bundle getExtras()
      Get the custom Gecko intent extras.
      Returns:
      The Gecko intent extras.
    • getConfigFilePath

      @Nullable public String getConfigFilePath()
      Path to configuration file from which GeckoView will read configuration options such as Gecko process arguments, environment variables, and preferences.

      Note: this feature is only available for Build.VERSION.SDK_INT > 21.

      Returns:
      Path to configuration file from which GeckoView will read configuration options, or null for default location /data/local/tmp/$PACKAGE-geckoview-config.yaml .
    • getJavaScriptEnabled

      public boolean getJavaScriptEnabled()
      Get whether JavaScript support is enabled.
      Returns:
      Whether JavaScript support is enabled.
    • setJavaScriptEnabled

      @NonNull public GeckoRuntimeSettings setJavaScriptEnabled(boolean flag)
      Set whether JavaScript support should be enabled.
      Parameters:
      flag - A flag determining whether JavaScript should be enabled.
      Returns:
      This GeckoRuntimeSettings instance.
    • setGlobalPrivacyControl

      @NonNull public GeckoRuntimeSettings setGlobalPrivacyControl(boolean enabled)
      Enable the Global Privacy Control Feature.

      Note: Global Privacy Control is always enabled in private mode.

      Parameters:
      enabled - A flag determining whether GPC should be enabled.
      Returns:
      This GeckoRuntimeSettings instance
    • getExtensionsProcessEnabled

      @Nullable public Boolean getExtensionsProcessEnabled()
      Get whether Extensions Process support is enabled.
      Returns:
      Whether Extensions Process support is enabled.
    • setExtensionsProcessEnabled

      @NonNull public GeckoRuntimeSettings setExtensionsProcessEnabled(boolean flag)
      Set whether Extensions Process support should be enabled.
      Parameters:
      flag - A flag determining whether Extensions Process support should be enabled.
      Returns:
      This GeckoRuntimeSettings instance.
    • getExtensionsProcessCrashThreshold

      @Nullable public Integer getExtensionsProcessCrashThreshold()
      Get the crash threshold before spawning is disabled for the remote extensions process.
      Returns:
      the crash threshold
    • getExtensionsProcessCrashTimeframe

      @Nullable public Long getExtensionsProcessCrashTimeframe()
      Get the timeframe in milliseconds for the threshold before spawning is disabled for the remote extensions process.
      Returns:
      the timeframe in milliseconds for the crash threshold
    • setExtensionsProcessCrashThreshold

      @NonNull public GeckoRuntimeSettings setExtensionsProcessCrashThreshold(@NonNull Integer crashThreshold)
      Set the crash threshold before disabling spawning of the extensions remote process.
      Parameters:
      crashThreshold - max crashes allowed
      Returns:
      This GeckoRuntimeSettings instance.
    • setExtensionsProcessCrashTimeframe

      @NonNull public GeckoRuntimeSettings setExtensionsProcessCrashTimeframe(@NonNull Long timeframeMs)
      Set the timeframe for the extensions process crash threshold. Any crashes older than the current time minus the timeframe are not included in the crash count.
      Parameters:
      timeframeMs - time in milliseconds
      Returns:
      This GeckoRuntimeSettings instance.
    • getRemoteDebuggingEnabled

      public boolean getRemoteDebuggingEnabled()
      Get whether remote debugging support is enabled.
      Returns:
      True if remote debugging support is enabled.
    • setRemoteDebuggingEnabled

      @NonNull public GeckoRuntimeSettings setRemoteDebuggingEnabled(boolean enabled)
      Set whether remote debugging support should be enabled.
      Parameters:
      enabled - True if remote debugging should be enabled.
      Returns:
      This GeckoRuntimeSettings instance.
    • getWebFontsEnabled

      public boolean getWebFontsEnabled()
      Get whether web fonts support is enabled.
      Returns:
      Whether web fonts support is enabled.
    • setWebFontsEnabled

      @NonNull public GeckoRuntimeSettings setWebFontsEnabled(boolean flag)
      Set whether support for web fonts should be enabled.
      Parameters:
      flag - A flag determining whether web fonts should be enabled.
      Returns:
      This GeckoRuntimeSettings instance.
    • getPauseForDebuggerEnabled

      public boolean getPauseForDebuggerEnabled()
      Gets whether the pause-for-debugger is enabled or not.
      Returns:
      True if the pause is enabled.
    • getForceEnableAccessibility

      public boolean getForceEnableAccessibility()
      Gets whether accessibility is force enabled or not.
      Returns:
      true if accessibility is force enabled.
    • setForceEnableAccessibility

      @NonNull public GeckoRuntimeSettings setForceEnableAccessibility(boolean value)
      Sets whether accessibility is force enabled or not.

      Useful when testing accessibility.

      Parameters:
      value - whether accessibility is force enabled or not
      Returns:
      this GeckoRuntimeSettings instance.
    • getUseMaxScreenDepth

      public boolean getUseMaxScreenDepth()
      Gets whether the compositor should use the maximum screen depth when rendering.
      Returns:
      True if the maximum screen depth should be used.
    • getDisplayDensityOverride

      @Nullable public Float getDisplayDensityOverride()
      Gets the display density override value.
      Returns:
      Returns a positive number. Will return null if not set.
    • getDisplayDpiOverride

      @Nullable public Integer getDisplayDpiOverride()
      Gets the display DPI override value.
      Returns:
      Returns a positive number. Will return null if not set.
    • getCrashHandler

      @Nullable public Class<? extends Service> getCrashHandler()
    • getScreenSizeOverride

      @Nullable public Rect getScreenSizeOverride()
      Gets the screen size override value.
      Returns:
      Returns a Rect containing the dimensions to use for the window size. Will return null if not set.
    • getLocales

      @Nullable public String[] getLocales()
      Gets the list of requested locales.
      Returns:
      A list of locale codes in Gecko format ("en" or "en-US").
    • setLocales

      public void setLocales(@Nullable String[] requestedLocales)
      Set the locale.
      Parameters:
      requestedLocales - An ordered list of locales in Gecko format ("en-US").
    • getExtensionsWebAPIEnabled

      public boolean getExtensionsWebAPIEnabled()
      Gets whether the Add-on Manager web API (`mozAddonManager`) is enabled.
      Returns:
      True when the web API is enabled, false otherwise.
    • getGlobalPrivacyControl

      public boolean getGlobalPrivacyControl()
      Get whether or not Global Privacy Control is currently enabled for normal tabs.
      Returns:
      True if GPC is enabled in normal tabs.
    • getGlobalPrivacyControlPrivateMode

      public boolean getGlobalPrivacyControlPrivateMode()
      Get whether or not Global Privacy Control is currently enabled for private tabs.
      Returns:
      True if GPC is enabled in private tabs.
    • setExtensionsWebAPIEnabled

      @NonNull public GeckoRuntimeSettings setExtensionsWebAPIEnabled(boolean flag)
      Sets whether the Add-on Manager web API (`mozAddonManager`) is enabled.
      Parameters:
      flag - True if the web API should be enabled, false otherwise.
      Returns:
      This GeckoRuntimeSettings instance.
    • setWebManifestEnabled

      @NonNull public GeckoRuntimeSettings setWebManifestEnabled(boolean enabled)
      Sets whether Web Manifest processing support is enabled.
      Parameters:
      enabled - A flag determining whether Web Manifest processing support is enabled.
      Returns:
      This GeckoRuntimeSettings instance.
    • getWebManifestEnabled

      public boolean getWebManifestEnabled()
      Get whether or not Web Manifest processing support is enabled.
      Returns:
      True if web manifest processing support is enabled.
    • setConsoleOutputEnabled

      @NonNull public GeckoRuntimeSettings setConsoleOutputEnabled(boolean enabled)
      Set whether or not web console messages should go to logcat.

      Note: If enabled, Gecko performance may be negatively impacted if content makes heavy use of the console API.

      Parameters:
      enabled - A flag determining whether or not web console messages should be printed to logcat.
      Returns:
      This GeckoRuntimeSettings instance.
    • getConsoleOutputEnabled

      public boolean getConsoleOutputEnabled()
      Get whether or not web console messages are sent to logcat.
      Returns:
      True if console output is enabled.
    • setAutomaticFontSizeAdjustment

      @NonNull public GeckoRuntimeSettings setAutomaticFontSizeAdjustment(boolean enabled)
      Set whether or not font sizes in web content should be automatically scaled according to the device's current system font scale setting. Enabling this will prevent modification of the font size factor. Disabling this setting will restore the previously used value for the font size factor.
      Parameters:
      enabled - A flag determining whether or not font sizes should be scaled automatically to match the device's system font scale.
      Returns:
      This GeckoRuntimeSettings instance.
    • getAutomaticFontSizeAdjustment

      public boolean getAutomaticFontSizeAdjustment()
      Get whether or not the font sizes for web content are automatically adjusted to match the device's system font scale setting.
      Returns:
      True if font sizes are automatically adjusted.
    • setFontSizeFactor

      @NonNull public GeckoRuntimeSettings setFontSizeFactor(float fontSizeFactor)
      Set a font size factor that will operate as a global text zoom. All font sizes will be multiplied by this factor.

      The default factor is 1.0.

      Currently, any changes only take effect after a reload of the session.

      This setting cannot be modified while automatic font size adjustment is enabled.

      Parameters:
      fontSizeFactor - The factor to be used for scaling all text. Setting a value of 0 disables both this feature and font inflation.
      Returns:
      This GeckoRuntimeSettings instance.
    • setEnterpriseRootsEnabled

      @NonNull public GeckoRuntimeSettings setEnterpriseRootsEnabled(boolean enabled)
    • getEnterpriseRootsEnabled

      public boolean getEnterpriseRootsEnabled()
      Gets whether the Enteprise Roots feature is enabled or not.
      Returns:
      true if the feature is enabled, false otherwise.
    • getFontSizeFactor

      public float getFontSizeFactor()
      Gets the currently applied font size factor.
      Returns:
      The currently applied font size factor.
    • setFontInflationEnabled

      @NonNull public GeckoRuntimeSettings setFontInflationEnabled(boolean enabled)
      Set whether or not font inflation for non mobile-friendly pages should be enabled. The default value of this setting is false.

      When enabled, font sizes will be increased on all pages that are lacking a <meta> viewport tag and have been loaded in a session using GeckoSessionSettings.VIEWPORT_MODE_MOBILE. To improve readability, the font inflation logic will attempt to increase font sizes for the main text content of the page only.

      The magnitude of font inflation applied depends on the font size factor currently in use.

      Currently, any changes only take effect after a reload of the session.

      Parameters:
      enabled - A flag determining whether or not font inflation should be enabled.
      Returns:
      This GeckoRuntimeSettings instance.
    • getFontInflationEnabled

      public boolean getFontInflationEnabled()
      Get whether or not font inflation for non mobile-friendly pages is currently enabled.
      Returns:
      True if font inflation is enabled.
    • getPreferredColorScheme

      public int getPreferredColorScheme()
      Gets the preferred color scheme override for web content.
      Returns:
      One of the COLOR_SCHEME_* constants.
    • setPreferredColorScheme

      @NonNull public GeckoRuntimeSettings setPreferredColorScheme(int scheme)
      Sets the preferred color scheme override for web content.
      Parameters:
      scheme - The preferred color scheme. Must be one of the COLOR_SCHEME_* constants.
      Returns:
      This GeckoRuntimeSettings instance.
    • getInputAutoZoomEnabled

      public boolean getInputAutoZoomEnabled()
      Gets whether auto-zoom to editable fields is enabled.
      Returns:
      True if auto-zoom is enabled, false otherwise.
    • setInputAutoZoomEnabled

      @NonNull public GeckoRuntimeSettings setInputAutoZoomEnabled(boolean flag)
      Set whether auto-zoom to editable fields should be enabled.
      Parameters:
      flag - True if auto-zoom should be enabled, false otherwise.
      Returns:
      This GeckoRuntimeSettings instance.
    • getDoubleTapZoomingEnabled

      public boolean getDoubleTapZoomingEnabled()
      Gets whether double-tap zooming is enabled.
      Returns:
      True if double-tap zooming is enabled, false otherwise.
    • setDoubleTapZoomingEnabled

      @NonNull public GeckoRuntimeSettings setDoubleTapZoomingEnabled(boolean flag)
      Sets whether double tap zooming is enabled.
      Parameters:
      flag - true if double tap zooming should be enabled, false otherwise.
      Returns:
      This GeckoRuntimeSettings instance.
    • getGlMsaaLevel

      public int getGlMsaaLevel()
      Gets the current WebGL MSAA level.
      Returns:
      number of MSAA samples, 0 if MSAA is disabled.
    • setGlMsaaLevel

      @NonNull public GeckoRuntimeSettings setGlMsaaLevel(int level)
      Sets the WebGL MSAA level.
      Parameters:
      level - number of MSAA samples, 0 if MSAA should be disabled.
      Returns:
      This GeckoRuntimeSettings instance.
    • getExperimentDelegate

      @AnyThread @Nullable public ExperimentDelegate getExperimentDelegate()
      Get the ExperimentDelegate instance set on this runtime, if any,
      Returns:
      The ExperimentDelegate set on this runtime.
    • getAboutConfigEnabled

      public boolean getAboutConfigEnabled()
      Gets whether about:config is enabled or not.
      Returns:
      True if about:config is enabled, false otherwise.
    • setAboutConfigEnabled

      @NonNull public GeckoRuntimeSettings setAboutConfigEnabled(boolean flag)
      Sets whether or not about:config should be enabled. This is a page that allows users to directly modify Gecko preferences. Modification of some preferences may cause the app to break in unpredictable ways -- crashes, performance issues, security vulnerabilities, etc.
      Parameters:
      flag - True if about:config should be enabled, false otherwise.
      Returns:
      This GeckoRuntimeSettings instance.
    • getForceUserScalableEnabled

      public boolean getForceUserScalableEnabled()
      Gets whether or not force user scalable zooming should be enabled or not.
      Returns:
      True if force user scalable zooming should be enabled, false otherwise.
    • setForceUserScalableEnabled

      @NonNull public GeckoRuntimeSettings setForceUserScalableEnabled(boolean flag)
      Sets whether or not pinch-zooming should be enabled when user-scalable=no is set on the viewport.
      Parameters:
      flag - True if force user scalable zooming should be enabled, false otherwise.
      Returns:
      This GeckoRuntimeSettings instance.
    • getLoginAutofillEnabled

      public boolean getLoginAutofillEnabled()
      Get whether login form autofill is enabled.
      Returns:
      True if login autofill is enabled.
    • setTranslationsOfferPopup

      @NonNull public GeckoRuntimeSettings setTranslationsOfferPopup(boolean enabled)
      Set whether automatic popups should appear for offering translations on candidate pages.
      Parameters:
      enabled - A flag determining whether automatic offer popups should be enabled for translations.
      Returns:
      The builder instance.
    • getTranslationsOfferPopup

      public boolean getTranslationsOfferPopup()
      Get whether automatic popups for translations is enabled.
      Returns:
      True if login automatic popups for translations are enabled.
    • setLoginAutofillEnabled

      @NonNull public GeckoRuntimeSettings setLoginAutofillEnabled(boolean enabled)
      Set whether login forms should be filled automatically if only one viable candidate is provided via onLoginFetch.
      Parameters:
      enabled - A flag determining whether login autofill should be enabled.
      Returns:
      The builder instance.
    • getAllowInsecureConnections

      public int getAllowInsecureConnections()
      Get whether and where insecure (non-HTTPS) connections are allowed.
      Returns:
      One of the HttpsOnlyMode constants.
    • setAllowInsecureConnections

      @NonNull public GeckoRuntimeSettings setAllowInsecureConnections(int level)
      Set whether and where insecure (non-HTTPS) connections are allowed.
      Parameters:
      level - One of the HttpsOnlyMode constants.
      Returns:
      This GeckoRuntimeSettings instance.
    • getTrustedRecusiveResolverMode

      public int getTrustedRecusiveResolverMode()
      Get whether and how DNS-over-HTTPS (Trusted Recursive Resolver) is configured.
      Returns:
      One of the TrustedRecursiveResolverMode constants.
    • getLargeKeepaliveFactor

      @NonNull public int getLargeKeepaliveFactor()
      Get the factor by which to increase the keepalive timeout when the NS_HTTP_LARGE_KEEPALIVE flag is used for a connection.
      Returns:
      An integer factor.
    • setTrustedRecursiveResolverMode

      @NonNull public GeckoRuntimeSettings setTrustedRecursiveResolverMode(int mode)
      Set whether and how DNS-over-HTTPS (Trusted Recursive Resolver) is configured.
      Parameters:
      mode - One of the TrustedRecursiveResolverMode constants.
      Returns:
      This GeckoRuntimeSettings instance.
    • setLargeKeepaliveFactor

      @NonNull public GeckoRuntimeSettings setLargeKeepaliveFactor(int factor)
      Set the factor by which to increase the keepalive timeout when the NS_HTTP_LARGE_KEEPALIVE flag is used for a connection.
      Parameters:
      factor - FACTOR by which to increase the keepalive timeout.
      Returns:
      This GeckoRuntimeSettings instance.
    • getTrustedRecursiveResolverUri

      @NonNull public String getTrustedRecursiveResolverUri()
      Get the DNS-over-HTTPS (DoH) server URI.
      Returns:
      URI of the DoH server.
    • setTrustedRecursiveResolverUri

      @NonNull public GeckoRuntimeSettings setTrustedRecursiveResolverUri(@NonNull String uri)
      Set the DNS-over-HTTPS server URI.
      Parameters:
      uri - URI of the DNS-over-HTTPS server.
      Returns:
      This GeckoRuntimeSettings instance.
    • writeToParcel

      public void writeToParcel(Parcel out, int flags)
      Specified by:
      writeToParcel in interface Parcelable
      Overrides:
      writeToParcel in class RuntimeSettings
    • readFromParcel

      public void readFromParcel(@NonNull Parcel source)
      Overrides:
      readFromParcel in class RuntimeSettings