WebNavigationClient


@WebNavigationClient.ExperimentalNavigationCallback
public interface WebNavigationClient


Page identification and lifecycle APIs. This class provides callbacks to identify the different stages of navigation. For more information about the navigation lifecycle, please see the Life of a Navigation Presentation.

Note: These navigation callbacks only fire for navigations happening on the main frame.

Navigation lifecycle events:

  • onNavigationStarted
  • Potentially zero or more onNavigationRedirected events
  • onNavigationCompleted
  • If the navigation commits and is not a same-document navigation, potentially any combination and order of zero or one of each of:
    • onPageLoadEvent
    • onPageDomContentLoaded
    • onFirstContentfulPaint

Summary

Nested types

@Retention(value = RetentionPolicy.CLASS)
@Target(value = [ElementType.METHOD, ElementType.TYPE, ElementType.FIELD])
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
public annotation WebNavigationClient.ExperimentalNavigationCallback

Denotes Navigation, Page and WebNavigationClient API surfaces are experimental.

Public methods

abstract void

Fired when the page achieves "First Contentful Paint".

abstract void

Fired when a navigation completes.

abstract void

Fired when a navigation is redirected.

abstract void

Fired when a navigation starts, including same-document navigations.

abstract void

Fired when any Page is evicted/destroyed.

abstract void

Fired when the `DOMContentLoaded` event is fired for the current page.

abstract void

Fired when the `window.load` event is fired for the current page.

Public methods

onFirstContentfulPaint

abstract void onFirstContentfulPaint(@NonNull Page page)

Fired when the page achieves "First Contentful Paint".

See First Contentful Paint (FCP) for a definition.

Parameters
@NonNull Page page

The Page for which the First Contentful Paint occurred.

onNavigationCompleted

abstract void onNavigationCompleted(@NonNull Navigation navigation)

Fired when a navigation completes.

The navigation might not have actually committed (e.g., results in 204/download/cancelled).

Parameters
@NonNull Navigation navigation

The Navigation object representing the completed navigation.

onNavigationRedirected

abstract void onNavigationRedirected(@NonNull Navigation navigation)

Fired when a navigation is redirected.

Parameters
@NonNull Navigation navigation

The Navigation object representing the redirected navigation.

onNavigationStarted

abstract void onNavigationStarted(@NonNull Navigation navigation)

Fired when a navigation starts, including same-document navigations.

Note: These navigation callbacks only fire for navigations happening on the main frame.

Parameters
@NonNull Navigation navigation

The Navigation object representing the started navigation.

onPageDeleted

abstract void onPageDeleted(@NonNull Page page)

Fired when any Page is evicted/destroyed. This can occur immediately on navigation, or later if the page is BFCached and subsequently evicted.

Parameters
@NonNull Page page

The Page that was evicted or destroyed.

onPageDomContentLoadedEventFired

abstract void onPageDomContentLoadedEventFired(@NonNull Page page)

Fired when the `DOMContentLoaded` event is fired for the current page.

Parameters
@NonNull Page page

The Page for which the `DOMContentLoaded` event fired.

onPageLoadEventFired

abstract void onPageLoadEventFired(@NonNull Page page)

Fired when the `window.load` event is fired for the current page.

Parameters
@NonNull Page page

The Page for which the `window.load` event fired.