Index: chrome/browser/autocomplete/shortcuts_provider.cc |
diff --git a/chrome/browser/autocomplete/shortcuts_provider.cc b/chrome/browser/autocomplete/shortcuts_provider.cc |
index 8ead62e723d8dad0cccf6424efd8abfcb4feb7df..57943906f1c258e1d29790a02b7b382dceb0fe88 100644 |
--- a/chrome/browser/autocomplete/shortcuts_provider.cc |
+++ b/chrome/browser/autocomplete/shortcuts_provider.cc |
@@ -152,12 +152,21 @@ void ShortcutsProvider::GetMatches(const AutocompleteInput& input) { |
if (relevance) { |
matches_.push_back(ShortcutToACMatch(it->second, relevance, input, |
fixed_up_input)); |
- matches_.back().ComputeStrippedDestinationURL(template_url_service); |
+ matches_.back().ComputeStrippedDestinationURL(input, |
+ template_url_service); |
} |
} |
- // Remove duplicates. Duplicates don't need to be preserved in the matches |
- // because they are only used for deletions, and shortcuts deletes matches |
- // based on the URL. |
+ // Remove duplicates. This is important because it's common to have multiple |
+ // shortcuts pointing to the same URL, e.g., ma, mai, and mail all pointing |
+ // to mail.google.com, so typing "m" will return them all. If we then simply |
+ // clamp to kMaxMatches and let the AutocompleteResult take care of |
+ // collapsing the duplicates, we'll effectively only be returning one match, |
+ // instead of several possibilities. |
+ // |
+ // Note that while removing duplicates, we don't populate a match's |
+ // |duplicate_matches| field--duplicates don't need to be preserved in the |
+ // matches because they are only used for deletions, and this provider |
+ // deletes matches based on the URL. |
AutocompleteResult::DedupMatchesByDestination( |
input.current_page_classification(), false, &matches_); |
// Find best matches. |
@@ -236,7 +245,7 @@ AutocompleteMatch ShortcutsProvider::ShortcutToACMatch( |
} |
} |
match.EnsureUWYTIsAllowedToBeDefault( |
- input.canonicalized_url(), |
+ input, |
TemplateURLServiceFactory::GetForProfile(profile_)); |
// Try to mark pieces of the contents and description as matches if they |