diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-07 19:44:25 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-07 19:44:25 +0000 |
commit | 478a521784818e429847b2d0e7011e1a521b2ff9 (patch) | |
tree | 64fe1862c4246e9f45c4c118ac5a37dad9ad535e /chrome/browser | |
parent | bc9e271112139a38fb81c38f00809a8a6d496542 (diff) | |
download | chromium_src-478a521784818e429847b2d0e7011e1a521b2ff9.zip chromium_src-478a521784818e429847b2d0e7011e1a521b2ff9.tar.gz chromium_src-478a521784818e429847b2d0e7011e1a521b2ff9.tar.bz2 |
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: <http://codereview.chromium.org/100246>
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15571 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.cc | 12 |
1 files changed, 8 insertions, 4 deletions
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); + } } } |