From 66e2c28c1f940c38f54fc042b625c11d63375b48 Mon Sep 17 00:00:00 2001 From: "stevenjb@chromium.org" Date: Tue, 24 Jul 2012 18:07:55 +0000 Subject: Avoid crash in render view context menu with no browser. BUG=136809 TEST=See issue Review URL: https://chromiumcodereview.appspot.com/10805075 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148141 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/tab_contents/render_view_context_menu.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 9ff2c16..bd8bf56 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -1151,7 +1151,12 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { return IsDevCommandEnabled(id); case IDC_CONTENT_CONTEXT_VIEWPAGEINFO: - return source_web_contents_->GetController().GetActiveEntry() != NULL; + if (source_web_contents_->GetController().GetActiveEntry() == NULL) + return false; + // Disabled if no browser is associated (e.g. desktop notifications). + if (browser::FindBrowserWithWebContents(source_web_contents_) == NULL) + return false; + return true; case IDC_CONTENT_CONTEXT_TRANSLATE: { TabContents* tab_contents = @@ -1341,7 +1346,11 @@ bool RenderViewContextMenu::IsCommandIdEnabled(int id) const { case IDC_CONTENT_CONTEXT_GOTOURL: case IDC_SPELLPANEL_TOGGLE: case IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS: + return true; case IDC_CONTENT_CONTEXT_VIEWFRAMEINFO: + // Disabled if no browser is associated (e.g. desktop notifications). + if (browser::FindBrowserWithWebContents(source_web_contents_) == NULL) + return false; return true; case IDC_CHECK_SPELLING_WHILE_TYPING: -- cgit v1.1