OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 case VisitClassifier::VISITED: | 698 case VisitClassifier::VISITED: |
699 // We have data for this match, use it. | 699 // We have data for this match, use it. |
700 match->deletable = true; | 700 match->deletable = true; |
701 match->description = classifier.url_row().title(); | 701 match->description = classifier.url_row().title(); |
702 AutocompleteMatch::ClassifyMatchInString( | 702 AutocompleteMatch::ClassifyMatchInString( |
703 input.text(), | 703 input.text(), |
704 classifier.url_row().title(), | 704 classifier.url_row().title(), |
705 ACMatchClassification::NONE, &match->description_class); | 705 ACMatchClassification::NONE, &match->description_class); |
706 if (!classifier.url_row().typed_count()) { | 706 if (!classifier.url_row().typed_count()) { |
707 // If we reach here, we must be in the second pass, and we must not have | 707 // If we reach here, we must be in the second pass, and we must not have |
708 // promoted this match as an exact match during the first pass. That | 708 // this row's data available during the first pass. That means we |
709 // means it will have been outscored by the "search what you typed | 709 // either scored it as WHAT_YOU_TYPED or UNVISITED_INTRANET, and to |
710 // match". We need to maintain that ordering in order to not make the | 710 // maintain the ordering between passes consistent, we need to score it |
711 // destination for the user's typing change depending on when they hit | 711 // the same way here. |
712 // enter. So lower the score here enough to let the search provider | 712 type = CanFindIntranetURL(db, input) ? |
713 // continue to outscore this match. | 713 UNVISITED_INTRANET : WHAT_YOU_TYPED; |
714 type = WHAT_YOU_TYPED; | |
715 } | 714 } |
716 break; | 715 break; |
717 case VisitClassifier::UNVISITED_INTRANET: | 716 case VisitClassifier::UNVISITED_INTRANET: |
718 type = UNVISITED_INTRANET; | 717 type = UNVISITED_INTRANET; |
719 break; | 718 break; |
720 default: | 719 default: |
721 DCHECK_EQ(VisitClassifier::UNVISITED, classifier.type()); | 720 DCHECK_EQ(VisitClassifier::UNVISITED, classifier.type()); |
722 break; | 721 break; |
723 } | 722 } |
724 | 723 |
(...skipping 20 matching lines...) Expand all Loading... |
745 // Normally passing the first two conditions below ought to guarantee the | 744 // Normally passing the first two conditions below ought to guarantee the |
746 // third condition, but because FixupUserInput() can run and modify the | 745 // third condition, but because FixupUserInput() can run and modify the |
747 // input's text and parts between Parse() and here, it seems better to be | 746 // input's text and parts between Parse() and here, it seems better to be |
748 // paranoid and check. | 747 // paranoid and check. |
749 if ((input.type() != AutocompleteInput::UNKNOWN) || | 748 if ((input.type() != AutocompleteInput::UNKNOWN) || |
750 !LowerCaseEqualsASCII(input.scheme(), chrome::kHttpScheme) || | 749 !LowerCaseEqualsASCII(input.scheme(), chrome::kHttpScheme) || |
751 !input.parts().host.is_nonempty()) | 750 !input.parts().host.is_nonempty()) |
752 return false; | 751 return false; |
753 const std::string host(UTF16ToUTF8( | 752 const std::string host(UTF16ToUTF8( |
754 input.text().substr(input.parts().host.begin, input.parts().host.len))); | 753 input.text().substr(input.parts().host.begin, input.parts().host.len))); |
755 if (net::RegistryControlledDomainService::GetRegistryLength(host, false) != 0) | 754 return (net::RegistryControlledDomainService::GetRegistryLength(host, |
756 return false; | 755 false) == 0) && db->IsTypedHost(host); |
757 return db->IsTypedHost(host); | |
758 } | 756 } |
759 | 757 |
760 bool HistoryURLProvider::PromoteMatchForInlineAutocomplete( | 758 bool HistoryURLProvider::PromoteMatchForInlineAutocomplete( |
761 HistoryURLProviderParams* params, | 759 HistoryURLProviderParams* params, |
762 const history::HistoryMatch& match, | 760 const history::HistoryMatch& match, |
763 const history::HistoryMatches& matches) { | 761 const history::HistoryMatches& matches) { |
764 // Promote the first match if it's been typed at least n times, where n == 1 | 762 // Promote the first match if it's been typed at least n times, where n == 1 |
765 // for "simple" (host-only) URLs and n == 2 for others. We set a higher bar | 763 // for "simple" (host-only) URLs and n == 2 for others. We set a higher bar |
766 // for these long URLs because it's less likely that users will want to visit | 764 // for these long URLs because it's less likely that users will want to visit |
767 // them again. Even though we don't increment the typed_count for pasted-in | 765 // them again. Even though we don't increment the typed_count for pasted-in |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 &match.contents_class); | 931 &match.contents_class); |
934 } | 932 } |
935 match.description = info.title(); | 933 match.description = info.title(); |
936 AutocompleteMatch::ClassifyMatchInString(params->input.text(), | 934 AutocompleteMatch::ClassifyMatchInString(params->input.text(), |
937 info.title(), | 935 info.title(), |
938 ACMatchClassification::NONE, | 936 ACMatchClassification::NONE, |
939 &match.description_class); | 937 &match.description_class); |
940 | 938 |
941 return match; | 939 return match; |
942 } | 940 } |
OLD | NEW |