Chromium Code Reviews| Index: components/search_engines/template_url.cc |
| diff --git a/components/search_engines/template_url.cc b/components/search_engines/template_url.cc |
| index dbb74fc77853e1fe3c15533b7a1740a360ecf6fe..9d4dde80ef6ffe2ed97ca488ab45f8dab12b67a3 100644 |
| --- a/components/search_engines/template_url.cc |
| +++ b/components/search_engines/template_url.cc |
| @@ -1210,14 +1210,20 @@ TemplateURL::~TemplateURL() { |
| } |
| // static |
| -base::string16 TemplateURL::GenerateKeyword(const GURL& url) { |
| +base::string16 TemplateURL::GenerateKeyword( |
| + const GURL& url, |
| + const std::string& accept_languages) { |
| DCHECK(url.is_valid()); |
| // Strip "www." off the front of the keyword; otherwise the keyword won't work |
| // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 . |
| + // Since keyword is generated from hostname, it might be IDN-encoded. |
| + // If so, decode it and convert to Unicode using user's accepted languages, |
| + // making it look like Unicode hostname the user is used to seeing. |
|
Peter Kasting
2015/07/21 17:34:09
Grammar issues. Try this:
|url|'s hostname may b
alshabalin
2015/07/22 14:31:17
Done.
|
| + base::string16 keyword = |
| + net::StripWWW(net::IDNToUnicode(url.host(), accept_languages)); |
| // Special case: if the host was exactly "www." (not sure this can happen but |
| // perhaps with some weird intranet and custom DNS server?), ensure we at |
| // least don't return the empty string. |
| - base::string16 keyword(net::StripWWWFromHost(url)); |
| return keyword.empty() ? base::ASCIIToUTF16("www") : keyword; |
| } |
| @@ -1485,7 +1491,8 @@ void TemplateURL::ResetKeywordIfNecessary( |
| DCHECK(GetType() != OMNIBOX_API_EXTENSION); |
| GURL url(GenerateSearchURL(search_terms_data)); |
| if (url.is_valid()) |
| - data_.SetKeyword(GenerateKeyword(url)); |
| + data_.SetKeyword( |
| + GenerateKeyword(url, search_terms_data.GetAcceptLanguages())); |
| } |
| } |