public class GeckoSession extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
GeckoSession.ContentDelegate |
static class |
GeckoSession.FinderResult
Represent the result of a find-in-page operation.
|
static interface |
GeckoSession.HistoryDelegate
An interface for recording new history visits and fetching the visited
status for links.
|
static class |
GeckoSession.Loader
Main entry point for loading URIs into a
GeckoSession . |
static interface |
GeckoSession.MediaDelegate
GeckoSession applications implement this interface to handle media events.
|
static interface |
GeckoSession.NavigationDelegate |
static interface |
GeckoSession.PermissionDelegate
GeckoSession applications implement this interface to handle requests for permissions
from content, such as geolocation and notifications.
|
static interface |
GeckoSession.ProgressDelegate |
static interface |
GeckoSession.PromptDelegate
GeckoSession applications implement this interface to handle prompts triggered by
content in the GeckoSession, such as alerts, authentication dialogs, and select list
pickers.
|
static interface |
GeckoSession.ScrollDelegate
GeckoSession applications implement this interface to handle content scroll
events.
|
static interface |
GeckoSession.SelectionActionDelegate |
static class |
GeckoSession.SessionState
Class representing a saved session state.
|
static interface |
GeckoSession.TextInputDelegate
Interface that SessionTextInput uses for performing operations such as opening and closing
the software keyboard.
|
static class |
GeckoSession.WebResponseInfo
WebResponseInfo contains information about a single web response.
|
Modifier and Type | Field and Description |
---|---|
static int |
FINDER_DISPLAY_DIM_PAGE
Dim the rest of the page when showing a find-in-page match.
|
static int |
FINDER_DISPLAY_DRAW_LINK_OUTLINE
Draw outlines around matching links.
|
static int |
FINDER_DISPLAY_HIGHLIGHT_ALL
Highlight all find-in-page matches.
|
static int |
FINDER_FIND_BACKWARDS
Go backwards when finding the next match.
|
static int |
FINDER_FIND_LINKS_ONLY
Limit matches to links on the page.
|
static int |
FINDER_FIND_MATCH_CASE
Perform case-sensitive match; default is to perform a case-insensitive match.
|
static int |
FINDER_FIND_WHOLE_WORD
Must match entire words; default is to allow matching partial words.
|
static int |
HEADER_FILTER_CORS_SAFELISTED
Filter headers according to the CORS safelisted rules.
|
static int |
HEADER_FILTER_UNRESTRICTED_UNSAFE
Allows most headers.
|
static int |
LOAD_FLAGS_ALLOW_POPUPS
Popup blocking will be disabled for this load
|
static int |
LOAD_FLAGS_BYPASS_CACHE
Bypass the cache.
|
static int |
LOAD_FLAGS_BYPASS_CLASSIFIER
Bypass the URI classifier (content blocking and Safe Browsing).
|
static int |
LOAD_FLAGS_BYPASS_PROXY
Bypass the proxy, if one has been configured.
|
static int |
LOAD_FLAGS_EXTERNAL
The load is coming from an external app.
|
static int |
LOAD_FLAGS_FORCE_ALLOW_DATA_URI
Allows a top-level data: navigation to occur.
|
static int |
LOAD_FLAGS_NONE
Default load flag, no special considerations.
|
static int |
LOAD_FLAGS_REPLACE_HISTORY
This flag specifies that any existing history entry should be replaced.
|
protected org.mozilla.geckoview.GeckoSession.Window |
mWindow |
Constructor and Description |
---|
GeckoSession() |
GeckoSession(GeckoSessionSettings settings) |
Modifier and Type | Method and Description |
---|---|
GeckoDisplay |
acquireDisplay()
Acquire the GeckoDisplay instance for providing the session with a drawing Surface.
|
void |
autofill(SparseArray<CharSequence> values)
Perform autofill using the specified values.
|
void |
close()
Closes the session.
|
void |
exitFullScreen()
Exits fullscreen mode
|
SessionAccessibility |
getAccessibility()
Get the SessionAccessibility instance for this session.
|
Autofill.Delegate |
getAutofillDelegate() |
Autofill.Session |
getAutofillSession()
Provides an autofill structure similar to
View.onProvideAutofillVirtualStructure(ViewStructure, int) , but
does not rely on ViewStructure to build the tree. |
void |
getClientBounds(RectF rect)
Get the bounds of the client area in client coordinates.
|
void |
getClientToScreenMatrix(Matrix matrix)
Get a matrix for transforming from client coordinates to screen coordinates.
|
void |
getClientToSurfaceMatrix(Matrix matrix)
Get a matrix for transforming from client coordinates to surface coordinates.
|
CompositorController |
getCompositorController()
Get the CompositorController instance for this session.
|
ContentBlocking.Delegate |
getContentBlockingDelegate()
Get the content blocking callback handler.
|
GeckoSession.ContentDelegate |
getContentDelegate()
Get the content callback handler.
|
static String |
getDefaultUserAgent()
Get the default user agent for this GeckoView build.
|
SessionFinder |
getFinder()
Get the SessionFinder instance for this session, to perform find-in-page operations.
|
GeckoSession.HistoryDelegate |
getHistoryDelegate() |
GeckoSession.MediaDelegate |
getMediaDelegate()
Get the Media callback handler.
|
MediaSession.Delegate |
getMediaSessionDelegate()
Get the media session delegate.
|
GeckoSession.NavigationDelegate |
getNavigationDelegate()
Get the navigation callback handler.
|
OverscrollEdgeEffect |
getOverscrollEdgeEffect()
Get the OverscrollEdgeEffect instance for this session.
|
void |
getPageToScreenMatrix(Matrix matrix)
Get a matrix for transforming from page coordinates to screen coordinates.
|
void |
getPageToSurfaceMatrix(Matrix matrix)
Get a matrix for transforming from page coordinates to surface coordinates.
|
PanZoomController |
getPanZoomController()
Get the PanZoomController instance for this session.
|
GeckoSession.PermissionDelegate |
getPermissionDelegate()
Get the current permission delegate for this GeckoSession.
|
GeckoSession.ProgressDelegate |
getProgressDelegate()
Get the progress callback handler.
|
GeckoSession.PromptDelegate |
getPromptDelegate()
Get the current prompt delegate for this GeckoSession.
|
GeckoSession.ScrollDelegate |
getScrollDelegate() |
GeckoSession.SelectionActionDelegate |
getSelectionActionDelegate()
Get the current selection action delegate for this GeckoSession.
|
GeckoSessionSettings |
getSettings() |
void |
getSurfaceBounds(Rect rect)
Get the bounds of the client area in surface coordinates.
|
SessionTextInput |
getTextInput()
Get the SessionTextInput instance for this session.
|
GeckoResult<String> |
getUserAgent()
Get the current user agent string for this GeckoSession.
|
WebExtension.SessionController |
getWebExtensionController()
Returns a WebExtensionController for this GeckoSession.
|
void |
goBack()
Go back in history.
|
void |
goForward()
Go forward in history.
|
void |
gotoHistoryIndex(int index)
Navigate to an index in browser history; the index of the currently
viewed page can be retrieved from an up-to-date HistoryList by
calling
GeckoSession.HistoryDelegate.HistoryList.getCurrentIndex() . |
boolean |
isOpen()
Return whether this session is open.
|
void |
load(GeckoSession.Loader request)
Load page using the
GeckoSession.Loader specified. |
void |
loadUri(String uri)
Load the given URI.
|
void |
open(GeckoRuntime runtime)
Opens the session.
|
void |
purgeHistory()
Purge history for the session.
|
void |
releaseDisplay(GeckoDisplay display)
Release an acquired GeckoDisplay instance.
|
void |
reload()
Reload the current URI.
|
void |
reload(int flags)
Reload the current URI.
|
void |
restoreState(GeckoSession.SessionState state)
Restore a saved state to this GeckoSession; only data that is saved (history, scroll
position, zoom, and form data) will be restored.
|
void |
setActive(boolean active)
Set this GeckoSession as active or inactive, which represents if the session is currently
visible or not.
|
void |
setAutofillDelegate(Autofill.Delegate delegate)
Sets the autofill delegate for this session.
|
void |
setContentBlockingDelegate(ContentBlocking.Delegate delegate)
Set the content blocking callback handler.
|
void |
setContentDelegate(GeckoSession.ContentDelegate delegate)
Set the content callback handler.
|
void |
setFocused(boolean focused)
Move focus to this session or away from this session.
|
void |
setHistoryDelegate(GeckoSession.HistoryDelegate delegate)
Set the history tracking delegate for this session, replacing the
current delegate if one is set.
|
void |
setMediaDelegate(GeckoSession.MediaDelegate delegate)
Set the media callback handler.
|
void |
setMediaSessionDelegate(MediaSession.Delegate delegate)
Set the media session delegate.
|
void |
setNavigationDelegate(GeckoSession.NavigationDelegate delegate)
Set the navigation callback handler.
|
void |
setPermissionDelegate(GeckoSession.PermissionDelegate delegate)
Set the current permission delegate for this GeckoSession.
|
void |
setProgressDelegate(GeckoSession.ProgressDelegate delegate)
Set the progress callback handler.
|
void |
setPromptDelegate(GeckoSession.PromptDelegate delegate)
Set the current prompt delegate for this GeckoSession.
|
void |
setScrollDelegate(GeckoSession.ScrollDelegate delegate)
Set the content scroll callback handler.
|
void |
setSelectionActionDelegate(GeckoSession.SelectionActionDelegate delegate)
Set the current selection action delegate for this GeckoSession.
|
protected void |
setShouldPinOnScreen(boolean pinned) |
void |
stop()
Stop loading.
|
@Nullable protected org.mozilla.geckoview.GeckoSession.Window mWindow
public static final int LOAD_FLAGS_NONE
public static final int LOAD_FLAGS_BYPASS_CACHE
public static final int LOAD_FLAGS_BYPASS_PROXY
public static final int LOAD_FLAGS_EXTERNAL
public static final int LOAD_FLAGS_ALLOW_POPUPS
public static final int LOAD_FLAGS_BYPASS_CLASSIFIER
public static final int LOAD_FLAGS_FORCE_ALLOW_DATA_URI
public static final int LOAD_FLAGS_REPLACE_HISTORY
public static final int HEADER_FILTER_CORS_SAFELISTED
public static final int HEADER_FILTER_UNRESTRICTED_UNSAFE
Host
and Connection
headers are still ignored.
This should only be used when input is hard-coded from the app or when
properly sanitized, as some headers could cause unexpected consequences
and security issues.
Only use this if you know what you're doing.public static final int FINDER_FIND_BACKWARDS
public static final int FINDER_FIND_MATCH_CASE
public static final int FINDER_FIND_WHOLE_WORD
public static final int FINDER_FIND_LINKS_ONLY
public static final int FINDER_DISPLAY_HIGHLIGHT_ALL
public static final int FINDER_DISPLAY_DIM_PAGE
public static final int FINDER_DISPLAY_DRAW_LINK_OUTLINE
public GeckoSession()
public GeckoSession(@Nullable GeckoSessionSettings settings)
@AnyThread @NonNull public GeckoResult<String> getUserAgent()
GeckoResult
containing the UserAgent string@AnyThread @NonNull public static String getDefaultUserAgent()
@UiThread @Nullable public GeckoSession.PermissionDelegate getPermissionDelegate()
@UiThread public void setPermissionDelegate(@Nullable GeckoSession.PermissionDelegate delegate)
delegate
- PermissionDelegate instance or null to use the default delegate.@AnyThread public boolean isOpen()
open(org.mozilla.geckoview.GeckoRuntime)
,
close()
@UiThread public void open(@NonNull GeckoRuntime runtime)
@UiThread public void close()
open(org.mozilla.geckoview.GeckoRuntime)
,
isOpen()
@AnyThread @NonNull public SessionTextInput getTextInput()
@UiThread @NonNull public SessionAccessibility getAccessibility()
@AnyThread public void load(@NonNull GeckoSession.Loader request)
GeckoSession.Loader
specified.request
- Loader for this request.GeckoSession.Loader
@AnyThread public void loadUri(@NonNull String uri)
session.load(new Loader().uri(uri));
uri
- The URI of the resource to load.@AnyThread public void reload()
@AnyThread public void reload(int flags)
flags
- the load flags to use, an OR-ed value of LOAD_FLAGS_*
@AnyThread public void stop()
@AnyThread public void goBack()
@AnyThread public void goForward()
@AnyThread public void gotoHistoryIndex(int index)
GeckoSession.HistoryDelegate.HistoryList.getCurrentIndex()
.index
- The index of the location in browser history you want
to navigate to.@UiThread @NonNull public WebExtension.SessionController getWebExtensionController()
WebExtension.SessionController
.@AnyThread public void purgeHistory()
GeckoSession.NavigationDelegate.onCanGoBack(GeckoSession, boolean)
and GeckoSession.NavigationDelegate.onCanGoForward(GeckoSession, boolean)
will be false.@AnyThread @NonNull public SessionFinder getFinder()
@AnyThread public void setActive(boolean active)
active
- A boolean determining whether the GeckoSession is active.setFocused(boolean)
@AnyThread public void setFocused(boolean focused)
focused
- True if the session should gain focus or
false if the session should lose focus.setActive(boolean)
@AnyThread public void restoreState(@NonNull GeckoSession.SessionState state)
state
- A saved session state; this should originate from onSessionStateChange().@UiThread @NonNull public GeckoDisplay acquireDisplay()
GeckoDisplay.surfaceChanged(Surface, int, int)
on the
acquired display if there is already a valid Surface.releaseDisplay(GeckoDisplay)
@UiThread public void releaseDisplay(@NonNull GeckoDisplay display)
GeckoDisplay.surfaceDestroyed()
before releasing the display if it still has a
valid Surface.display
- Acquired GeckoDisplay instance.acquireDisplay()
@AnyThread @NonNull public GeckoSessionSettings getSettings()
@AnyThread public void exitFullScreen()
@UiThread public void setContentDelegate(@Nullable GeckoSession.ContentDelegate delegate)
delegate
- An implementation of ContentDelegate.@UiThread @Nullable public GeckoSession.ContentDelegate getContentDelegate()
@UiThread public void setProgressDelegate(@Nullable GeckoSession.ProgressDelegate delegate)
delegate
- An implementation of ProgressDelegate.@UiThread @Nullable public GeckoSession.ProgressDelegate getProgressDelegate()
@UiThread public void setNavigationDelegate(@Nullable GeckoSession.NavigationDelegate delegate)
delegate
- An implementation of NavigationDelegate.@UiThread @Nullable public GeckoSession.NavigationDelegate getNavigationDelegate()
@UiThread public void setScrollDelegate(@Nullable GeckoSession.ScrollDelegate delegate)
delegate
- An implementation of ScrollDelegate.@UiThread @Nullable public GeckoSession.ScrollDelegate getScrollDelegate()
@AnyThread public void setHistoryDelegate(@Nullable GeckoSession.HistoryDelegate delegate)
delegate
- The history tracking delegate, or null
to unset.@AnyThread @Nullable public GeckoSession.HistoryDelegate getHistoryDelegate()
@AnyThread public void setContentBlockingDelegate(@Nullable ContentBlocking.Delegate delegate)
delegate
- An implementation of ContentBlocking.Delegate
.@AnyThread @Nullable public ContentBlocking.Delegate getContentBlockingDelegate()
@AnyThread public void setPromptDelegate(@Nullable GeckoSession.PromptDelegate delegate)
delegate
- PromptDelegate instance or null to use the built-in delegate.@AnyThread @Nullable public GeckoSession.PromptDelegate getPromptDelegate()
@UiThread public void setSelectionActionDelegate(@Nullable GeckoSession.SelectionActionDelegate delegate)
delegate
- SelectionActionDelegate instance or null to unset.@AnyThread public void setMediaDelegate(@Nullable GeckoSession.MediaDelegate delegate)
delegate
- An implementation of MediaDelegate.@AnyThread @Nullable public GeckoSession.MediaDelegate getMediaDelegate()
@AnyThread public void setMediaSessionDelegate(@Nullable MediaSession.Delegate delegate)
delegate
- An implementation of MediaSession.Delegate
.@AnyThread @Nullable public MediaSession.Delegate getMediaSessionDelegate()
@AnyThread @Nullable public GeckoSession.SelectionActionDelegate getSelectionActionDelegate()
@UiThread protected void setShouldPinOnScreen(boolean pinned)
@UiThread @NonNull public PanZoomController getPanZoomController()
@UiThread @NonNull public OverscrollEdgeEffect getOverscrollEdgeEffect()
@UiThread @NonNull public CompositorController getCompositorController()
@UiThread public void getClientToSurfaceMatrix(@NonNull Matrix matrix)
matrix
- Matrix to be replaced by the transformation matrix.getClientToScreenMatrix(Matrix)
,
getPageToSurfaceMatrix(Matrix)
@UiThread public void getClientToScreenMatrix(@NonNull Matrix matrix)
matrix
- Matrix to be replaced by the transformation matrix.getClientToSurfaceMatrix(Matrix)
,
getPageToScreenMatrix(Matrix)
@UiThread public void getPageToScreenMatrix(@NonNull Matrix matrix)
matrix
- Matrix to be replaced by the transformation matrix.getPageToSurfaceMatrix(Matrix)
,
getClientToScreenMatrix(Matrix)
@UiThread public void getPageToSurfaceMatrix(@NonNull Matrix matrix)
matrix
- Matrix to be replaced by the transformation matrix.getPageToScreenMatrix(Matrix)
,
getClientToSurfaceMatrix(Matrix)
@UiThread public void getClientBounds(@NonNull RectF rect)
getClientToSurfaceMatrix(Matrix)
or getClientToScreenMatrix(Matrix)
to
map these bounds to surface or screen coordinates, respectively.rect
- RectF to be replaced by the client bounds in client coordinates.getSurfaceBounds(Rect)
@UiThread public void getSurfaceBounds(@NonNull Rect rect)
rect
- Rect to be replaced by the client bounds in surface coordinates.@UiThread public void setAutofillDelegate(@Nullable Autofill.Delegate delegate)
delegate
- An instance of Autofill.Delegate
.@UiThread @Nullable public Autofill.Delegate getAutofillDelegate()
Autofill.Delegate
for this session, if any.@UiThread public void autofill(@NonNull SparseArray<CharSequence> values)
values
- Map of autofill IDs to values.@UiThread @NonNull public Autofill.Session getAutofillSession()
View.onProvideAutofillVirtualStructure(ViewStructure, int)
, but
does not rely on ViewStructure
to build the tree. This is useful for apps that want
to provide autofill functionality without using the Android autofill system or requiring
API 26.