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

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

Issue 184663002: Omnibox: Make URLs of Bookmarks Searchable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Peter's comments Created 6 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
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/autocomplete_match.h" 18 #include "chrome/browser/autocomplete/autocomplete_match.h"
19 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" 19 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h"
20 #include "chrome/browser/autocomplete/autocomplete_result.h" 20 #include "chrome/browser/autocomplete/autocomplete_result.h"
21 #include "chrome/browser/bookmarks/bookmark_utils.h"
21 #include "chrome/browser/history/history_backend.h" 22 #include "chrome/browser/history/history_backend.h"
22 #include "chrome/browser/history/history_database.h" 23 #include "chrome/browser/history/history_database.h"
23 #include "chrome/browser/history/history_service.h" 24 #include "chrome/browser/history/history_service.h"
24 #include "chrome/browser/history/history_service_factory.h" 25 #include "chrome/browser/history/history_service_factory.h"
25 #include "chrome/browser/history/history_types.h" 26 #include "chrome/browser/history/history_types.h"
26 #include "chrome/browser/history/in_memory_url_index_types.h" 27 #include "chrome/browser/history/in_memory_url_index_types.h"
27 #include "chrome/browser/history/scored_history_match.h" 28 #include "chrome/browser/history/scored_history_match.h"
28 #include "chrome/browser/omnibox/omnibox_field_trial.h" 29 #include "chrome/browser/omnibox/omnibox_field_trial.h"
29 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
30 #include "chrome/browser/search_engines/template_url_service.h" 31 #include "chrome/browser/search_engines/template_url_service.h"
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 } 1144 }
1144 1145
1145 DCHECK_LE(relevance, old_relevance); 1146 DCHECK_LE(relevance, old_relevance);
1146 return relevance; 1147 return relevance;
1147 } 1148 }
1148 1149
1149 // static 1150 // static
1150 ACMatchClassifications HistoryURLProvider::ClassifyDescription( 1151 ACMatchClassifications HistoryURLProvider::ClassifyDescription(
1151 const base::string16& input_text, 1152 const base::string16& input_text,
1152 const base::string16& description) { 1153 const base::string16& description) {
1153 base::string16 clean_description = history::CleanUpTitleForMatching( 1154 base::string16 clean_description = bookmark_utils::CleanUpTitleForMatching(
1154 description); 1155 description);
1155 history::TermMatches description_matches(SortAndDeoverlapMatches( 1156 history::TermMatches description_matches(SortAndDeoverlapMatches(
1156 history::MatchTermInString(input_text, clean_description, 0))); 1157 history::MatchTermInString(input_text, clean_description, 0)));
1157 history::WordStarts description_word_starts; 1158 history::WordStarts description_word_starts;
1158 history::String16VectorFromString16( 1159 history::String16VectorFromString16(
1159 clean_description, false, &description_word_starts); 1160 clean_description, false, &description_word_starts);
1160 // If HistoryURL retrieves any matches (and hence we reach this code), we 1161 // If HistoryURL retrieves any matches (and hence we reach this code), we
1161 // are guaranteed that the beginning of input_text must be a word break. 1162 // are guaranteed that the beginning of input_text must be a word break.
1162 history::WordStarts offsets(1, 0u); 1163 history::WordStarts offsets(1, 0u);
1163 description_matches = 1164 description_matches =
1164 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts( 1165 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts(
1165 description_matches, offsets, description_word_starts, 0, 1166 description_matches, offsets, description_word_starts, 0,
1166 std::string::npos); 1167 std::string::npos);
1167 return SpansFromTermMatch( 1168 return SpansFromTermMatch(
1168 description_matches, clean_description.length(), false); 1169 description_matches, clean_description.length(), false);
1169 } 1170 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698