Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: components/search_engines/template_url.cc

Issue 2806593006: Changed GenerateKeyword to always return keyword in lowercase (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/command_line.h" 10 #include "base/command_line.h"
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/i18n/case_conversion.h"
12 #include "base/i18n/icu_string_conversions.h" 13 #include "base/i18n/icu_string_conversions.h"
13 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/metrics/field_trial.h" 17 #include "base/metrics/field_trial.h"
17 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/string_piece.h" 19 #include "base/strings/string_piece.h"
19 #include "base/strings/string_split.h" 20 #include "base/strings/string_split.h"
20 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
21 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 DCHECK(url.is_valid()); 1171 DCHECK(url.is_valid());
1171 // Strip "www." off the front of the keyword; otherwise the keyword won't work 1172 // Strip "www." off the front of the keyword; otherwise the keyword won't work
1172 // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 . 1173 // properly. See http://code.google.com/p/chromium/issues/detail?id=6984 .
1173 // |url|'s hostname may be IDN-encoded. Before generating |keyword| from it, 1174 // |url|'s hostname may be IDN-encoded. Before generating |keyword| from it,
1174 // convert to Unicode, so it won't look like a confusing punycode string. 1175 // convert to Unicode, so it won't look like a confusing punycode string.
1175 base::string16 keyword = url_formatter::StripWWW( 1176 base::string16 keyword = url_formatter::StripWWW(
1176 url_formatter::IDNToUnicode(url.host())); 1177 url_formatter::IDNToUnicode(url.host()));
1177 // Special case: if the host was exactly "www." (not sure this can happen but 1178 // Special case: if the host was exactly "www." (not sure this can happen but
1178 // perhaps with some weird intranet and custom DNS server?), ensure we at 1179 // perhaps with some weird intranet and custom DNS server?), ensure we at
1179 // least don't return the empty string. 1180 // least don't return the empty string.
1180 return keyword.empty() ? base::ASCIIToUTF16("www") : keyword; 1181 return keyword.empty() ? base::ASCIIToUTF16("www")
1182 : base::i18n::ToLower(keyword);
1181 } 1183 }
1182 1184
1183 // static 1185 // static
1184 GURL TemplateURL::GenerateFaviconURL(const GURL& url) { 1186 GURL TemplateURL::GenerateFaviconURL(const GURL& url) {
1185 DCHECK(url.is_valid()); 1187 DCHECK(url.is_valid());
1186 GURL::Replacements rep; 1188 GURL::Replacements rep;
1187 1189
1188 const char favicon_path[] = "/favicon.ico"; 1190 const char favicon_path[] = "/favicon.ico";
1189 int favicon_path_len = arraysize(favicon_path) - 1; 1191 int favicon_path_len = arraysize(favicon_path) - 1;
1190 1192
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 // patterns. This means that given patterns 1501 // patterns. This means that given patterns
1500 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ], 1502 // [ "http://foo/#q={searchTerms}", "http://foo/?q={searchTerms}" ],
1501 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would 1503 // calling ExtractSearchTermsFromURL() on "http://foo/?q=bar#q=' would
1502 // return false. This is important for at least Google, where such URLs 1504 // return false. This is important for at least Google, where such URLs
1503 // are invalid. 1505 // are invalid.
1504 return !search_terms->empty(); 1506 return !search_terms->empty();
1505 } 1507 }
1506 } 1508 }
1507 return false; 1509 return false;
1508 } 1510 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698