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

Unified Diff: chrome/browser/autocomplete/shortcuts_provider.cc

Issue 353223002: Omnibox: Fix URL-What-You-Typed Allowed-To-Be-Default-Match Issues (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix crashes on about: schemes Created 6 years, 5 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
« no previous file with comments | « chrome/browser/autocomplete/shortcuts_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/shortcuts_provider.cc
diff --git a/chrome/browser/autocomplete/shortcuts_provider.cc b/chrome/browser/autocomplete/shortcuts_provider.cc
index 34759744e38de38f15541e684f4a9a7f0b805042..721e65ebf5f40c652ceaf6f0a3f53839dbc047be 100644
--- a/chrome/browser/autocomplete/shortcuts_provider.cc
+++ b/chrome/browser/autocomplete/shortcuts_provider.cc
@@ -142,15 +142,13 @@ void ShortcutsProvider::GetMatches(const AutocompleteInput& input) {
base::string16 term_string(base::i18n::ToLower(input.text()));
DCHECK(!term_string.empty());
- const GURL& input_as_gurl =
- url_fixer::FixupURL(base::UTF16ToUTF8(input.text()), std::string());
- const base::string16 fixed_up_input(FixupUserInput(input).second);
-
int max_relevance;
if (!OmniboxFieldTrial::ShortcutsScoringMaxRelevance(
input.current_page_classification(), &max_relevance))
max_relevance = kShortcutsProviderDefaultMaxRelevance;
-
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile_);
+ const base::string16 fixed_up_input(FixupUserInput(input).second);
for (ShortcutsBackend::ShortcutMap::const_iterator it =
FindFirstMatch(term_string, backend.get());
it != backend->shortcuts_map().end() &&
@@ -159,9 +157,8 @@ void ShortcutsProvider::GetMatches(const AutocompleteInput& input) {
int relevance = CalculateScore(term_string, it->second, max_relevance);
if (relevance) {
matches_.push_back(ShortcutToACMatch(it->second, relevance, input,
- fixed_up_input, input_as_gurl));
- matches_.back().ComputeStrippedDestinationURL(
- TemplateURLServiceFactory::GetForProfile(profile_));
+ fixed_up_input));
+ matches_.back().ComputeStrippedDestinationURL(template_url_service);
}
}
// Remove duplicates. Duplicates don't need to be preserved in the matches
@@ -192,8 +189,7 @@ AutocompleteMatch ShortcutsProvider::ShortcutToACMatch(
const history::ShortcutsDatabase::Shortcut& shortcut,
int relevance,
const AutocompleteInput& input,
- const base::string16& fixed_up_input_text,
- const GURL& input_as_gurl) {
+ const base::string16& fixed_up_input_text) {
DCHECK(!input.text().empty());
AutocompleteMatch match;
match.provider = this;
@@ -244,16 +240,11 @@ AutocompleteMatch ShortcutsProvider::ShortcutToACMatch(
match.allowed_to_be_default_match =
!HistoryProvider::PreventInlineAutocomplete(input) ||
match.inline_autocompletion.empty();
- } else {
- // Also allow a user's input to be marked as default if it would be fixed
- // up to the same thing as the fill_into_edit. This handles cases like
- // the user input containing a trailing slash absent in fill_into_edit.
- match.allowed_to_be_default_match =
- (input_as_gurl ==
- url_fixer::FixupURL(base::UTF16ToUTF8(match.fill_into_edit),
- std::string()));
}
}
+ match.EnsureUWYTIsAllowedToBeDefault(
+ input.canonicalized_url(),
+ TemplateURLServiceFactory::GetForProfile(profile_));
// Try to mark pieces of the contents and description as matches if they
// appear in |input.text()|.
« no previous file with comments | « chrome/browser/autocomplete/shortcuts_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698