Commit 44a4b566 authored by jennb@chromium.org's avatar jennb@chromium.org

[Panels] Fix favicon crash from using deleted WebContents.

Updated TaskManagerPanelResourceProvider to no longer expect Panel to have web contents after web contents are disconnected.

BUG=155133
TEST=updated

Review URL: https://chromiumcodereview.appspot.com/11092066

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162200 0039d316-1c4b-4281-b951-d872f2087c98
parent 32e2d81b
......@@ -702,7 +702,7 @@ void TaskManagerPanelResourceProvider::Observe(int type,
for (PanelResourceMap::iterator iter = resources_.begin();
iter != resources_.end(); ++iter) {
Panel* panel = iter->first;
if (panel->GetWebContents() == web_contents) {
if (!panel->GetWebContents()) {
Remove(panel);
break;
}
......
......@@ -71,7 +71,12 @@ void PanelHost::Init(const GURL& url) {
}
void PanelHost::DestroyWebContents() {
web_contents_.reset();
// Cannot do a web_contents_.reset() because web_contents_.get() will
// still return the pointer when we CHECK in WebContentsDestroyed (or if
// we get called back in the middle of web contents destruction, which
// WebView might do when it detects the web contents is destroyed).
content::WebContents* contents = web_contents_.release();
delete contents;
}
gfx::Image PanelHost::GetPageIcon() const {
......@@ -80,6 +85,7 @@ gfx::Image PanelHost::GetPageIcon() const {
FaviconTabHelper* favicon_tab_helper =
FaviconTabHelper::FromWebContents(web_contents_.get());
CHECK(favicon_tab_helper);
return favicon_tab_helper->GetFavicon();
}
......@@ -203,6 +209,9 @@ void PanelHost::RenderViewGone(base::TerminationStatus status) {
}
void PanelHost::WebContentsDestroyed(content::WebContents* web_contents) {
// Web contents should only be destroyed by us.
CHECK(!web_contents_.get());
// Close the panel after we return to the message loop (not immediately,
// otherwise, it may destroy this object before the stack has a chance
// to cleanly unwind.)
......
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