mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Improve the timing of OnLoadEnd (fixes issue #3341)
Use WebContentsDelegate::DidFinishLoad instead of a custom Mojo message. This fixes flaky OnLoadEnd behavior with NavigationTest.Order.
This commit is contained in:
@@ -515,6 +515,20 @@ void CefBrowserContentsDelegate::DidFailLoad(
|
||||
OnLoadEnd(frame, validated_url, error_code);
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::DidFinishLoad(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& validated_url) {
|
||||
auto frame = browser_info_->GetFrameForHost(render_frame_host);
|
||||
frame->RefreshAttributes();
|
||||
|
||||
int http_status_code = 0;
|
||||
if (auto response_headers = render_frame_host->GetLastResponseHeaders()) {
|
||||
http_status_code = response_headers->response_code();
|
||||
}
|
||||
|
||||
OnLoadEnd(frame, validated_url, http_status_code);
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::TitleWasSet(content::NavigationEntry* entry) {
|
||||
// |entry| may be NULL if a popup is created via window.open and never
|
||||
// navigated.
|
||||
@@ -577,17 +591,6 @@ void CefBrowserContentsDelegate::Observe(
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::OnLoadEnd(CefRefPtr<CefFrame> frame,
|
||||
const GURL& url,
|
||||
int http_status_code) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetLoadHandler()) {
|
||||
auto navigation_lock = browser_info_->CreateNavigationLock();
|
||||
handler->OnLoadEnd(browser(), frame, http_status_code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CefBrowserContentsDelegate::OnSetFocus(cef_focus_source_t source) {
|
||||
// SetFocus() might be called while inside the OnSetFocus() callback. If
|
||||
// so, don't re-enter the callback.
|
||||
@@ -649,6 +652,17 @@ void CefBrowserContentsDelegate::OnLoadStart(
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::OnLoadEnd(CefRefPtr<CefFrame> frame,
|
||||
const GURL& url,
|
||||
int http_status_code) {
|
||||
if (auto c = client()) {
|
||||
if (auto handler = c->GetLoadHandler()) {
|
||||
auto navigation_lock = browser_info_->CreateNavigationLock();
|
||||
handler->OnLoadEnd(browser(), frame, http_status_code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserContentsDelegate::OnLoadError(CefRefPtr<CefFrame> frame,
|
||||
const GURL& url,
|
||||
int error_code) {
|
||||
|
@@ -134,6 +134,8 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
||||
void DidFailLoad(content::RenderFrameHost* render_frame_host,
|
||||
const GURL& validated_url,
|
||||
int error_code) override;
|
||||
void DidFinishLoad(content::RenderFrameHost* render_frame_host,
|
||||
const GURL& validated_url) override;
|
||||
void TitleWasSet(content::NavigationEntry* entry) override;
|
||||
void DidUpdateFaviconURL(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
@@ -159,9 +161,6 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
||||
|
||||
// Helpers for executing client callbacks.
|
||||
// TODO(cef): Make this private if/when possible.
|
||||
void OnLoadEnd(CefRefPtr<CefFrame> frame,
|
||||
const GURL& url,
|
||||
int http_status_code);
|
||||
bool OnSetFocus(cef_focus_source_t source);
|
||||
|
||||
private:
|
||||
@@ -173,6 +172,9 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
||||
void OnAddressChange(const GURL& url);
|
||||
void OnLoadStart(CefRefPtr<CefFrame> frame,
|
||||
ui::PageTransition transition_type);
|
||||
void OnLoadEnd(CefRefPtr<CefFrame> frame,
|
||||
const GURL& url,
|
||||
int http_status_code);
|
||||
void OnLoadError(CefRefPtr<CefFrame> frame, const GURL& url, int error_code);
|
||||
void OnTitleChange(const std::u16string& title);
|
||||
void OnFullscreenModeChange(bool fullscreen);
|
||||
|
@@ -62,13 +62,6 @@ void CefBrowserFrame::FrameAttached(
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserFrame::DidFinishFrameLoad(const GURL& validated_url,
|
||||
int http_status_code) {
|
||||
if (auto host = GetFrameHost()) {
|
||||
host->DidFinishFrameLoad(validated_url, http_status_code);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserFrame::UpdateDraggableRegions(
|
||||
absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) {
|
||||
if (auto host = GetFrameHost()) {
|
||||
|
@@ -40,8 +40,6 @@ class CefBrowserFrame
|
||||
base::ReadOnlySharedMemoryRegion region) override;
|
||||
void FrameAttached(mojo::PendingRemote<cef::mojom::RenderFrame> render_frame,
|
||||
bool reattached) override;
|
||||
void DidFinishFrameLoad(const GURL& validated_url,
|
||||
int32_t http_status_code) override;
|
||||
void UpdateDraggableRegions(
|
||||
absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions)
|
||||
override;
|
||||
|
@@ -848,14 +848,6 @@ bool CefBrowserHostBase::Navigate(const content::OpenURLParams& params) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame,
|
||||
const GURL& validated_url,
|
||||
int http_status_code) {
|
||||
frame->RefreshAttributes();
|
||||
|
||||
contents_delegate_->OnLoadEnd(frame, validated_url, http_status_code);
|
||||
}
|
||||
|
||||
void CefBrowserHostBase::ViewText(const std::string& text) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
|
@@ -247,9 +247,6 @@ class CefBrowserHostBase : public CefBrowserHost,
|
||||
|
||||
// Methods called from CefFrameHostImpl.
|
||||
void LoadMainFrameURL(const content::OpenURLParams& params);
|
||||
void OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame,
|
||||
const GURL& validated_url,
|
||||
int http_status_code);
|
||||
virtual void OnSetFocus(cef_focus_source_t source) = 0;
|
||||
void ViewText(const std::string& text);
|
||||
|
||||
|
@@ -647,13 +647,6 @@ void CefFrameHostImpl::FrameAttached(
|
||||
CefRefPtr<CefFrameHostImpl>(this), reattached));
|
||||
}
|
||||
|
||||
void CefFrameHostImpl::DidFinishFrameLoad(const GURL& validated_url,
|
||||
int http_status_code) {
|
||||
auto browser = GetBrowserHostBase();
|
||||
if (browser)
|
||||
browser->OnDidFinishLoad(this, validated_url, http_status_code);
|
||||
}
|
||||
|
||||
void CefFrameHostImpl::UpdateDraggableRegions(
|
||||
absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions) {
|
||||
auto browser = GetBrowserHostBase();
|
||||
|
@@ -136,8 +136,6 @@ class CefFrameHostImpl : public CefFrame, public cef::mojom::BrowserFrame {
|
||||
base::ReadOnlySharedMemoryRegion region) override;
|
||||
void FrameAttached(mojo::PendingRemote<cef::mojom::RenderFrame> render_frame,
|
||||
bool reattached) override;
|
||||
void DidFinishFrameLoad(const GURL& validated_url,
|
||||
int32_t http_status_code) override;
|
||||
void UpdateDraggableRegions(
|
||||
absl::optional<std::vector<cef::mojom::DraggableRegionEntryPtr>> regions)
|
||||
override;
|
||||
|
Reference in New Issue
Block a user