summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-20 20:12:53 +0000
committerxji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-20 20:12:53 +0000
commit2778def9d0245d1629cf77a6c35cf2ff7d452c83 (patch)
treedd5449085d5277075016bd2d77e4a80e0443c644
parentc67afaee8860470a3b716ed595223e0a187a9ade (diff)
downloadchromium_src-2778def9d0245d1629cf77a6c35cf2ff7d452c83.zip
chromium_src-2778def9d0245d1629cf77a6c35cf2ff7d452c83.tar.gz
chromium_src-2778def9d0245d1629cf77a6c35cf2ff7d452c83.tar.bz2
This CL fixes issue 2674 - Omnibar displays wrong parenthesis for "arabia.msn.com‬"
(http://crbug.com/2674) The issue is: in RTL locale, the search engine name, if ending with punctuation, might not be displayed correctly in omnibox keyword text and omnibox keyword hint. Fix: adjust the search engine keyword description (short name) for RTL locale so that the pure LTR search engine name is marked with LRE-PDF pair to be displayed correctly. For example, "MSN(English)" is displayed as is, not as "(MSN(English". Reproduce steps: Looks like the "MSN(English)" is no longer a default search engine name. We can make one by the following steps: 1. Open "customize and control Google Chrome" --> "Options", 2. under "basics" tab, under "Default search:", click "Manage" 3. click on one search engine from the "default search options", then click "edit". For example, pick "AOL". 4. change the "name" from "AOL" to "AOL(English)". Without the fix, in RTL Chrome, when type in "aol.com" in omnibox, the omni keyword hint shows "(AOL(English - xxxx <tab> yyy" while "xxx" stands for "to search" in Hebrew and "yyy" stands for "press" in Hebrew. After press <tab>, the keyword text in omnibox is ":(AOL(English - zzz" while "zzz" stands for "search" in Hebrew. With the fix, the name "AOL(English)" is displayed correctly in the above 2 places. Review URL: http://codereview.chromium.org/21320 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10116 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/location_bar_view.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc
index 0ec20a6..8d16e89 100644
--- a/chrome/browser/views/location_bar_view.cc
+++ b/chrome/browser/views/location_bar_view.cc
@@ -66,7 +66,14 @@ static std::wstring GetKeywordDescription(Profile* profile,
// to track changes to the model, this should become a DCHECK.
const TemplateURL* template_url =
profile->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword);
- return template_url ? template_url->short_name() : std::wstring();
+ if (template_url) {
+ std::wstring keyword_description;
+ if (l10n_util::AdjustStringForLocaleDirection(template_url->short_name(),
+ &keyword_description))
+ return keyword_description;
+ return template_url->short_name();
+ }
+ return std::wstring();
}
LocationBarView::LocationBarView(Profile* profile,
@@ -642,11 +649,15 @@ std::wstring LocationBarView::SelectedKeywordView::CalculateMinString(
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.
- return l10n_util::TruncateString(description, 3);
+ min_string = l10n_util::TruncateString(description, 3);
+ } else {
+ min_string = description.substr(0, chop_index);
}
- return description.substr(0, chop_index);
+ l10n_util::AdjustStringForLocaleDirection(min_string, &min_string);
+ return min_string;
}
// KeywordHintView -------------------------------------------------------------