android-components / mozilla.components.concept.engine.request / RequestInterceptor

RequestInterceptor

interface RequestInterceptor (source)

Interface for classes that want to intercept load requests to allow custom behavior.

Types

Name Summary
ErrorResponse sealed class ErrorResponse
An alternative response for an error request.
InterceptionResponse sealed class InterceptionResponse
An alternative response for an intercepted request.

Functions

Name Summary
interceptsAppInitiatedRequests open fun interceptsAppInitiatedRequests(): Boolean
Returns whether or not this RequestInterceptor should intercept load requests initiated by the app (via direct calls to EngineSession.loadUrl). All other requests triggered by users interacting with web content (e.g. following links) or redirects will always be intercepted.
onErrorRequest open fun onErrorRequest(session: EngineSession, errorType: ErrorType, uri: String?): ErrorResponse?
A request that the engine wasn’t able to handle that resulted in an error.
onLoadRequest open fun onLoadRequest(engineSession: EngineSession, uri: String, lastUri: String?, hasUserGesture: Boolean, isSameDomain: Boolean, isRedirect: Boolean, isDirectNavigation: Boolean, isSubframeRequest: Boolean): InterceptionResponse?
A request to open an URI. This is called before each page load to allow providing custom behavior.

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.

Inheritors

Name Summary
AppLinksInterceptor class AppLinksInterceptor : RequestInterceptor
This feature implements use cases for detecting and handling redirects to external apps. The user is asked to confirm her intention before leaving the app. These include the Android Intents, custom schemes and support for Intent.CATEGORY_BROWSABLE http(s) URLs.
WebAppInterceptor class WebAppInterceptor : RequestInterceptor
This feature will intercept requests and reopen them in the corresponding installed PWA, if any.