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 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 return kBaseScoreForNonInlineableResult + match_number; | 699 return kBaseScoreForNonInlineableResult + match_number; |
700 } | 700 } |
701 } | 701 } |
702 | 702 |
703 // static | 703 // static |
704 ACMatchClassifications HistoryURLProvider::ClassifyDescription( | 704 ACMatchClassifications HistoryURLProvider::ClassifyDescription( |
705 const base::string16& input_text, | 705 const base::string16& input_text, |
706 const base::string16& description) { | 706 const base::string16& description) { |
707 base::string16 clean_description = | 707 base::string16 clean_description = |
708 bookmarks::CleanUpTitleForMatching(description); | 708 bookmarks::CleanUpTitleForMatching(description); |
709 history::TermMatches description_matches(SortAndDeoverlapMatches( | 709 TermMatches description_matches(SortAndDeoverlapMatches( |
710 history::MatchTermInString(input_text, clean_description, 0))); | 710 MatchTermInString(input_text, clean_description, 0))); |
711 history::WordStarts description_word_starts; | 711 WordStarts description_word_starts; |
712 history::String16VectorFromString16( | 712 String16VectorFromString16(clean_description, false, |
713 clean_description, false, &description_word_starts); | 713 &description_word_starts); |
714 // If HistoryURL retrieves any matches (and hence we reach this code), we | 714 // If HistoryURL retrieves any matches (and hence we reach this code), we |
715 // are guaranteed that the beginning of input_text must be a word break. | 715 // are guaranteed that the beginning of input_text must be a word break. |
716 history::WordStarts offsets(1, 0u); | 716 WordStarts offsets(1, 0u); |
717 description_matches = | 717 description_matches = |
718 ScoredHistoryMatchBuilderImpl::FilterTermMatchesByWordStarts( | 718 ScoredHistoryMatchBuilderImpl::FilterTermMatchesByWordStarts( |
719 description_matches, offsets, description_word_starts, 0, | 719 description_matches, offsets, description_word_starts, 0, |
720 std::string::npos); | 720 std::string::npos); |
721 return SpansFromTermMatch( | 721 return SpansFromTermMatch( |
722 description_matches, clean_description.length(), false); | 722 description_matches, clean_description.length(), false); |
723 } | 723 } |
724 | 724 |
725 void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend, | 725 void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend, |
726 history::URLDatabase* db, | 726 history::URLDatabase* db, |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, | 1153 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, |
1154 match.contents.length(), ACMatchClassification::URL, | 1154 match.contents.length(), ACMatchClassification::URL, |
1155 &match.contents_class); | 1155 &match.contents_class); |
1156 } | 1156 } |
1157 match.description = info.title(); | 1157 match.description = info.title(); |
1158 match.description_class = | 1158 match.description_class = |
1159 ClassifyDescription(params.input.text(), match.description); | 1159 ClassifyDescription(params.input.text(), match.description); |
1160 RecordAdditionalInfoFromUrlRow(info, &match); | 1160 RecordAdditionalInfoFromUrlRow(info, &match); |
1161 return match; | 1161 return match; |
1162 } | 1162 } |
OLD | NEW |