在ContentViewCore.java里:
@CalledByNative
private void setTitle(String title) {
getContentViewClient().onUpdateTitle(title);
}
这里会调用:WebChromeClient.onReceivedTitle.
调用ContentViewCore.setTitle的C++文件是:
content_view_core_impl.cc
void ContentViewCoreImpl::SetTitle(const base::string16& title) {
Java_ContentViewCore_setTitle(env, obj.obj(), jtitle.obj());
}
在web_contents/web_contents_view_android.cc中
void WebContentsViewAndroid::SetPageTitle(const base::string16& title) {
if (content_view_core_)
content_view_core_->SetTitle(title);
}
然后调用:
WebContentsImpl::UpdateTitleForEntry() {
view_->SetPageTitle(final_title);
}
这里会接收msg:
RenderViewHostImpl::OnUpdateTitle
{}
void RenderViewImpl::UpdateTitle
{
Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, shortened_title,
title_direction));
}
RenderViewImpl::didReceiveTitle{
UpdateTitle();
}
void FrameLoaderClientImpl::dispatchDidReceiveTitle(const String& title)
{
if (m_webFrame->client())
m_webFrame->client()->didReceiveTitle(m_webFrame, title, WebTextDirectionLeftToRight);
}

本文详细解析了 ContentViewCore.java 类中如何通过 setTitle 方法设置标题,并追踪了其在不同组件间的传递过程,包括 C++ 实现、Java 调用、WebContents 视图更新以及渲染视图主机的消息处理。
1万+

被折叠的 条评论
为什么被折叠?



