OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_quick_provider.h" | 5 #include "chrome/browser/autocomplete/history_quick_provider.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/i18n/word_iterator.h" | 8 #include "base/i18n/break_iterator.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/autocomplete/autocomplete_match.h" | 12 #include "chrome/browser/autocomplete/autocomplete_match.h" |
13 #include "chrome/browser/history/history.h" | 13 #include "chrome/browser/history/history.h" |
14 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/history/in_memory_url_index.h" | 16 #include "chrome/browser/history/in_memory_url_index.h" |
17 #include "chrome/browser/net/url_fixer_upper.h" | 17 #include "chrome/browser/net/url_fixer_upper.h" |
18 #include "chrome/browser/plugin_service.h" | 18 #include "chrome/browser/plugin_service.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 history::InMemoryURLIndex* index) { | 160 history::InMemoryURLIndex* index) { |
161 DCHECK(index); | 161 DCHECK(index); |
162 index_for_testing_.reset(index); | 162 index_for_testing_.reset(index); |
163 } | 163 } |
164 | 164 |
165 // Utility Functions | 165 // Utility Functions |
166 | 166 |
167 history::InMemoryURLIndex::String16Vector | 167 history::InMemoryURLIndex::String16Vector |
168 HistoryQuickProvider::WordVectorFromString16(const string16& uni_string) { | 168 HistoryQuickProvider::WordVectorFromString16(const string16& uni_string) { |
169 history::InMemoryURLIndex::String16Vector words; | 169 history::InMemoryURLIndex::String16Vector words; |
170 WordIterator iter(&uni_string, WordIterator::BREAK_WORD); | 170 base::BreakIterator iter(&uni_string, base::BreakIterator::BREAK_WORD); |
171 if (iter.Init()) { | 171 if (iter.Init()) { |
172 while (iter.Advance()) { | 172 while (iter.Advance()) { |
173 if (iter.IsWord()) | 173 if (iter.IsWord()) |
174 words.push_back(iter.GetWord()); | 174 words.push_back(iter.GetString()); |
175 } | 175 } |
176 } | 176 } |
177 return words; | 177 return words; |
178 } | 178 } |
179 | 179 |
180 // static | 180 // static |
181 int HistoryQuickProvider::CalculateRelevance(int raw_score, | 181 int HistoryQuickProvider::CalculateRelevance(int raw_score, |
182 AutocompleteInput::Type input_type, | 182 AutocompleteInput::Type input_type, |
183 MatchType match_type, | 183 MatchType match_type, |
184 size_t match_number) { | 184 size_t match_number) { |
185 switch (match_type) { | 185 switch (match_type) { |
186 case INLINE_AUTOCOMPLETE: | 186 case INLINE_AUTOCOMPLETE: |
187 return 1400; | 187 return 1400; |
188 | 188 |
189 case WHAT_YOU_TYPED: | 189 case WHAT_YOU_TYPED: |
190 return 1200; | 190 return 1200; |
191 | 191 |
192 default: | 192 default: |
193 return 900 + static_cast<int>(match_number); | 193 return 900 + static_cast<int>(match_number); |
194 } | 194 } |
195 } | 195 } |
OLD | NEW |