Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(873)

Unified Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 1355513003: Adds NULL checks in RenderFrameHostImpl::GetVisibilityState(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/render_frame_host_impl.cc
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index 8f6c99c269f96de55707f4f34fffa855cced9901..dbd10ed7233324d1ee31dcf7f53c8cd2dd7a06e5 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -378,10 +378,17 @@ ServiceRegistry* RenderFrameHostImpl::GetServiceRegistry() {
}
blink::WebPageVisibilityState RenderFrameHostImpl::GetVisibilityState() {
+ // Works around the crashes seen in https://crbug.com/501863, where the
+ // active WebContents from a browser iterator may contain a render frame
+ // detached from the frame tree.
+ RenderWidgetHostView* view = RenderFrameHostImpl::GetView();
+ if (!view || !view->GetRenderWidgetHost())
+ return blink::WebPageVisibilityStateHidden;
+
// TODO(mlamouri,kenrb): call GetRenderWidgetHost() directly when it stops
// returning nullptr in some cases. See https://crbug.com/455245.
blink::WebPageVisibilityState visibility_state =
- RenderWidgetHostImpl::From(GetView()->GetRenderWidgetHost())->is_hidden()
+ RenderWidgetHostImpl::From(view->GetRenderWidgetHost())->is_hidden()
? blink::WebPageVisibilityStateHidden
: blink::WebPageVisibilityStateVisible;
GetContentClient()->browser()->OverridePageVisibilityState(this,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698