From 478a521784818e429847b2d0e7011e1a521b2ff9 Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Thu, 7 May 2009 19:44:25 +0000 Subject: Clicking right mouse button after selecting an image (or a whitespace character) brings up a context menu containing "Search Google for''". This change will fix the above by not adding the menu item if the selection string is empty. BUG=10798 patch by yuzo@google.com original review: git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15571 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/tab_contents/render_view_context_menu.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'chrome/browser/tab_contents') diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 35624d3..8708487 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -127,10 +127,14 @@ void RenderViewContextMenu::AppendSearchProvider() { const TemplateURL* const default_provider = profile_->GetTemplateURLModel()->GetDefaultSearchProvider(); if (default_provider != NULL) { - std::wstring label(l10n_util::GetStringF(IDS_CONTENT_CONTEXT_SEARCHWEBFOR, - default_provider->short_name(), - l10n_util::TruncateString(params_.selection_text, 50))); - AppendMenuItem(IDS_CONTENT_CONTEXT_SEARCHWEBFOR, label); + std::wstring selection_text = + l10n_util::TruncateString(params_.selection_text, 50); + if (!selection_text.empty()) { + std::wstring label(l10n_util::GetStringF(IDS_CONTENT_CONTEXT_SEARCHWEBFOR, + default_provider->short_name(), + selection_text)); + AppendMenuItem(IDS_CONTENT_CONTEXT_SEARCHWEBFOR, label); + } } } -- cgit v1.1