Chromium Code Reviews| Index: chrome/browser/autocomplete/autocomplete_match.cc |
| =================================================================== |
| --- chrome/browser/autocomplete/autocomplete_match.cc (revision 80868) |
| +++ chrome/browser/autocomplete/autocomplete_match.cc (working copy) |
| @@ -94,15 +94,15 @@ |
| // Sort identical destination_urls together. Place the most relevant matches |
| // first, so that when we call std::unique(), these are the ones that get |
| // preserved. |
| - return (elem1.destination_url != elem2.destination_url) ? |
| - (elem1.destination_url < elem2.destination_url) : |
| + return (elem1.stripped_destination_url != elem2.stripped_destination_url) ? |
| + (elem1.stripped_destination_url < elem2.stripped_destination_url) : |
| MoreRelevant(elem1, elem2); |
| } |
| // static |
| bool AutocompleteMatch::DestinationsEqual(const AutocompleteMatch& elem1, |
| const AutocompleteMatch& elem2) { |
| - return elem1.destination_url == elem2.destination_url; |
| + return elem1.stripped_destination_url == elem2.stripped_destination_url; |
| } |
| // static |
| @@ -151,6 +151,25 @@ |
| } |
| } |
| +void AutocompleteMatch::ComputeStrippedDestinationURL() { |
| + static const char prefix[] = "www."; |
| + static const size_t prefix_len = strlen(prefix); |
|
Peter Kasting
2011/04/11 23:17:33
Nit: Use arraysize(prefix) - 1 so this is a compil
|
| + |
| + if (!stripped_destination_url.is_empty()) |
|
Peter Kasting
2011/04/11 23:17:33
Nit: This check seems unnecessary
|
| + return; |
| + |
| + std::string host = destination_url.host(); |
| + if (destination_url.is_valid() && host.compare(0, prefix_len, prefix) == 0) { |
| + host = host.substr(prefix_len); |
| + GURL::Replacements replace_host; |
| + replace_host.SetHostStr(host); |
| + stripped_destination_url = |
| + destination_url.ReplaceComponents(replace_host); |
| + } else { |
| + stripped_destination_url = destination_url; |
| + } |
| +} |
| + |
| #ifndef NDEBUG |
| void AutocompleteMatch::Validate() const { |
| ValidateClassifications(contents, contents_class); |