Class GeckoRuntimeSettings.Builder

Object
org.mozilla.geckoview.RuntimeSettings.Builder<GeckoRuntimeSettings>
org.mozilla.geckoview.GeckoRuntimeSettings.Builder
Enclosing class:
GeckoRuntimeSettings

@AnyThread public static final class GeckoRuntimeSettings.Builder extends RuntimeSettings.Builder<GeckoRuntimeSettings>
Settings builder used to construct the settings object.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • newSettings

      @NonNull protected GeckoRuntimeSettings newSettings(@Nullable GeckoRuntimeSettings settings)
      Description copied from class: RuntimeSettings.Builder
      Create a default or copy settings object.
      Specified by:
      newSettings in class RuntimeSettings.Builder<GeckoRuntimeSettings>
      Parameters:
      settings - Settings object to copy, null for default settings.
      Returns:
      The constructed settings object.
    • arguments

      @NonNull public GeckoRuntimeSettings.Builder arguments(@NonNull String[] args)
      Set the custom Gecko process arguments.
      Parameters:
      args - The Gecko process arguments.
      Returns:
      This Builder instance.
    • extras

      @NonNull public GeckoRuntimeSettings.Builder extras(@NonNull Bundle extras)
      Set the custom Gecko intent extras.
      Parameters:
      extras - The Gecko intent extras.
      Returns:
      This Builder instance.
    • configFilePath

      @NonNull public GeckoRuntimeSettings.Builder configFilePath(@Nullable String configFilePath)
      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, on older devices this will be silently ignored.

      Parameters:
      configFilePath - Configuration file path to read from, or null to use default location /data/local/tmp/$PACKAGE-geckoview-config.yaml.
      Returns:
      This Builder instance.
    • extensionsProcessEnabled

      @NonNull public GeckoRuntimeSettings.Builder extensionsProcessEnabled(boolean flag)
      Set whether Extensions Process support should be enabled.
      Parameters:
      flag - A flag determining whether Extensions Process support should be enabled. Default is false.
      Returns:
      This Builder instance.
    • extensionsProcessCrashThreshold

      @NonNull public GeckoRuntimeSettings.Builder extensionsProcessCrashThreshold(@NonNull Integer crashThreshold)
      Set the crash threshold within the timeframe before spawning is disabled for the remote extensions process.
      Parameters:
      crashThreshold - The crash threshold within the timeframe before spawning is disabled.
      Returns:
      This Builder instance.
    • extensionsProcessCrashTimeframe

      @NonNull public GeckoRuntimeSettings.Builder extensionsProcessCrashTimeframe(@NonNull Long timeframeMs)
      Set the crash threshold timeframe before spawning is disabled for the remote extensions process. Crashes that are older than the current time minus timeframeMs will not be counted towards meeting the threshold.
      Parameters:
      timeframeMs - The timeframe for the crash threshold in milliseconds. Any crashes older than the current time minus the timeframeMs are not counted.
      Returns:
      This Builder instance.
    • javaScriptEnabled

      @NonNull public GeckoRuntimeSettings.Builder javaScriptEnabled(boolean flag)
      Set whether JavaScript support should be enabled.
      Parameters:
      flag - A flag determining whether JavaScript should be enabled. Default is true.
      Returns:
      This Builder instance.
    • globalPrivacyControlEnabled

      @NonNull public GeckoRuntimeSettings.Builder globalPrivacyControlEnabled(boolean enabled)
      Set whether Global Privacy Control should be enabled. GPC is a mechanism for people to tell websites to respect their privacy rights. Once turned on, it sends a signal to the websites users visit telling them that the user doesn't want to be tracked and doesn't want their data to be sold.
      Parameters:
      enabled - A flag determining whether Global Privacy Control should be enabled.
      Returns:
      The builder instance.
    • remoteDebuggingEnabled

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

      @NonNull public GeckoRuntimeSettings.Builder webFontsEnabled(boolean flag)
      Set whether support for web fonts should be enabled.
      Parameters:
      flag - A flag determining whether web fonts should be enabled. Default is true.
      Returns:
      This Builder instance.
    • pauseForDebugger

      @NonNull public GeckoRuntimeSettings.Builder pauseForDebugger(boolean enabled)
      Set whether there should be a pause during startup. This is useful if you need to wait for a debugger to attach.
      Parameters:
      enabled - A flag determining whether there will be a pause early in startup. Defaults to false.
      Returns:
      This Builder.
    • useMaxScreenDepth

      @NonNull public GeckoRuntimeSettings.Builder useMaxScreenDepth(boolean enable)
      Set whether the to report the full bit depth of the device.

      By default, 24 bits are reported for high memory devices and 16 bits for low memory devices. If set to true, the device's maximum bit depth is reported. On most modern devices this will be 32 bit screen depth.

      Parameters:
      enable - A flag determining whether maximum screen depth should be used.
      Returns:
      This Builder.
    • webManifest

      @NonNull public GeckoRuntimeSettings.Builder webManifest(boolean enabled)
      Set whether web manifest support is enabled.

      This controls if Gecko actually downloads, or "obtains", web manifests and processes them. Without setting this pref, trying to obtain a manifest throws.

      Parameters:
      enabled - A flag determining whether Web Manifest processing support is enabled.
      Returns:
      The builder instance.
    • consoleOutput

      @NonNull public GeckoRuntimeSettings.Builder consoleOutput(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:
      The builder instance.
    • automaticFontSizeAdjustment

      @NonNull public GeckoRuntimeSettings.Builder automaticFontSizeAdjustment(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.
      Parameters:
      enabled - A flag determining whether or not font sizes should be scaled automatically to match the device's system font scale.
      Returns:
      The builder instance.
    • fontSizeFactor

      @NonNull public GeckoRuntimeSettings.Builder fontSizeFactor(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.

      This setting cannot be modified if automatic font size adjustment has already been 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:
      The builder instance.
    • enterpriseRootsEnabled

      @NonNull public GeckoRuntimeSettings.Builder enterpriseRootsEnabled(boolean enabled)
      Enable the Enterprise Roots feature.

      When Enabled, GeckoView will fetch the third-party root certificates added to the Android OS CA store and will use them internally.

      Parameters:
      enabled - whether to enable this feature or not
      Returns:
      The builder instance
    • fontInflation

      @NonNull public GeckoRuntimeSettings.Builder fontInflation(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.

      This setting cannot be modified if automatic font size adjustment has already been enabled.

      Parameters:
      enabled - A flag determining whether or not font inflation should be enabled.
      Returns:
      The builder instance.
    • displayDensityOverride

      @NonNull public GeckoRuntimeSettings.Builder displayDensityOverride(float density)
      Set the display density override.
      Parameters:
      density - The display density value to use for overriding the system default.
      Returns:
      The builder instance.
    • displayDpiOverride

      @NonNull public GeckoRuntimeSettings.Builder displayDpiOverride(int dpi)
      Set the display DPI override.
      Parameters:
      dpi - The display DPI value to use for overriding the system default.
      Returns:
      The builder instance.
    • screenSizeOverride

      @NonNull public GeckoRuntimeSettings.Builder screenSizeOverride(int width, int height)
      Set the screen size override.
      Parameters:
      width - The screen width value to use for overriding the system default.
      height - The screen height value to use for overriding the system default.
      Returns:
      The builder instance.
    • loginAutofillEnabled

      @NonNull public GeckoRuntimeSettings.Builder loginAutofillEnabled(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.
    • translationsOfferPopup

      @NonNull public GeckoRuntimeSettings.Builder translationsOfferPopup(boolean enabled)
      Set whether a candidate page should automatically offer a translation via a popup.
      Parameters:
      enabled - A flag determining whether the translations offer popup should be enabled.
      Returns:
      The builder instance.
    • crashHandler

      @NonNull public GeckoRuntimeSettings.Builder crashHandler(@Nullable Class<? extends Service> handler)
      When set, the specified Service will be started by an Intent with action GeckoRuntime.ACTION_CRASHED when a crash is encountered. Crash details can be found in the Intent extras, such as GeckoRuntime.EXTRA_MINIDUMP_PATH.

      The crash handler Service must be declared to run in a different process from the GeckoRuntime. Additionally, the handler will be run as a foreground service, so the normal rules about activating a foreground service apply.

      In practice, you have one of three options once the crash handler is started:
      You can use CrashReporter to send the report to Mozilla, which provides Mozilla with data needed to fix the crash. Be aware that the minidump may contain personally identifiable information (PII). Consult Mozilla's privacy policy for information on how this data will be handled.
      Parameters:
      handler - The class for the crash handler Service.
      Returns:
      This builder instance.
      See Also:
    • locales

      @NonNull public GeckoRuntimeSettings.Builder locales(@Nullable String[] requestedLocales)
      Set the locale.
      Parameters:
      requestedLocales - List of locale codes in Gecko format ("en" or "en-US").
      Returns:
      The builder instance.
    • contentBlocking

      @NonNull public GeckoRuntimeSettings.Builder contentBlocking(@NonNull ContentBlocking.Settings cb)
    • preferredColorScheme

      @NonNull public GeckoRuntimeSettings.Builder preferredColorScheme(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 Builder instance.
    • inputAutoZoomEnabled

      @NonNull public GeckoRuntimeSettings.Builder inputAutoZoomEnabled(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 Builder instance.
    • doubleTapZoomingEnabled

      @NonNull public GeckoRuntimeSettings.Builder doubleTapZoomingEnabled(boolean flag)
      Set whether double tap zooming should be enabled.
      Parameters:
      flag - True if double tap zooming should be enabled, false otherwise.
      Returns:
      This Builder instance.
    • glMsaaLevel

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

      @AnyThread @NonNull public GeckoRuntimeSettings.Builder experimentDelegate(@Nullable ExperimentDelegate delegate)
      Set the ExperimentDelegate instance on this runtime, if any. This delegate is used to send and receive experiment information from Nimbus.
      Parameters:
      delegate - The ExperimentDelegate sending and retrieving experiment information.
      Returns:
      The builder instance.
    • debugLogging

      @NonNull public GeckoRuntimeSettings.Builder debugLogging(boolean enable)
      Enables GeckoView and Gecko Logging. Logging is on by default. Does not control all logging in Gecko. Logging done in Java code must be stripped out at build time.
      Parameters:
      enable - True if logging is enabled.
      Returns:
      This Builder instance.
    • aboutConfigEnabled

      @NonNull public GeckoRuntimeSettings.Builder aboutConfigEnabled(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 Builder instance.
    • forceUserScalableEnabled

      @NonNull public GeckoRuntimeSettings.Builder forceUserScalableEnabled(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 Builder instance.
    • allowInsecureConnections

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

      @NonNull public GeckoRuntimeSettings.Builder extensionsWebAPIEnabled(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 Builder instance.
    • trustedRecursiveResolverMode

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

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

      @NonNull public GeckoRuntimeSettings.Builder largeKeepaliveFactor(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 Builder instance.