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

Unified Diff: components/omnibox/shortcuts_provider.cc

Issue 1098843004: Omnibox - Do Not Allow HTTP/HTTPS Equivalence if User Explicitly Entered A Scheme (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revise test cases to be correct Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: components/omnibox/shortcuts_provider.cc
diff --git a/components/omnibox/shortcuts_provider.cc b/components/omnibox/shortcuts_provider.cc
index fe6a04881ec7c4ba01df49122d3a73d51fc83dff..4a7600fa6035916e70d3013dd1fff6457bf2a366 100644
--- a/components/omnibox/shortcuts_provider.cc
+++ b/components/omnibox/shortcuts_provider.cc
@@ -143,12 +143,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.
@@ -227,7 +236,7 @@ AutocompleteMatch ShortcutsProvider::ShortcutToACMatch(
match.inline_autocompletion.empty();
}
}
- match.EnsureUWYTIsAllowedToBeDefault(input.canonicalized_url(),
+ match.EnsureUWYTIsAllowedToBeDefault(input,
client_->GetTemplateURLService());
// Try to mark pieces of the contents and description as matches if they
« components/omnibox/autocomplete_match_unittest.cc ('K') | « components/omnibox/search_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698