OLD | NEW |
---|---|
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 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
753 | 753 |
754 // Create sorted list of suggestions. | 754 // Create sorted list of suggestions. |
755 CullPoorMatches(params); | 755 CullPoorMatches(params); |
756 SortAndDedupMatches(¶ms->matches); | 756 SortAndDedupMatches(¶ms->matches); |
757 | 757 |
758 // Try to create a shorter suggestion from the best match. | 758 // Try to create a shorter suggestion from the best match. |
759 // We consider the what you typed match eligible for display when there's a | 759 // We consider the what you typed match eligible for display when there's a |
760 // reasonable chance the user actually cares: | 760 // reasonable chance the user actually cares: |
761 // * Their input can be opened as a URL, and | 761 // * Their input can be opened as a URL, and |
762 // * We parsed the input as a URL, or it starts with an explicit "http:" or | 762 // * We parsed the input as a URL, or it starts with an explicit "http:" or |
763 // "https:". | 763 // "https:". |
Peter Kasting
2014/10/24 01:10:07
Nit: These comments should be updated. How about:
| |
764 // Otherwise, this is just low-quality noise. In the cases where we've parsed | 764 // Otherwise, this is just low-quality noise. In the cases where we've parsed |
765 // as UNKNOWN, we'll still show an accidental search infobar if need be. | 765 // as UNKNOWN, we'll still show an accidental search infobar if need be. |
766 VisitClassifier classifier(this, params->input, db); | 766 VisitClassifier classifier(this, params->input, db); |
767 params->have_what_you_typed_match = | 767 params->have_what_you_typed_match = |
768 (params->input.type() != metrics::OmniboxInputType::QUERY) && | 768 (params->input.type() != metrics::OmniboxInputType::QUERY) && |
769 ((params->input.type() != metrics::OmniboxInputType::UNKNOWN) || | 769 ((params->input.type() != metrics::OmniboxInputType::UNKNOWN) || |
770 (classifier.type() == VisitClassifier::UNVISITED_INTRANET) || | 770 (classifier.type() == VisitClassifier::UNVISITED_INTRANET) || |
771 !params->trim_http || | 771 !params->trim_http || |
772 (AutocompleteInput::NumNonHostComponents(params->input.parts()) > 0)); | 772 (AutocompleteInput::NumNonHostComponents(params->input.parts()) > 0) || |
773 (params->default_search_provider == NULL)); | |
Peter Kasting
2014/10/24 01:10:07
Nit: Just do
!params->default_search_provid
| |
773 const bool have_shorter_suggestion_suitable_for_inline_autocomplete = | 774 const bool have_shorter_suggestion_suitable_for_inline_autocomplete = |
774 PromoteOrCreateShorterSuggestion( | 775 PromoteOrCreateShorterSuggestion( |
775 db, params->have_what_you_typed_match, params); | 776 db, params->have_what_you_typed_match, params); |
776 | 777 |
777 // Check whether what the user typed appears in history. | 778 // Check whether what the user typed appears in history. |
778 const bool can_check_history_for_exact_match = | 779 const bool can_check_history_for_exact_match = |
779 // Checking what_you_typed_match.is_history_what_you_typed_match tells us | 780 // Checking what_you_typed_match.is_history_what_you_typed_match tells us |
780 // whether SuggestExactInput() succeeded in constructing a valid match. | 781 // whether SuggestExactInput() succeeded in constructing a valid match. |
781 params->what_you_typed_match.is_history_what_you_typed_match && | 782 params->what_you_typed_match.is_history_what_you_typed_match && |
782 // Additionally, in the case where the user has typed "foo.com" and | 783 // Additionally, in the case where the user has typed "foo.com" and |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1155 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, | 1156 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, |
1156 match.contents.length(), ACMatchClassification::URL, | 1157 match.contents.length(), ACMatchClassification::URL, |
1157 &match.contents_class); | 1158 &match.contents_class); |
1158 } | 1159 } |
1159 match.description = info.title(); | 1160 match.description = info.title(); |
1160 match.description_class = | 1161 match.description_class = |
1161 ClassifyDescription(params.input.text(), match.description); | 1162 ClassifyDescription(params.input.text(), match.description); |
1162 RecordAdditionalInfoFromUrlRow(info, &match); | 1163 RecordAdditionalInfoFromUrlRow(info, &match); |
1163 return match; | 1164 return match; |
1164 } | 1165 } |
OLD | NEW |