OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/search_engines/template_url.h" | 5 #include "components/search_engines/template_url.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1210 } | 1210 } |
1211 | 1211 |
1212 // static | 1212 // static |
1213 base::string16 TemplateURL::GenerateKeyword(const GURL& url) { | 1213 base::string16 TemplateURL::GenerateKeyword(const GURL& url) { |
1214 DCHECK(url.is_valid()); | 1214 DCHECK(url.is_valid()); |
1215 // Strip "www." off the front of the keyword; otherwise the keyword won't work | 1215 // Strip "www." off the front of the keyword; otherwise the keyword won't work |
1216 // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 . | 1216 // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 . |
1217 // Special case: if the host was exactly "www." (not sure this can happen but | 1217 // Special case: if the host was exactly "www." (not sure this can happen but |
1218 // perhaps with some weird intranet and custom DNS server?), ensure we at | 1218 // perhaps with some weird intranet and custom DNS server?), ensure we at |
1219 // least don't return the empty string. | 1219 // least don't return the empty string. |
1220 base::string16 keyword(net::StripWWWFromHost(url)); | 1220 // We do not want any punycode in any language. |
1221 base::string16 keyword(net::StripWWW(net::IDNToUnicode(url.host(), ""))); | |
Peter Kasting
2015/07/14 18:05:33
I think we should pass the user's accept-languages
alshabalin
2015/07/15 14:18:01
My thought was that a string in a language user do
Peter Kasting
2015/07/15 21:19:12
It seems like you're misunderstanding how the conv
alshabalin
2015/07/16 15:13:07
I thought script-mixing in hostnames is not allowe
alshabalin
2015/07/20 14:06:37
Done.
| |
1221 return keyword.empty() ? base::ASCIIToUTF16("www") : keyword; | 1222 return keyword.empty() ? base::ASCIIToUTF16("www") : keyword; |
1222 } | 1223 } |
1223 | 1224 |
1224 // static | 1225 // static |
1225 GURL TemplateURL::GenerateFaviconURL(const GURL& url) { | 1226 GURL TemplateURL::GenerateFaviconURL(const GURL& url) { |
1226 DCHECK(url.is_valid()); | 1227 DCHECK(url.is_valid()); |
1227 GURL::Replacements rep; | 1228 GURL::Replacements rep; |
1228 | 1229 |
1229 const char favicon_path[] = "/favicon.ico"; | 1230 const char favicon_path[] = "/favicon.ico"; |
1230 int favicon_path_len = arraysize(favicon_path) - 1; | 1231 int favicon_path_len = arraysize(favicon_path) - 1; |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1509 // patterns. This means that given patterns | 1510 // patterns. This means that given patterns |
1510 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], | 1511 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], |
1511 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would | 1512 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would |
1512 // return false. This is important for at least Google, where such URLs | 1513 // return false. This is important for at least Google, where such URLs |
1513 // are invalid. | 1514 // are invalid. |
1514 return !search_terms->empty(); | 1515 return !search_terms->empty(); |
1515 } | 1516 } |
1516 } | 1517 } |
1517 return false; | 1518 return false; |
1518 } | 1519 } |
OLD | NEW |