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

Side by Side Diff: chrome/browser/autocomplete/history_url_provider.cc

Issue 976423002: Remove ScoreHistoryMatch::Builder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cpplint
Patch Set: Address comments Created 5 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 unified diff | Download patch
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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" 18 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
19 #include "chrome/browser/autocomplete/in_memory_url_index_types.h" 19 #include "chrome/browser/autocomplete/in_memory_url_index_types.h"
20 #include "chrome/browser/autocomplete/scored_history_match_builder_impl.h" 20 #include "chrome/browser/autocomplete/scored_history_match.h"
21 #include "chrome/browser/history/history_service_factory.h" 21 #include "chrome/browser/history/history_service_factory.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/search_engines/template_url_service_factory.h" 23 #include "chrome/browser/search_engines/template_url_service_factory.h"
24 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" 24 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
28 #include "components/bookmarks/browser/bookmark_utils.h" 28 #include "components/bookmarks/browser/bookmark_utils.h"
29 #include "components/history/core/browser/history_backend.h" 29 #include "components/history/core/browser/history_backend.h"
30 #include "components/history/core/browser/history_database.h" 30 #include "components/history/core/browser/history_database.h"
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 base::string16 clean_description = 708 base::string16 clean_description =
709 bookmarks::CleanUpTitleForMatching(description); 709 bookmarks::CleanUpTitleForMatching(description);
710 TermMatches description_matches(SortAndDeoverlapMatches( 710 TermMatches description_matches(SortAndDeoverlapMatches(
711 MatchTermInString(input_text, clean_description, 0))); 711 MatchTermInString(input_text, clean_description, 0)));
712 WordStarts description_word_starts; 712 WordStarts description_word_starts;
713 String16VectorFromString16(clean_description, false, 713 String16VectorFromString16(clean_description, false,
714 &description_word_starts); 714 &description_word_starts);
715 // If HistoryURL retrieves any matches (and hence we reach this code), we 715 // If HistoryURL retrieves any matches (and hence we reach this code), we
716 // are guaranteed that the beginning of input_text must be a word break. 716 // are guaranteed that the beginning of input_text must be a word break.
717 WordStarts offsets(1, 0u); 717 WordStarts offsets(1, 0u);
718 description_matches = 718 description_matches = ScoredHistoryMatch::FilterTermMatchesByWordStarts(
719 ScoredHistoryMatchBuilderImpl::FilterTermMatchesByWordStarts( 719 description_matches, offsets, description_word_starts, 0,
720 description_matches, offsets, description_word_starts, 0, 720 std::string::npos);
721 std::string::npos);
722 return SpansFromTermMatch( 721 return SpansFromTermMatch(
723 description_matches, clean_description.length(), false); 722 description_matches, clean_description.length(), false);
724 } 723 }
725 724
726 void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend, 725 void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend,
727 history::URLDatabase* db, 726 history::URLDatabase* db,
728 HistoryURLProviderParams* params) { 727 HistoryURLProviderParams* params) {
729 // Get the matching URLs from the DB. 728 // Get the matching URLs from the DB.
730 params->matches.clear(); 729 params->matches.clear();
731 history::URLRows url_matches; 730 history::URLRows url_matches;
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, 1153 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0,
1155 match.contents.length(), ACMatchClassification::URL, 1154 match.contents.length(), ACMatchClassification::URL,
1156 &match.contents_class); 1155 &match.contents_class);
1157 } 1156 }
1158 match.description = info.title(); 1157 match.description = info.title();
1159 match.description_class = 1158 match.description_class =
1160 ClassifyDescription(params.input.text(), match.description); 1159 ClassifyDescription(params.input.text(), match.description);
1161 RecordAdditionalInfoFromUrlRow(info, &match); 1160 RecordAdditionalInfoFromUrlRow(info, &match);
1162 return match; 1161 return match;
1163 } 1162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698