Fix crash when destroying the browser window while a context menu is displayed.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1096 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2013-02-13 17:11:50 +00:00
parent 6604af5462
commit bb3a804033
1 changed files with 9 additions and 4 deletions

View File

@ -43,8 +43,10 @@ CefMenuCreator::~CefMenuCreator() {
}
bool CefMenuCreator::IsShowingContextMenu() {
content::RenderWidgetHostView* view =
browser_->GetWebContents()->GetRenderWidgetHostView();
content::WebContents* web_contents = browser_->GetWebContents();
if (!web_contents)
return false;
content::RenderWidgetHostView* view = web_contents->GetRenderWidgetHostView();
return (view && view->IsShowingContextMenu());
}
@ -159,9 +161,12 @@ void CefMenuCreator::MenuWillShow(CefRefPtr<CefMenuModelImpl> source) {
if (source.get() != model_.get())
return;
content::WebContents* web_contents = browser_->GetWebContents();
if (!web_contents)
return;
// Notify the host before showing the context menu.
content::RenderWidgetHostView* view =
browser_->GetWebContents()->GetRenderWidgetHostView();
content::RenderWidgetHostView* view = web_contents->GetRenderWidgetHostView();
if (view)
view->SetShowingContextMenu(true);
}