diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-05 23:03:32 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-05 23:03:32 +0000 |
commit | 68d3c9eabf88ed410127c6ef3ffaf6f007c74a19 (patch) | |
tree | 382995b74698aecd84b00148bd5b21b5f1c88e04 /chrome/browser/views/go_button.cc | |
parent | b39b708246bd53c09e4fea01dac923d742c303e0 (diff) | |
download | chromium_src-68d3c9eabf88ed410127c6ef3ffaf6f007c74a19.zip chromium_src-68d3c9eabf88ed410127c6ef3ffaf6f007c74a19.tar.gz chromium_src-68d3c9eabf88ed410127c6ef3ffaf6f007c74a19.tar.bz2 |
Give the Go button the correct tooltip based on what's in the omnibox.
BUG=6906
TEST=Type "foo" into the Omnibox. Verify the Go button tooltip refers to searching for "foo" using your default engine. Change to "foo.com". Verify the Go button tooltip refers to navigating to foo.com. Change to using some custom search engine (e.g. tab-to-search on yahoo.com) and put in a search term. Verify the Go button tooltip refers to searching for your term on the chosen engine.
Review URL: http://codereview.chromium.org/119263
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17791 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/go_button.cc')
-rw-r--r-- | chrome/browser/views/go_button.cc | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/chrome/browser/views/go_button.cc b/chrome/browser/views/go_button.cc index 54381ae..f3a040d 100644 --- a/chrome/browser/views/go_button.cc +++ b/chrome/browser/views/go_button.cc @@ -9,6 +9,8 @@ #include "base/message_loop.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser.h" +#include "chrome/browser/profile.h" +#include "chrome/browser/search_engines/template_url_model.h" #include "chrome/browser/views/event_utils.h" #include "chrome/browser/views/location_bar_view.h" #include "grit/generated_resources.h" @@ -116,12 +118,22 @@ bool GoButton::GetTooltipText(int x, int y, std::wstring* tooltip) { if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) l10n_util::WrapStringWithLTRFormatting(¤t_text); - // TODO(pkasting): http://b/868940 Use the right strings at the right times by - // asking the autocomplete system what to do. Don't hardcode "Google" as the - // search provider name. - tooltip->assign(true ? - l10n_util::GetStringF(IDS_TOOLTIP_GO_SITE, current_text) : - l10n_util::GetStringF(IDS_TOOLTIP_GO_SEARCH, L"Google", current_text)); + AutocompleteEditModel* edit_model = location_bar_->location_entry()->model(); + if (edit_model->CurrentTextIsURL()) { + tooltip->assign(l10n_util::GetStringF(IDS_TOOLTIP_GO_SITE, current_text)); + } else { + std::wstring keyword(edit_model->keyword()); + TemplateURLModel* template_url_model = + location_bar_->profile()->GetTemplateURLModel(); + const TemplateURL* provider = + (keyword.empty() || edit_model->is_keyword_hint()) ? + template_url_model->GetDefaultSearchProvider() : + template_url_model->GetTemplateURLForKeyword(keyword); + if (!provider) + return false; + tooltip->assign(l10n_util::GetStringF(IDS_TOOLTIP_GO_SEARCH, + provider->AdjustedShortNameForLocaleDirection(), current_text)); + } return true; } |