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 "components/omnibox/browser/url_index_private_data.h" | 5 #include "components/omnibox/browser/url_index_private_data.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <functional> | 9 #include <functional> |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 size_t cursor_position, | 146 size_t cursor_position, |
147 size_t max_matches, | 147 size_t max_matches, |
148 bookmarks::BookmarkModel* bookmark_model, | 148 bookmarks::BookmarkModel* bookmark_model, |
149 TemplateURLService* template_url_service) { | 149 TemplateURLService* template_url_service) { |
150 // This list will contain the original search string and any other string | 150 // This list will contain the original search string and any other string |
151 // transformations. | 151 // transformations. |
152 String16Vector search_strings; | 152 String16Vector search_strings; |
153 search_strings.push_back(original_search_string); | 153 search_strings.push_back(original_search_string); |
154 if ((cursor_position != base::string16::npos) && | 154 if ((cursor_position != base::string16::npos) && |
155 (cursor_position < original_search_string.length()) && | 155 (cursor_position < original_search_string.length()) && |
156 (cursor_position > 0)) { | 156 (cursor_position > 0) && |
157 (original_search_string[cursor_position - 1] != L' ') && | |
158 (original_search_string[cursor_position] != L' ')) { | |
Peter Kasting
2017/04/26 01:43:02
What about other kinds of whitespace/word breaks?
Mark P
2017/04/26 22:24:44
It uses ICU via the call to String16VectorFromStri
| |
157 // The original search_string broken at cursor position. This is one type of | 159 // The original search_string broken at cursor position. This is one type of |
158 // transformation. | 160 // transformation. There is no need to break the cursor position at a space |
161 // if there is already a space adjacent to the cursor. | |
159 base::string16 transformed_search_string(original_search_string); | 162 base::string16 transformed_search_string(original_search_string); |
160 transformed_search_string.insert(cursor_position, base::ASCIIToUTF16(" ")); | 163 transformed_search_string.insert(cursor_position, base::ASCIIToUTF16(" ")); |
161 search_strings.push_back(transformed_search_string); | 164 search_strings.push_back(transformed_search_string); |
162 } | 165 } |
163 | 166 |
164 ScoredHistoryMatches scored_items; | 167 ScoredHistoryMatches scored_items; |
165 // Invalidate the term cache and return if we have indexed no words (probably | 168 // Invalidate the term cache and return if we have indexed no words (probably |
166 // because we've not been initialized yet). | 169 // because we've not been initialized yet). |
167 if (word_list_.empty()) { | 170 if (word_list_.empty()) { |
168 search_term_cache_.clear(); | 171 search_term_cache_.clear(); |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1266 // First cut: typed count, visit count, recency. | 1269 // First cut: typed count, visit count, recency. |
1267 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks | 1270 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks |
1268 // recently visited (within the last 12/24 hours) as highly important. Get | 1271 // recently visited (within the last 12/24 hours) as highly important. Get |
1269 // input from mpearson. | 1272 // input from mpearson. |
1270 if (r1.typed_count() != r2.typed_count()) | 1273 if (r1.typed_count() != r2.typed_count()) |
1271 return (r1.typed_count() > r2.typed_count()); | 1274 return (r1.typed_count() > r2.typed_count()); |
1272 if (r1.visit_count() != r2.visit_count()) | 1275 if (r1.visit_count() != r2.visit_count()) |
1273 return (r1.visit_count() > r2.visit_count()); | 1276 return (r1.visit_count() > r2.visit_count()); |
1274 return (r1.last_visit() > r2.last_visit()); | 1277 return (r1.last_visit() > r2.last_visit()); |
1275 } | 1278 } |
OLD | NEW |