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

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

Issue 13190020: Omnibox: Don't Promote Intranet Hostnames Pound Sign Space Whatever ("c# foo") (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/autocomplete/history_url_provider_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/history_url_provider.cc
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc
index dd2807e4438181216894e244125e7b7dbeb72a3e..9ba153a4a3afd39e69547615eaa0328514fc3849 100644
--- a/chrome/browser/autocomplete/history_url_provider.cc
+++ b/chrome/browser/autocomplete/history_url_provider.cc
@@ -741,16 +741,42 @@ bool HistoryURLProvider::FixupExactSuggestion(
break;
}
+ const GURL& url = match->destination_url;
+ const url_parse::Parsed& parsed = url.parsed_for_possibly_invalid_spec();
+ // If the what-you-typed result looks like a single word (which can be
+ // interpreted as an intranet address) followed by a pound sign ("#"),
+ // leave the score for the url-what-you-typed result as is. It will be
+ // outscored by a search query from the SearchProvider. This test fixes
+ // cases such as "c#" and "c# foo" where the user has visited an intranet
+ // site "c". We want the search-what-you-typed score to beat the
+ // URL-what-you-typed score in this case. Most of the below test tries to
+ // make sure that this code does not trigger if the user did anything to
+ // indicate the desired match is a URL. For instance, "c/# foo" will not
+ // pass the test because that will be classified as input type URL. The
+ // parsed.CountCharactersBefore() in the test looks for the presence of a
+ // reference fragment in the URL by checking whether the position differs
+ // included the delimiter (pound sign) versus not including the delimiter.
+ // (One cannot simply check url.ref() because it will not distinguish
+ // between the input "c" and the input "c#", both of which will have empty
+ // reference fragments.)
+ if ((type == UNVISITED_INTRANET) &&
+ (input.type() != AutocompleteInput::URL) &&
+ url.username().empty() && url.password().empty() && url.port().empty() &&
+ (url.path() == "/") && url.query().empty() &&
+ (parsed.CountCharactersBefore(url_parse::Parsed::REF, true) !=
+ parsed.CountCharactersBefore(url_parse::Parsed::REF, false))) {
+ return false;
+ }
+
match->relevance = CalculateRelevance(type, 0);
- if (type == UNVISITED_INTRANET && !matches->empty()) {
- // If there are any other matches, then don't promote this match here, in
- // hopes the caller will be able to inline autocomplete a better suggestion.
- // DoAutocomplete() will fall back on this match if inline autocompletion
- // fails. This matches how we react to never-visited URL inputs in the non-
- // intranet case.
+ // If there are any other matches, then don't promote this match here, in
+ // hopes the caller will be able to inline autocomplete a better suggestion.
+ // DoAutocomplete() will fall back on this match if inline autocompletion
+ // fails. This matches how we react to never-visited URL inputs in the non-
+ // intranet case.
+ if (type == UNVISITED_INTRANET && !matches->empty())
return false;
- }
// Put it on the front of the HistoryMatches for redirect culling.
CreateOrPromoteMatch(classifier.url_row(), string16::npos, false, matches,
« no previous file with comments | « no previous file | chrome/browser/autocomplete/history_url_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698