Commit ae5b774a authored by Sean Topping's avatar Sean Topping Committed by Commit Bot

[Chromecast] Handle other page stop events in CastWebViewExtension

This mirrors the logic in CastWebViewDefault, where load errors will
forcibly stop and restart the page. In particular, this allows us to
handle network changes when we're in the middle of loading an extension
page.

Bug: internal b/79432754
Test: Test device in bi-interface mode, verify UI page properly reloads
      on network change.

Change-Id: I004db712b6a016f0f16bf3341399f800da069d77
Reviewed-on: https://chromium-review.googlesource.com/1096657
Commit-Queue: Sean Topping <seantopping@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566597}
parent 9f482eae
......@@ -83,6 +83,52 @@ void CastWebViewExtension::RenderViewCreated(
}
}
void CastWebViewExtension::DidFinishNavigation(
content::NavigationHandle* navigation_handle) {
// If the navigation was not committed, it means either the page was a
// download or error 204/205, or the navigation never left the previous
// URL. Basically, this isn't a problem since we stayed at the existing URL.
if (!navigation_handle->HasCommitted())
return;
// The navigation committed. If we navigated to an error page then
// this is a bad state, and should be notified. Otherwise the navigation
// completed as intended.
if (!navigation_handle->IsErrorPage())
return;
net::Error error_code = navigation_handle->GetNetErrorCode();
// Ignore sub-frame errors.
if (!navigation_handle->IsInMainFrame()) {
LOG(ERROR) << "Got error on sub-frame: url=" << navigation_handle->GetURL()
<< ", error=" << error_code
<< ", description=" << net::ErrorToShortString(error_code);
return;
}
LOG(ERROR) << "Got error on navigation: url=" << navigation_handle->GetURL()
<< ", error_code=" << error_code
<< ", description= " << net::ErrorToShortString(error_code);
delegate_->OnPageStopped(error_code);
}
void CastWebViewExtension::DidFailLoad(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code,
const base::string16& error_description) {
// Only report an error if we are the main frame.
if (render_frame_host->GetParent()) {
LOG(ERROR) << "Got error on sub-frame: url=" << validated_url.spec()
<< ", error=" << error_code << ": " << error_description;
return;
}
LOG(ERROR) << "Got error on load: url=" << validated_url.spec()
<< ", error_code=" << error_code << ": " << error_description;
;
delegate_->OnPageStopped(error_code);
}
void CastWebViewExtension::RenderProcessGone(base::TerminationStatus status) {
delegate_->OnPageStopped(net::ERR_UNEXPECTED);
}
......
......@@ -58,6 +58,12 @@ class CastWebViewExtension : public CastWebView, content::WebContentsObserver {
// WebContentsObserver implementation:
void WebContentsDestroyed() override;
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override;
void DidFailLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code,
const base::string16& error_description) override;
void RenderProcessGone(base::TerminationStatus status) override;
Delegate* const delegate_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment