Class Session
-
- All Implemented Interfaces:
public final class SessionThis class is primarily responsible for managing an instance of an Android WebView that will be shared between destinations.
-
-
Field Summary
Fields Modifier and Type Field Description private final VisitcurrentVisitprivate final BooleanisReadyprivate final BooleanisRenderProcessGoneprivate final FileChooserDelegatefileChooserDelegateprivate final GeolocationPermissionDelegategeolocationPermissionDelegateprivate final AngularNativeWebViewwebView
-
Constructor Summary
Constructors Constructor Description Session(String sessionName, AppCompatActivity activity, AngularNativeWebView webView)
-
Method Summary
Modifier and Type Method Description final VisitgetCurrentVisit()The current visit for the current destination. final BooleanisReady()Provides the status of whether WebNavigation is initialized and ready for use. final BooleanisRenderProcessGone()Specifies whether the render process is gone for the WebView instance. final FileChooserDelegategetFileChooserDelegate()The delegate that handles WebView-requested file chooser requests. final GeolocationPermissionDelegategetGeolocationPermissionDelegate()The delegate the handles WebView-requested geolocation permission requests. final AngularNativeWebViewgetWebView()An instance of a AngularNativeWebView to be shared/managed. final BooleanisWebNavigationEnabled()Indicates whether WebNavigation is currently enabled for this session. final UnitpreCacheLocation(String location)Fetches a given location and returns the response to the OfflineRequestHandler Allows an offline cache to contain specific items instead of solely relying on visited items. final Unitreset()Resets this session to a cold boot state. final Unitvisit(Visit visit)final BooleanrestoreCurrentVisit(SessionCallback callback)Synthetically restore the WebView's current visit without using a cached snapshot or a visit request. final UnitcacheSnapshot()Cache a snapshot of the current visit. final UnitremoveCallback(SessionCallback callback)final UnitvisitProposedToLocation(String location, String optionsJson)Called by WebNavigation bridge when a new visit is proposed. final UnitvisitProposalRefreshingPage(String location, String optionsJson)Called by WebNavigation bridge when a new visit proposal will refresh the current page. final UnitvisitProposalScrollingToAnchor(String location, String optionsJson)Called by WebNavigation bridge when a new visit proposal will scroll to an anchor on the same page. final UnitvisitStarted(String visitIdentifier, Boolean visitHasCachedSnapshot, Boolean visitIsPageRefresh, String location)Called by WebNavigation bridge when a new visit has just started. final UnitvisitRequestStarted(String visitIdentifier)Called by WebNavigation bridge when the HTTP request has started. final UnitvisitRequestCompleted(String visitIdentifier)Called by WebNavigation bridge when the HTTP request has been completed. final UnitvisitRequestFailedWithStatusCode(String location, String visitIdentifier, Boolean visitHasCachedSnapshot, Integer statusCode)Called by WebNavigation bridge when the HTTP request has failed. final UnitvisitRequestFailedWithNonHttpStatusCode(String location, String visitIdentifier, Boolean visitHasCachedSnapshot)Called by WebNavigation bridge when a visit request fails with a non-HTTP status code, suggesting it may be the result of a cross-origin redirect visit. final UnitvisitRequestFinished(String visitIdentifier)Called by WebNavigation bridge when the HTTP request has been completed. final UnitpageLoaded(String restorationIdentifier)Called by WebNavigation bridge once the page has been fully loaded by the WebView. final UnitvisitRendered(String visitIdentifier)Called by WebNavigation bridge once the page has been fully rendered in the webView. final UnitvisitCompleted(String visitIdentifier, String restorationIdentifier)Called by WebNavigation bridge when the visit is fully completed (request successful and page rendered). final UnitformSubmissionStarted(String location)Called by WebNavigation bridge when a form submission has started. final UnitformSubmissionFinished(String location)Called by WebNavigation bridge when a form submission has finished. final UnitpageInvalidated()Called when WebNavigation bridge detects that the page being visited has been invalidated, typically by new resources in the the page HEAD. final UnitwebNavigationIsReady(Boolean isReady)Sets internal flags that indicate whether WebNavigation in the WebView is ready for use. final UnitwebNavigationFailedToLoad()Sets internal flags indicating that WebNavigation did not properly initialize. final UnitsetWebNavigationEnabled(Boolean isWebNavigationEnabled)Sets whether this session should use WebNavigation/LegacyNavigation navigation. final UnitelementTouchStarted(Boolean preventsPullsToRefresh)Called when a touched element event has started. final UnitelementTouchEnded()Called when a touched element event has ended. -
-
Constructor Detail
-
Session
Session(String sessionName, AppCompatActivity activity, AngularNativeWebView webView)
-
-
Method Detail
-
getCurrentVisit
final Visit getCurrentVisit()
The current visit for the current destination.
-
isReady
final Boolean isReady()
Provides the status of whether WebNavigation is initialized and ready for use.
-
isRenderProcessGone
final Boolean isRenderProcessGone()
Specifies whether the render process is gone for the WebView instance. If the render process is gone, this Session and its WebView cannot be reused and must be recreated.
-
getFileChooserDelegate
final FileChooserDelegate getFileChooserDelegate()
The delegate that handles WebView-requested file chooser requests.
-
getGeolocationPermissionDelegate
final GeolocationPermissionDelegate getGeolocationPermissionDelegate()
The delegate the handles WebView-requested geolocation permission requests.
-
getWebView
final AngularNativeWebView getWebView()
An instance of a AngularNativeWebView to be shared/managed.
-
isWebNavigationEnabled
final Boolean isWebNavigationEnabled()
Indicates whether WebNavigation is currently enabled for this session.
-
preCacheLocation
final Unit preCacheLocation(String location)
Fetches a given location and returns the response to the OfflineRequestHandler Allows an offline cache to contain specific items instead of solely relying on visited items.
- Parameters:
location- Location to cache.
-
reset
final Unit reset()
Resets this session to a cold boot state. The first subsequent visit after resetting will execute a full cold boot (reloading of all resources).
-
restoreCurrentVisit
final Boolean restoreCurrentVisit(SessionCallback callback)
Synthetically restore the WebView's current visit without using a cached snapshot or a visit request. This is used when restoring a destination from the backstack, but the WebView's current location hasn't changed from the destination's location.
-
cacheSnapshot
final Unit cacheSnapshot()
Cache a snapshot of the current visit.
-
removeCallback
final Unit removeCallback(SessionCallback callback)
-
visitProposedToLocation
final Unit visitProposedToLocation(String location, String optionsJson)
Called by WebNavigation bridge when a new visit is proposed.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
- Parameters:
location- The location to visit.optionsJson- A JSON block to be serialized into VisitOptions.
-
visitProposalRefreshingPage
final Unit visitProposalRefreshingPage(String location, String optionsJson)
Called by WebNavigation bridge when a new visit proposal will refresh the current page.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
- Parameters:
location- The location to visit.optionsJson- A JSON block to be serialized into VisitOptions.
-
visitProposalScrollingToAnchor
final Unit visitProposalScrollingToAnchor(String location, String optionsJson)
Called by WebNavigation bridge when a new visit proposal will scroll to an anchor on the same page.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
- Parameters:
location- The location to visit.optionsJson- A JSON block to be serialized into VisitOptions.
-
visitStarted
final Unit visitStarted(String visitIdentifier, Boolean visitHasCachedSnapshot, Boolean visitIsPageRefresh, String location)
Called by WebNavigation bridge when a new visit has just started.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
- Parameters:
visitIdentifier- A unique identifier for the visit.visitHasCachedSnapshot- Whether the visit has a cached snapshot available.location- The location being visited.
-
visitRequestStarted
final Unit visitRequestStarted(String visitIdentifier)
Called by WebNavigation bridge when the HTTP request has started.
- Parameters:
visitIdentifier- A unique identifier for the visit.
-
visitRequestCompleted
final Unit visitRequestCompleted(String visitIdentifier)
Called by WebNavigation bridge when the HTTP request has been completed.
- Parameters:
visitIdentifier- A unique identifier for the visit.
-
visitRequestFailedWithStatusCode
final Unit visitRequestFailedWithStatusCode(String location, String visitIdentifier, Boolean visitHasCachedSnapshot, Integer statusCode)
Called by WebNavigation bridge when the HTTP request has failed.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
- Parameters:
location- The location of the failed visit.visitIdentifier- A unique identifier for the visit.visitHasCachedSnapshot- Whether the visit has a cached snapshot available.statusCode- The HTTP status code that caused the failure.
-
visitRequestFailedWithNonHttpStatusCode
final Unit visitRequestFailedWithNonHttpStatusCode(String location, String visitIdentifier, Boolean visitHasCachedSnapshot)
Called by WebNavigation bridge when a visit request fails with a non-HTTP status code, suggesting it may be the result of a cross-origin redirect visit. Determining a cross-origin redirect is not possible in javascript with the Fetch API due to CORS restrictions, so verify on the native side. Propose a cross-origin redirect visit if a redirect is found, otherwise fail the visit.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
- Parameters:
location- The original visit location requested.visitIdentifier- A unique identifier for the visit.visitHasCachedSnapshot- Whether the visit has a cached snapshot available.
-
visitRequestFinished
final Unit visitRequestFinished(String visitIdentifier)
Called by WebNavigation bridge when the HTTP request has been completed.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
- Parameters:
visitIdentifier- A unique identifier for the visit.
-
pageLoaded
final Unit pageLoaded(String restorationIdentifier)
Called by WebNavigation bridge once the page has been fully loaded by the WebView.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
- Parameters:
restorationIdentifier- A unique identifier for restoring the page and scroll position from cache.
-
visitRendered
final Unit visitRendered(String visitIdentifier)
Called by WebNavigation bridge once the page has been fully rendered in the webView.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
- Parameters:
visitIdentifier- A unique identifier for the visit.
-
visitCompleted
final Unit visitCompleted(String visitIdentifier, String restorationIdentifier)
Called by WebNavigation bridge when the visit is fully completed (request successful and page rendered).
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
- Parameters:
visitIdentifier- A unique identifier for the visit.restorationIdentifier- A unique identifier for restoring the page and scroll position from cache.
-
formSubmissionStarted
final Unit formSubmissionStarted(String location)
Called by WebNavigation bridge when a form submission has started.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
- Parameters:
location- The location of the form submission.
-
formSubmissionFinished
final Unit formSubmissionFinished(String location)
Called by WebNavigation bridge when a form submission has finished.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
- Parameters:
location- The location of the form submission.
-
pageInvalidated
final Unit pageInvalidated()
Called when WebNavigation bridge detects that the page being visited has been invalidated, typically by new resources in the the page HEAD.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
-
webNavigationIsReady
final Unit webNavigationIsReady(Boolean isReady)
Sets internal flags that indicate whether WebNavigation in the WebView is ready for use.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
-
webNavigationFailedToLoad
final Unit webNavigationFailedToLoad()
Sets internal flags indicating that WebNavigation did not properly initialize.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
-
setWebNavigationEnabled
final Unit setWebNavigationEnabled(Boolean isWebNavigationEnabled)
Sets whether this session should use WebNavigation/LegacyNavigation navigation.
Some pages intentionally omit AngularNative, and still need full page navigation with native shell handoff.
- Parameters:
isWebNavigationEnabled- true when a WebNavigation bridge is present.
-
elementTouchStarted
final Unit elementTouchStarted(Boolean preventsPullsToRefresh)
Called when a touched element event has started.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
-
elementTouchEnded
final Unit elementTouchEnded()
Called when a touched element event has ended.
Warning: This method is public so it can be used as a Javascript Interface. You should never call this directly as it could lead to unintended behavior.
-
-
-
-