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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/autocomplete/history_url_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autocomplete/history_url_provider.h" 5 #include "chrome/browser/autocomplete/history_url_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 // this row's data available during the first pass. That means we 734 // this row's data available during the first pass. That means we
735 // either scored it as WHAT_YOU_TYPED or UNVISITED_INTRANET, and to 735 // either scored it as WHAT_YOU_TYPED or UNVISITED_INTRANET, and to
736 // maintain the ordering between passes consistent, we need to score it 736 // maintain the ordering between passes consistent, we need to score it
737 // the same way here. 737 // the same way here.
738 type = CanFindIntranetURL(db, input) ? 738 type = CanFindIntranetURL(db, input) ?
739 UNVISITED_INTRANET : WHAT_YOU_TYPED; 739 UNVISITED_INTRANET : WHAT_YOU_TYPED;
740 } 740 }
741 break; 741 break;
742 } 742 }
743 743
744 const GURL& url = match->destination_url;
745 const url_parse::Parsed& parsed = url.parsed_for_possibly_invalid_spec();
746 if ((type == UNVISITED_INTRANET) &&
747 (input.type() != AutocompleteInput::URL) &&
748 url.username().empty() && url.password().empty() &&
749 (net::RegistryControlledDomainService::GetRegistryLength(url.host(),
750 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.
751 (url.port().empty() || (url.port() == "-1")) && // -1 = "default"
752 (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.
753 url.query().empty() &&
754 (parsed.CountCharactersBefore(url_parse::Parsed::REF, true) !=
755 parsed.CountCharactersBefore(url_parse::Parsed::REF, false))) {
756 // 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.
757 // can be interpreted as an intranet address) followed by a pound
758 // sign ("#"), leave the score for the url-what-you-typed result
759 // 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 (
760 // search-what-you-typed. This test fixes cases such as "c# foo"
761 // where the user has visited an intranet site "c". We want the
762 // search-what-you-typed to beat the URL-what-you-typed in this
763 // case. Most of the above test tries to make sure that this code
764 // does not trigger if the user did anything to indicate the
765 // desired match is a URL. For instance, "c/# foo" will not pass
766 // the test because those will be classified as input type URL.
767 // The parsed.CountCharactersBefore() in the test looks for the
768 // presence of a reference fragment in the URL by checking whether
769 // the position differs included the delimiter (pound sign) versus
770 // not including the delimiter. (One cannot simply check
771 // url.ref() because it will not distinguish between the input "c"
772 // and the input "c#", both of which will have empty reference
773 // fragments.)
774 return false;
775 }
776
744 match->relevance = CalculateRelevance(type, 0); 777 match->relevance = CalculateRelevance(type, 0);
745 778
746 if (type == UNVISITED_INTRANET && !matches->empty()) { 779 if (type == UNVISITED_INTRANET && !matches->empty()) {
747 // If there are any other matches, then don't promote this match here, in 780 // If there are any other matches, then don't promote this match here, in
748 // hopes the caller will be able to inline autocomplete a better suggestion. 781 // hopes the caller will be able to inline autocomplete a better suggestion.
749 // DoAutocomplete() will fall back on this match if inline autocompletion 782 // DoAutocomplete() will fall back on this match if inline autocompletion
750 // fails. This matches how we react to never-visited URL inputs in the non- 783 // fails. This matches how we react to never-visited URL inputs in the non-
751 // intranet case. 784 // intranet case.
752 return false; 785 return false;
753 } 786 }
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 &match.contents_class); 1081 &match.contents_class);
1049 } 1082 }
1050 match.description = info.title(); 1083 match.description = info.title();
1051 AutocompleteMatch::ClassifyMatchInString(params->input.text(), 1084 AutocompleteMatch::ClassifyMatchInString(params->input.text(),
1052 info.title(), 1085 info.title(),
1053 ACMatchClassification::NONE, 1086 ACMatchClassification::NONE,
1054 &match.description_class); 1087 &match.description_class);
1055 RecordAdditionalInfoFromUrlRow(info, &match); 1088 RecordAdditionalInfoFromUrlRow(info, &match);
1056 return match; 1089 return match;
1057 } 1090 }
OLDNEW
« 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