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

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: fix 'c#' and 'c# ' and 'c#foo' Created 7 years, 9 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..8b39687208fe962c6edc0140df91274779628a45 100644
--- a/chrome/browser/autocomplete/history_url_provider.cc
+++ b/chrome/browser/autocomplete/history_url_provider.cc
@@ -741,6 +741,39 @@ bool HistoryURLProvider::FixupExactSuggestion(
break;
}
+ const GURL& url = match->destination_url;
+ const url_parse::Parsed& parsed = url.parsed_for_possibly_invalid_spec();
+ if ((type == UNVISITED_INTRANET) &&
+ (input.type() != AutocompleteInput::URL) &&
+ url.username().empty() && url.password().empty() &&
+ (net::RegistryControlledDomainService::GetRegistryLength(url.host(),
+ false) == 0) &&
Peter Kasting 2013/04/03 00:21:29 Why do we have to check the registry length? Does
Mark P 2013/04/03 16:08:01 You are correct. Removed.
+ (url.port().empty() || (url.port() == "-1")) && // -1 = "default"
+ (url.path().empty() || (url.path() == "/")) &&
Peter Kasting 2013/04/03 00:21:29 For the port and path checks, it'd be nice to avoi
Mark P 2013/04/03 16:08:01 Done.
+ url.query().empty() &&
+ (parsed.CountCharactersBefore(url_parse::Parsed::REF, true) !=
+ parsed.CountCharactersBefore(url_parse::Parsed::REF, false))) {
+ // If the what-you-typed result looks like a single word (which
Peter Kasting 2013/04/03 00:21:29 Nit: Put this comment above the conditional instea
Mark P 2013/04/03 16:08:01 Done.
+ // can be interpreted as an intranet address) followed by a pound
+ // sign ("#"), leave the score for the url-what-you-typed result
+ // as is and hope the top result ends up being a
Peter Kasting 2013/04/03 00:21:29 Nit: This sounds a bit sketchy when you say "hope"
Mark P 2013/04/03 16:08:01 We're guaranteed to be a search query above this (
+ // search-what-you-typed. This test fixes cases such as "c# foo"
+ // where the user has visited an intranet site "c". We want the
+ // search-what-you-typed to beat the URL-what-you-typed in this
+ // case. Most of the above 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 those 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.)
+ return false;
+ }
+
match->relevance = CalculateRelevance(type, 0);
if (type == UNVISITED_INTRANET && !matches->empty()) {
« 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