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

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: fix ALL_MATCHES (in response to recent changes) 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 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 } 1143 }
1143 1144
1144 DCHECK_LE(relevance, old_relevance); 1145 DCHECK_LE(relevance, old_relevance);
1145 return relevance; 1146 return relevance;
1146 } 1147 }
1147 1148
1148 // static 1149 // static
1149 ACMatchClassifications HistoryURLProvider::ClassifyDescription( 1150 ACMatchClassifications HistoryURLProvider::ClassifyDescription(
1150 const base::string16& input_text, 1151 const base::string16& input_text,
1151 const base::string16& description) { 1152 const base::string16& description) {
1152 base::string16 clean_description = history::CleanUpTitleForMatching( 1153 base::string16 clean_description = bookmark_utils::CleanUpTitleForMatching(
1153 description); 1154 description);
1154 history::TermMatches description_matches(SortAndDeoverlapMatches( 1155 history::TermMatches description_matches(SortAndDeoverlapMatches(
1155 history::MatchTermInString(input_text, clean_description, 0))); 1156 history::MatchTermInString(input_text, clean_description, 0)));
1156 history::WordStarts description_word_starts; 1157 history::WordStarts description_word_starts;
1157 history::String16VectorFromString16( 1158 history::String16VectorFromString16(
1158 clean_description, false, &description_word_starts); 1159 clean_description, false, &description_word_starts);
1159 // If HistoryURL retrieves any matches (and hence we reach this code), we 1160 // If HistoryURL retrieves any matches (and hence we reach this code), we
1160 // are guaranteed that the beginning of input_text must be a word break. 1161 // are guaranteed that the beginning of input_text must be a word break.
1161 history::WordStarts offsets(1, 0u); 1162 history::WordStarts offsets(1, 0u);
1162 description_matches = 1163 description_matches =
1163 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts( 1164 history::ScoredHistoryMatch::FilterTermMatchesByWordStarts(
1164 description_matches, offsets, description_word_starts, 0, 1165 description_matches, offsets, description_word_starts, 0,
1165 std::string::npos); 1166 std::string::npos);
1166 return SpansFromTermMatch( 1167 return SpansFromTermMatch(
1167 description_matches, clean_description.length(), false); 1168 description_matches, clean_description.length(), false);
1168 } 1169 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/bookmark_provider_unittest.cc ('k') | chrome/browser/autocomplete/shortcuts_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698