Package org.mozilla.geckoview
Class GeckoRuntime
Object
org.mozilla.geckoview.GeckoRuntime
- All Implemented Interfaces:
Parcelable
Runtime environment for Gecko-based applications.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis is used to allow GeckoRuntime to start activities via the embedding application (andActivity).static @interfaceCrashed process visibility type definitions for process crash handling.static interfaceDelegate for handling GeckoRuntime lifecycle events.static interfaceDelegate for handling service worker events and requests.Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T extends Object>, Parcelable.Creator<T extends Object> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringIntent action sent to the crash handler when a crash is encountered.static final StringValue forEXTRA_CRASH_PROCESS_VISIBILITYindicating a background child process crashed.static final StringValue forEXTRA_CRASH_PROCESS_VISIBILITYindicating a foreground child process, such as a content process, crashed.static final StringValue forEXTRA_CRASH_PROCESS_VISIBILITYindicating the main application process was affected by the crash, which is therefore fatal.static final Parcelable.Creator<GeckoRuntime>Parcelable creator for GeckoRuntime instances.static final StringThis is a key for extra data sent withACTION_CRASHED.static final StringThis is a key for extra data sent withACTION_CRASHED.static final StringThis is a key for extra data sent withACTION_CRASHED.static final StringThis is a key for extra data sent withACTION_CRASHED.static final StringThis is a key for extra data sent withACTION_CRASHED.Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE -
Method Summary
Modifier and TypeMethodDescriptionvoidAppends notes to crash report.voidAttach the runtime to the given context.voidconfigurationChanged(Configuration newConfig) Notify Gecko that the device configuration has changed.static GeckoRuntimeCreate a new runtime with default settings and attach it to the given context.static GeckoRuntimecreate(Context context, GeckoRuntimeSettings settings) Create a new runtime with the given settings and attach it to the given context.intGet theGeckoRuntime.ActivityDelegateinstance set on this runtime, if any,Get theAutocomplete.StorageDelegateinstance set on this runtime.Returns the ContentBlockingController for this GeckoRuntime.Get theCrashPullController.Delegateinstance set on this runtime.static GeckoRuntimegetDefault(Context context) Get the default runtime for the given context.Returns the current delegate, if any.Get the orientation controller for this runtime.Get theGeckoPreferenceController.Observer.Delegateinstance set on this runtime, if any.Gets theGeckoRuntime.ServiceWorkerDelegateto be used for Service Worker requests.Get the runtime settings.Get the storage controller for this runtime.Returns a WebExtensionController for this GeckoRuntime.Returns the current WebNotificationDelegate, if anyGet the Web Push controller for this runtime.booleanWhether the default `interactive-widget` is `resizes-visual`.voidnotifyTelemetryPrefChanged(boolean isEnabled) Notifies Gecko observers of a telemetry preference change.voidNotify Gecko that the screen orientation has changed.voidorientationChanged(int newOrientation) Notify Gecko that the screen orientation has changed.voidreadFromParcel(Parcel source) Read runtime settings from a Parcel.voidSet theGeckoRuntime.ActivityDelegateinstance on this runtime.voidSet theAutocomplete.StorageDelegateinstance on this runtime.voidSet theCrashPullController.Delegateinstance set on this runtime.voidsetDelegate(GeckoRuntime.Delegate delegate) Set a delegate for receiving callbacks relevant to to this GeckoRuntime.voidSet theGeckoPreferenceController.Observer.Delegateinstance set on this runtime.voidsetServiceWorkerDelegate(GeckoRuntime.ServiceWorkerDelegate serviceWorkerDelegate) Sets theGeckoRuntime.ServiceWorkerDelegateto be used for Service Worker requests.voidSets the delegate to be used for handling Web Notifications.voidshutdown()Shutdown the runtime.voidwriteToParcel(Parcel out, int flags)
-
Field Details
-
ACTION_CRASHED
Intent action sent to the crash handler when a crash is encountered. -
EXTRA_MINIDUMP_PATH
This is a key for extra data sent withACTION_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. -
EXTRA_EXTRAS_PATH
This is a key for extra data sent withACTION_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 formKey=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_VISIBILITY
This is a key for extra data sent withACTION_CRASHED. The value is a String matching one of the `CRASHED_PROCESS_VISIBILITY_*` constants, describing what type of process the crash occurred in. -
EXTRA_CRASH_PROCESS_TYPE
This is a key for extra data sent withACTION_CRASHED. The value is a String identifier for the process type where the crash occurred. -
EXTRA_CRASH_REMOTE_TYPE
This is a key for extra data sent withACTION_CRASHED. The value is a String containing the content process type, which might not be available even for child processes. -
CRASHED_PROCESS_VISIBILITY_MAIN
Value forEXTRA_CRASH_PROCESS_VISIBILITYindicating the main application process was affected by the crash, which is therefore fatal.- See Also:
-
CRASHED_PROCESS_VISIBILITY_FOREGROUND_CHILD
Value forEXTRA_CRASH_PROCESS_VISIBILITYindicating 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_VISIBILITY_BACKGROUND_CHILD
Value forEXTRA_CRASH_PROCESS_VISIBILITYindicating 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
Parcelable creator for GeckoRuntime instances.
-
-
Method Details
-
getDefault
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
Attach the runtime to the given context.- Parameters:
context- The new context to attach to.
-
create
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
Returns a WebExtensionController for this GeckoRuntime.- Returns:
- an instance of
WebExtensionController.
-
getContentBlockingController
Returns the ContentBlockingController for this GeckoRuntime.- Returns:
- An instance of
ContentBlockingController.
-
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
Set a delegate for receiving callbacks relevant to to this GeckoRuntime.- Parameters:
delegate- an implementation ofGeckoRuntime.Delegate.
-
getDelegate
Returns the current delegate, if any.- Returns:
- an instance of
GeckoRuntime.Delegateor null if no delegate has been set.
-
setAutocompleteStorageDelegate
@UiThread public void setAutocompleteStorageDelegate(@Nullable Autocomplete.StorageDelegate delegate) Set theAutocomplete.StorageDelegateinstance on this runtime. This delegate is required for handling autocomplete storage requests.- Parameters:
delegate- TheAutocomplete.StorageDelegatehandling autocomplete storage requests.
-
getAutocompleteStorageDelegate
Get theAutocomplete.StorageDelegateinstance set on this runtime.- Returns:
- The
Autocomplete.StorageDelegateset on this runtime.
-
setCrashPullDelegate
Set theCrashPullController.Delegateinstance set on this runtime.- Parameters:
delegate- TheCrashPullController.Delegatehandling crash pull from Remote Settings.
-
getCrashPullDelegate
Get theCrashPullController.Delegateinstance set on this runtime.- Returns:
- The
CrashPullController.Delegateset on this runtime.
-
setPreferencesObserverDelegate
@AnyThread public void setPreferencesObserverDelegate(@Nullable GeckoPreferenceController.Observer.Delegate delegate) Set theGeckoPreferenceController.Observer.Delegateinstance set on this runtime.- Parameters:
delegate- The delegate to set on the runtime.
-
getPreferencesObserverDelegate
@AnyThread @Nullable public GeckoPreferenceController.Observer.Delegate getPreferencesObserverDelegate()Get theGeckoPreferenceController.Observer.Delegateinstance set on this runtime, if any.- Returns:
- The
GeckoPreferenceController.Observer.Delegateset on this runtime.
-
setServiceWorkerDelegate
@UiThread public void setServiceWorkerDelegate(@Nullable GeckoRuntime.ServiceWorkerDelegate serviceWorkerDelegate) Sets theGeckoRuntime.ServiceWorkerDelegateto be used for Service Worker requests.- Parameters:
serviceWorkerDelegate- An instance ofGeckoRuntime.ServiceWorkerDelegate.- See Also:
-
getServiceWorkerDelegate
Gets theGeckoRuntime.ServiceWorkerDelegateto be used for Service Worker requests.- Returns:
- the
GeckoRuntime.ServiceWorkerDelegateinstance set bysetServiceWorkerDelegate(org.mozilla.geckoview.GeckoRuntime.ServiceWorkerDelegate)
-
setWebNotificationDelegate
Sets the delegate to be used for handling Web Notifications.- Parameters:
delegate- An instance ofWebNotificationDelegate.- See Also:
-
getWebNotificationDelegate
Returns the current WebNotificationDelegate, if any- Returns:
- an instance of WebNotificationDelegate or null if no delegate has been set
-
setActivityDelegate
Set theGeckoRuntime.ActivityDelegateinstance on this runtime. This delegate is used to provide GeckoView support for launching external activities and receiving results from those activities.- Parameters:
delegate- TheGeckoRuntime.ActivityDelegatehandling intent launching requests.
-
getActivityDelegate
Get theGeckoRuntime.ActivityDelegateinstance set on this runtime, if any,- Returns:
- The
GeckoRuntime.ActivityDelegateset on this runtime.
-
getSettings
Get the runtime settings.- Returns:
- The GeckoRuntimeSettings for this runtime
-
orientationChanged
@UiThread public void orientationChanged()Notify Gecko that the screen orientation has changed. -
configurationChanged
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 currentConfiguration.
-
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
OrientationControllerfor this instance.
-
getStorageController
Get the storage controller for this runtime. The storage controller can be used to manage persistent storage data accumulated byGeckoSession.- Returns:
- The
StorageControllerfor this instance.
-
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
WebPushControllerfor this instance.
-
notifyTelemetryPrefChanged
@AnyThread public void notifyTelemetryPrefChanged(boolean isEnabled) Notifies Gecko observers of a telemetry preference change.- Parameters:
isEnabled- Whether telemetry is enabled or disabled.
-
appendAppNotesToCrashReport
Appends notes to crash report.- Parameters:
notes- The application notes to append to the crash report.
-
describeContents
@AnyThread public int describeContents()- Specified by:
describeContentsin interfaceParcelable
-
writeToParcel
- Specified by:
writeToParcelin interfaceParcelable
-
readFromParcel
Read runtime settings from a Parcel.- Parameters:
source- The Parcel to read from
-
isInteractiveWidgetDefaultResizesVisual
@AnyThread public boolean isInteractiveWidgetDefaultResizesVisual()Whether the default `interactive-widget` is `resizes-visual`.- Returns:
- True the default `interactive-widget` is `resizes-visual`, false otherwise.
-