diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-30 02:20:07 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-30 02:20:07 +0000 |
commit | 87609f15399bd5c26b4a0aa07b1cba0287f597e4 (patch) | |
tree | 50137fddddf2d47b8a6bc1c274f2c7315083c4dc /chrome/browser/views | |
parent | 1a0a19a59b7b57c166a49aa93dfda3568660d14d (diff) | |
download | chromium_src-87609f15399bd5c26b4a0aa07b1cba0287f597e4.zip chromium_src-87609f15399bd5c26b4a0aa07b1cba0287f597e4.tar.gz chromium_src-87609f15399bd5c26b4a0aa07b1cba0287f597e4.tar.bz2 |
Share common location bar functions across the 3 platforms that uses them.
BUG=None
TEST=compiles, and everything should works as before.
Review URL: http://codereview.chromium.org/2125020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48568 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/location_bar/selected_keyword_view.cc | 21 | ||||
-rw-r--r-- | chrome/browser/views/location_bar/selected_keyword_view.h | 3 |
2 files changed, 3 insertions, 21 deletions
diff --git a/chrome/browser/views/location_bar/selected_keyword_view.cc b/chrome/browser/views/location_bar/selected_keyword_view.cc index 4bcb827..aeead05 100644 --- a/chrome/browser/views/location_bar/selected_keyword_view.cc +++ b/chrome/browser/views/location_bar/selected_keyword_view.cc @@ -8,6 +8,7 @@ #include "base/i18n/rtl.h" #include "base/logging.h" #include "chrome/browser/search_engines/template_url_model.h" +#include "chrome/browser/location_bar_util.h" #include "chrome/browser/profile.h" #include "chrome/browser/views/location_bar/keyword_hint_view.h" #include "grit/generated_resources.h" @@ -63,25 +64,9 @@ void SelectedKeywordView::SetKeyword(const std::wstring& keyword) { int message_id = is_extension_keyword ? IDS_OMNIBOX_EXTENSION_KEYWORD_TEXT : IDS_OMNIBOX_KEYWORD_TEXT; full_label_.SetText(l10n_util::GetStringF(message_id, short_name)); - const std::wstring min_string = CalculateMinString(short_name); + const std::wstring min_string( + location_bar_util::CalculateMinString(short_name)); partial_label_.SetText(min_string.empty() ? full_label_.GetText() : l10n_util::GetStringF(message_id, min_string)); } - -std::wstring SelectedKeywordView::CalculateMinString( - const std::wstring& description) { - // Chop at the first '.' or whitespace. - const size_t dot_index = description.find(L'.'); - const size_t ws_index = description.find_first_of(kWhitespaceWide); - size_t chop_index = std::min(dot_index, ws_index); - std::wstring min_string; - if (chop_index == std::wstring::npos) { - // No dot or whitespace, truncate to at most 3 chars. - min_string = l10n_util::TruncateString(description, 3); - } else { - min_string = description.substr(0, chop_index); - } - base::i18n::AdjustStringForLocaleDirection(min_string, &min_string); - return min_string; -} diff --git a/chrome/browser/views/location_bar/selected_keyword_view.h b/chrome/browser/views/location_bar/selected_keyword_view.h index 8a3afbf..143025f 100644 --- a/chrome/browser/views/location_bar/selected_keyword_view.h +++ b/chrome/browser/views/location_bar/selected_keyword_view.h @@ -38,9 +38,6 @@ class SelectedKeywordView : public IconLabelBubbleView { void set_profile(Profile* profile) { profile_ = profile; } private: - // Returns the truncated version of description to use. - std::wstring CalculateMinString(const std::wstring& description); - // The keyword we're showing. If empty, no keyword is selected. // NOTE: we don't cache the TemplateURL as it is possible for it to get // deleted out from under us. |