Class GeckoRuntime

Object
org.mozilla.geckoview.GeckoRuntime
All Implemented Interfaces:
Parcelable

public final class GeckoRuntime extends Object implements Parcelable
  • Field Details

    • ACTION_CRASHED

      public static final String ACTION_CRASHED
      Intent action sent to the crash handler when a crash is encountered.
      See Also:
    • EXTRA_MINIDUMP_PATH

      public static final String EXTRA_MINIDUMP_PATH
      This is a key for extra data sent with ACTION_CRASHED. It refers to a String with the path to a Breakpad minidump file containing information about the crash. Several crash reporters are able to ingest this in a crash report, including Sentry and Mozilla's Socorro.

      Be aware, the minidump can contain personally identifiable information. Ensure you are obeying all applicable laws and policies before sending this to a remote server.
      See Also:
    • EXTRA_EXTRAS_PATH

      public static final String EXTRA_EXTRAS_PATH
      This is a key for extra data sent with ACTION_CRASHED. It refers to a string with the path to a file containing extra metadata about the crash. The file contains key-value pairs in the form
      Key=Value
      Be aware, it may contain sensitive data such as the URI that was loaded at the time of the crash.
      See Also:
    • EXTRA_CRASH_PROCESS_TYPE

      public static final String EXTRA_CRASH_PROCESS_TYPE
      This is a key for extra data sent with ACTION_CRASHED. The value is a String matching one of the `CRASHED_PROCESS_TYPE_*` constants, describing what type of process the crash occurred in.
      See Also:
    • CRASHED_PROCESS_TYPE_MAIN

      public static final String CRASHED_PROCESS_TYPE_MAIN
      Value for EXTRA_CRASH_PROCESS_TYPE indicating the main application process was affected by the crash, which is therefore fatal.
      See Also:
    • CRASHED_PROCESS_TYPE_FOREGROUND_CHILD

      public static final String CRASHED_PROCESS_TYPE_FOREGROUND_CHILD
      Value for EXTRA_CRASH_PROCESS_TYPE indicating a foreground child process, such as a content process, crashed. The application may be able to recover from this crash, but it was likely noticable to the user.
      See Also:
    • CRASHED_PROCESS_TYPE_BACKGROUND_CHILD

      public static final String CRASHED_PROCESS_TYPE_BACKGROUND_CHILD
      Value for EXTRA_CRASH_PROCESS_TYPE indicating a background child process crashed. This should have been recovered from automatically, and will have had minimal impact to the user, if any.
      See Also:
    • CREATOR

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

    • getDefault

      @UiThread @NonNull public static GeckoRuntime getDefault(@NonNull Context context)
      Get the default runtime for the given context. This will create and initialize the runtime with the default settings.

      Note: Only use this for session-less apps. For regular apps, use create() instead.

      Parameters:
      context - An application context for the default runtime.
      Returns:
      The (static) default runtime for the context.
    • attachTo

      @UiThread public void attachTo(@NonNull Context context)
      Attach the runtime to the given context.
      Parameters:
      context - The new context to attach to.
    • create

      @UiThread @NonNull public static GeckoRuntime create(@NonNull Context context)
      Create a new runtime with default settings and attach it to the given context.

      Create will throw if there is already an active Gecko instance running, to prevent that, bind the runtime to the process lifetime instead of the activity lifetime.

      Parameters:
      context - The context of the runtime.
      Returns:
      An initialized runtime.
    • getWebExtensionController

      @UiThread @NonNull public WebExtensionController getWebExtensionController()
      Returns a WebExtensionController for this GeckoRuntime.
      Returns:
      an instance of WebExtensionController.
    • getContentBlockingController

      @UiThread @NonNull public ContentBlockingController getContentBlockingController()
      Returns the ContentBlockingController for this GeckoRuntime.
      Returns:
      An instance of ContentBlockingController.
    • getProfilerController

      @UiThread @NonNull public ProfilerController getProfilerController()
      Returns a ProfilerController for this GeckoRuntime.
      Returns:
      an instance of ProfilerController.
    • create

      @UiThread @NonNull public static GeckoRuntime create(@NonNull Context context, @NonNull GeckoRuntimeSettings settings)
      Create a new runtime with the given settings and attach it to the given context.

      Create will throw if there is already an active Gecko instance running, to prevent that, bind the runtime to the process lifetime instead of the activity lifetime.

      Parameters:
      context - The context of the runtime.
      settings - The settings for the runtime.
      Returns:
      An initialized runtime.
    • shutdown

      @AnyThread public void shutdown()
      Shutdown the runtime. This will invalidate all attached sessions.
    • setDelegate

      @UiThread public void setDelegate(@Nullable GeckoRuntime.Delegate delegate)
      Set a delegate for receiving callbacks relevant to to this GeckoRuntime.
      Parameters:
      delegate - an implementation of GeckoRuntime.Delegate.
    • getDelegate

      @UiThread @Nullable public GeckoRuntime.Delegate getDelegate()
      Returns the current delegate, if any.
      Returns:
      an instance of GeckoRuntime.Delegate or null if no delegate has been set.
    • setAutocompleteStorageDelegate

      @UiThread public void setAutocompleteStorageDelegate(@Nullable Autocomplete.StorageDelegate delegate)
      Set the Autocomplete.StorageDelegate instance on this runtime. This delegate is required for handling autocomplete storage requests.
      Parameters:
      delegate - The Autocomplete.StorageDelegate handling autocomplete storage requests.
    • getAutocompleteStorageDelegate

      @UiThread @Nullable public Autocomplete.StorageDelegate getAutocompleteStorageDelegate()
      Get the Autocomplete.StorageDelegate instance set on this runtime.
      Returns:
      The Autocomplete.StorageDelegate set on this runtime.
    • setServiceWorkerDelegate

      @UiThread public void setServiceWorkerDelegate(@Nullable GeckoRuntime.ServiceWorkerDelegate serviceWorkerDelegate)
      Sets the GeckoRuntime.ServiceWorkerDelegate to be used for Service Worker requests.
      Parameters:
      serviceWorkerDelegate - An instance of GeckoRuntime.ServiceWorkerDelegate.
      See Also:
    • getServiceWorkerDelegate

      @UiThread @Nullable public GeckoRuntime.ServiceWorkerDelegate getServiceWorkerDelegate()
      Gets the GeckoRuntime.ServiceWorkerDelegate to be used for Service Worker requests.
      Returns:
      the GeckoRuntime.ServiceWorkerDelegate instance set by setServiceWorkerDelegate(org.mozilla.geckoview.GeckoRuntime.ServiceWorkerDelegate)
    • setWebNotificationDelegate

      @UiThread public void setWebNotificationDelegate(@Nullable WebNotificationDelegate delegate)
      Sets the delegate to be used for handling Web Notifications.
      Parameters:
      delegate - An instance of WebNotificationDelegate.
      See Also:
    • getWebNotificationDelegate

      @UiThread @Nullable public WebNotificationDelegate getWebNotificationDelegate()
      Returns the current WebNotificationDelegate, if any
      Returns:
      an instance of WebNotificationDelegate or null if no delegate has been set
    • setActivityDelegate

      @UiThread public void setActivityDelegate(@Nullable GeckoRuntime.ActivityDelegate delegate)
      Set the GeckoRuntime.ActivityDelegate instance on this runtime. This delegate is used to provide GeckoView support for launching external activities and receiving results from those activities.
      Parameters:
      delegate - The GeckoRuntime.ActivityDelegate handling intent launching requests.
    • getActivityDelegate

      @UiThread @Nullable public GeckoRuntime.ActivityDelegate getActivityDelegate()
      Get the GeckoRuntime.ActivityDelegate instance set on this runtime, if any,
      Returns:
      The GeckoRuntime.ActivityDelegate set on this runtime.
    • getSettings

      @AnyThread @NonNull public GeckoRuntimeSettings getSettings()
    • orientationChanged

      @UiThread public void orientationChanged()
      Notify Gecko that the screen orientation has changed.
    • configurationChanged

      @UiThread public void configurationChanged(@NonNull Configuration newConfig)
      Notify Gecko that the device configuration has changed.
      Parameters:
      newConfig - The new Configuration object, Configuration.
    • orientationChanged

      @UiThread public void orientationChanged(int newOrientation)
      Notify Gecko that the screen orientation has changed.
      Parameters:
      newOrientation - The new screen orientation, as retrieved e.g. from the current Configuration.
    • getOrientationController

      @UiThread @NonNull public OrientationController getOrientationController()
      Get the orientation controller for this runtime. The orientation controller can be used to manage changes to and locking of the screen orientation.
      Returns:
      The OrientationController for this instance.
    • getStorageController

      @UiThread @NonNull public StorageController getStorageController()
      Get the storage controller for this runtime. The storage controller can be used to manage persistent storage data accumulated by GeckoSession.
      Returns:
      The StorageController for this instance.
    • getWebPushController

      @UiThread @NonNull public WebPushController getWebPushController()
      Get the Web Push controller for this runtime. The Web Push controller can be used to allow content to use the Web Push API.
      Returns:
      The WebPushController for this instance.
    • appendAppNotesToCrashReport

      @AnyThread public void appendAppNotesToCrashReport(@NonNull String notes)
      Appends notes to crash report.
      Parameters:
      notes - The application notes to append to the crash report.
    • describeContents

      @AnyThread public int describeContents()
      Specified by:
      describeContents in interface Parcelable
    • writeToParcel

      @AnyThread public void writeToParcel(Parcel out, int flags)
      Specified by:
      writeToParcel in interface Parcelable
    • readFromParcel

      @AnyThread public void readFromParcel(@NonNull Parcel source)