Commit 2cba5ed4 authored by Shawn Gallea's avatar Shawn Gallea Committed by Commit Bot

Do not reset controller when web contents destroyed

This instead calls OnError to allow for proper cleanup
when web contents destruction occurs.

Bug: Internal b/146500172
Test: Build cast_shell
Change-Id: I4c83313c8324e361cdb0a0275bfa76ea1a5ae72b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1985810
Commit-Queue: Shawn Gallea <sagallea@google.com>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733468}
parent 4355951f
...@@ -34,4 +34,8 @@ content::WebContents* CastAppController::GetWebContents() { ...@@ -34,4 +34,8 @@ content::WebContents* CastAppController::GetWebContents() {
return contents_; return contents_;
} }
void CastAppController::WebContentsDestroyed() {
contents_ = nullptr;
}
} // namespace chromecast } // namespace chromecast
...@@ -22,6 +22,9 @@ class CastAppController : public WebContentController { ...@@ -22,6 +22,9 @@ class CastAppController : public WebContentController {
content::WebContents* GetWebContents() override; content::WebContents* GetWebContents() override;
private: private:
// content::WebContentsObserver
void WebContentsDestroyed() override;
content::WebContents* contents_; content::WebContents* contents_;
DISALLOW_COPY_AND_ASSIGN(CastAppController); DISALLOW_COPY_AND_ASSIGN(CastAppController);
......
...@@ -68,8 +68,8 @@ void CastAppRpcInstance::CreateCastAppWindowLink(int platform_view_id, ...@@ -68,8 +68,8 @@ void CastAppRpcInstance::CreateCastAppWindowLink(int platform_view_id,
} }
void CastAppRpcInstance::WebContentsDestroyed() { void CastAppRpcInstance::WebContentsDestroyed() {
controller_.reset();
window_manager_->RemoveObserver(this); window_manager_->RemoveObserver(this);
OnError("Web contents destroyed");
} }
} // namespace chromecast } // namespace chromecast
...@@ -59,7 +59,8 @@ void PlatformViewsRpcInstance::OnError(const std::string& error_message) { ...@@ -59,7 +59,8 @@ void PlatformViewsRpcInstance::OnError(const std::string& error_message) {
void PlatformViewsRpcInstance::ProcessRequestOnControllerThread( void PlatformViewsRpcInstance::ProcessRequestOnControllerThread(
std::unique_ptr<webview::WebviewRequest> request) { std::unique_ptr<webview::WebviewRequest> request) {
controller_->ProcessRequest(*request.get()); if (!errored_)
controller_->ProcessRequest(*request.get());
} }
void PlatformViewsRpcInstance::InitComplete(bool ok) { void PlatformViewsRpcInstance::InitComplete(bool ok) {
......
...@@ -406,7 +406,11 @@ void WebContentController::HandleSetAutoMediaPlaybackPolicy( ...@@ -406,7 +406,11 @@ void WebContentController::HandleSetAutoMediaPlaybackPolicy(
} }
viz::SurfaceId WebContentController::GetSurfaceId() { viz::SurfaceId WebContentController::GetSurfaceId() {
auto* rwhv = GetWebContents()->GetRenderWidgetHostView(); content::WebContents* web_contents = GetWebContents();
// Web contents are destroyed before controller for cast apps.
if (!web_contents)
return viz::SurfaceId();
auto* rwhv = web_contents->GetRenderWidgetHostView();
if (!rwhv) if (!rwhv)
return viz::SurfaceId(); return viz::SurfaceId();
auto frame_sink_id = rwhv->GetRenderWidgetHost()->GetFrameSinkId(); auto frame_sink_id = rwhv->GetRenderWidgetHost()->GetFrameSinkId();
......
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