Implement onPageDOMContentLoadedEventFired & onFirstContentfulPaint
This implements parts of the new Page-related APIs proposed at https://docs.google.com/document/d/1DDyPvVe7pyJXFpiI3Bk5EPDpoTM550kPt04s2_WTU-w/edit?tab=t.0 that was previously added in crrev.com/c/6290306: - NavigationClient.onPageDOMContentLoadedEventFired() - NavigationClient.onFirstContentfulPaint() Bug: 359826084 Change-Id: I6ff296d105f2c268f2970fbb2b2f23c633b20e3c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6298907 Reviewed-by: Richard (Torne) Coles <torne@chromium.org> Reviewed-by: Michael Thiessen <mthiesse@chromium.org> Commit-Queue: Rakina Zata Amni <rakina@chromium.org> Cr-Commit-Position: refs/heads/main@{#1426924}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
6d8cf58cb6
commit
020c6c2792
android_webview/java/src/org/chromium/android_webview
chrome/android/java/src/org/chromium/chrome/browser/browserservices
content
browser
public
android
java
src
org
chromium
@ -140,6 +140,29 @@ public class AwWebContentsObserver extends WebContentsObserver
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void documentLoadedInPrimaryMainFrame(
|
||||
Page page, GlobalRenderFrameHostId rfhId, @LifecycleState int rfhLifecycleState) {
|
||||
AwContents awContents = mAwContents.get();
|
||||
if (awContents != null) {
|
||||
AwNavigationClient client = awContents.getNavigationClient();
|
||||
if (client != null) {
|
||||
client.onPageDOMContentLoadedEventFired(getAwPageFor(page));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void firstContentfulPaintInPrimaryMainFrame(Page page) {
|
||||
AwContents awContents = mAwContents.get();
|
||||
if (awContents != null) {
|
||||
AwNavigationClient client = awContents.getNavigationClient();
|
||||
if (client != null) {
|
||||
client.onFirstContentfulPaint(getAwPageFor(page));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didStartLoading(GURL gurl) {
|
||||
AwContents awContents = mAwContents.get();
|
||||
|
@ -27,6 +27,7 @@ import org.chromium.content_public.browser.MessagePayload;
|
||||
import org.chromium.content_public.browser.MessagePort;
|
||||
import org.chromium.content_public.browser.MessagePort.MessageCallback;
|
||||
import org.chromium.content_public.browser.NavigationHandle;
|
||||
import org.chromium.content_public.browser.Page;
|
||||
import org.chromium.content_public.browser.WebContents;
|
||||
import org.chromium.content_public.browser.WebContentsObserver;
|
||||
import org.chromium.net.GURLUtils;
|
||||
@ -124,7 +125,9 @@ public class PostMessageHandler implements OriginVerificationListener {
|
||||
|
||||
@Override
|
||||
public void documentLoadedInPrimaryMainFrame(
|
||||
GlobalRenderFrameHostId rfhId, @LifecycleState int rfhLifecycleState) {
|
||||
Page page,
|
||||
GlobalRenderFrameHostId rfhId,
|
||||
@LifecycleState int rfhLifecycleState) {
|
||||
if (mChannel != null) {
|
||||
return;
|
||||
}
|
||||
|
@ -201,12 +201,19 @@ void WebContentsObserverProxy::DOMContentLoaded(
|
||||
if (render_frame_host->IsInPrimaryMainFrame()) {
|
||||
Java_WebContentsObserverProxy_documentLoadedInPrimaryMainFrame(
|
||||
AttachCurrentThread(), java_observer_,
|
||||
render_frame_host->GetPage().GetJavaPage(),
|
||||
render_frame_host->GetProcess()->GetDeprecatedID(),
|
||||
render_frame_host->GetRoutingID(),
|
||||
static_cast<jint>(render_frame_host->GetLifecycleState()));
|
||||
}
|
||||
}
|
||||
|
||||
void WebContentsObserverProxy::OnFirstContentfulPaintInPrimaryMainFrame() {
|
||||
Java_WebContentsObserverProxy_firstContentfulPaintInPrimaryMainFrame(
|
||||
AttachCurrentThread(), java_observer_,
|
||||
web_contents()->GetPrimaryPage().GetJavaPage());
|
||||
}
|
||||
|
||||
void WebContentsObserverProxy::NavigationEntryCommitted(
|
||||
const LoadCommittedDetails& load_details) {
|
||||
JNIEnv* env = AttachCurrentThread();
|
||||
|
@ -58,6 +58,7 @@ class WebContentsObserverProxy : public WebContentsObserver {
|
||||
void DidFinishLoad(RenderFrameHost* render_frame_host,
|
||||
const GURL& validated_url) override;
|
||||
void DOMContentLoaded(RenderFrameHost* render_frame_host) override;
|
||||
void OnFirstContentfulPaintInPrimaryMainFrame() override;
|
||||
void NavigationEntryCommitted(
|
||||
const LoadCommittedDetails& load_details) override;
|
||||
void NavigationEntriesDeleted() override;
|
||||
|
@ -318,18 +318,36 @@ class WebContentsObserverProxy extends WebContentsObserver {
|
||||
|
||||
@CalledByNative
|
||||
private void documentLoadedInPrimaryMainFrame(
|
||||
int renderProcessId, int renderFrameId, @LifecycleState int rfhLifecycleState) {
|
||||
Page page,
|
||||
int renderProcessId,
|
||||
int renderFrameId,
|
||||
@LifecycleState int rfhLifecycleState) {
|
||||
documentLoadedInPrimaryMainFrame(
|
||||
new GlobalRenderFrameHostId(renderProcessId, renderFrameId), rfhLifecycleState);
|
||||
page,
|
||||
new GlobalRenderFrameHostId(renderProcessId, renderFrameId),
|
||||
rfhLifecycleState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void documentLoadedInPrimaryMainFrame(
|
||||
GlobalRenderFrameHostId rfhId, @LifecycleState int rfhLifecycleState) {
|
||||
Page page, GlobalRenderFrameHostId rfhId, @LifecycleState int rfhLifecycleState) {
|
||||
handleObserverCall();
|
||||
Iterator<WebContentsObserver> observersIterator = mObservers.iterator();
|
||||
for (; observersIterator.hasNext(); ) {
|
||||
observersIterator.next().documentLoadedInPrimaryMainFrame(rfhId, rfhLifecycleState);
|
||||
observersIterator
|
||||
.next()
|
||||
.documentLoadedInPrimaryMainFrame(page, rfhId, rfhLifecycleState);
|
||||
}
|
||||
finishObserverCall();
|
||||
}
|
||||
|
||||
@CalledByNative
|
||||
@Override
|
||||
public void firstContentfulPaintInPrimaryMainFrame(Page page) {
|
||||
handleObserverCall();
|
||||
Iterator<WebContentsObserver> observersIterator = mObservers.iterator();
|
||||
for (; observersIterator.hasNext(); ) {
|
||||
observersIterator.next().firstContentfulPaintInPrimaryMainFrame(page);
|
||||
}
|
||||
finishObserverCall();
|
||||
}
|
||||
|
@ -177,14 +177,24 @@ public abstract class WebContentsObserver {
|
||||
|
||||
/**
|
||||
* Notifies that the document has finished loading for the primary main frame.
|
||||
*
|
||||
* @param page The Page whose document has finished loading.
|
||||
* @param rfhId Identifier of the navigating frame.
|
||||
* @param rfhLifecycleState The lifecycle state of the associated frame.
|
||||
*/
|
||||
public void documentLoadedInPrimaryMainFrame(
|
||||
GlobalRenderFrameHostId rfhId, @LifecycleState int rfhLifecycleState) {}
|
||||
Page page, GlobalRenderFrameHostId rfhId, @LifecycleState int rfhLifecycleState) {}
|
||||
|
||||
/**
|
||||
* Notifies that the first contentful paint happened on the primary main frame.
|
||||
*
|
||||
* @param page The Page where the first contentful paint happened.
|
||||
*/
|
||||
public void firstContentfulPaintInPrimaryMainFrame(Page page) {}
|
||||
|
||||
/**
|
||||
* Notifies that a navigation entry has been committed.
|
||||
*
|
||||
* @param details Details of committed navigation entry.
|
||||
*/
|
||||
public void navigationEntryCommitted(LoadCommittedDetails details) {}
|
||||
|
Reference in New Issue
Block a user