OLD | NEW |
1 // Copyright (c) 2009 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/keyword_provider.h" | 5 #include "chrome/browser/autocomplete/keyword_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 // Limit to one exact or three inexact matches, and mark them up for display | 127 // Limit to one exact or three inexact matches, and mark them up for display |
128 // in the autocomplete popup. | 128 // in the autocomplete popup. |
129 // Any exact match is going to be the highest quality match, and thus at the | 129 // Any exact match is going to be the highest quality match, and thus at the |
130 // front of our vector. | 130 // front of our vector. |
131 if (keyword_matches.front() == keyword) { | 131 if (keyword_matches.front() == keyword) { |
132 matches_.push_back(CreateAutocompleteMatch(model, keyword, input, | 132 matches_.push_back(CreateAutocompleteMatch(model, keyword, input, |
133 keyword.length(), | 133 keyword.length(), |
134 remaining_input)); | 134 remaining_input)); |
135 } else { | 135 } else { |
136 if (keyword_matches.size() > max_matches()) { | 136 if (keyword_matches.size() > kMaxMatches) { |
137 keyword_matches.erase(keyword_matches.begin() + max_matches(), | 137 keyword_matches.erase(keyword_matches.begin() + kMaxMatches, |
138 keyword_matches.end()); | 138 keyword_matches.end()); |
139 } | 139 } |
140 for (std::vector<std::wstring>::const_iterator i(keyword_matches.begin()); | 140 for (std::vector<std::wstring>::const_iterator i(keyword_matches.begin()); |
141 i != keyword_matches.end(); ++i) { | 141 i != keyword_matches.end(); ++i) { |
142 matches_.push_back(CreateAutocompleteMatch(model, *i, input, | 142 matches_.push_back(CreateAutocompleteMatch(model, *i, input, |
143 keyword.length(), | 143 keyword.length(), |
144 remaining_input)); | 144 remaining_input)); |
145 } | 145 } |
146 } | 146 } |
147 } | 147 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 AutocompleteMatch::ClassifyLocationInString(kKeywordDesc.find(L"%s"), | 287 AutocompleteMatch::ClassifyLocationInString(kKeywordDesc.find(L"%s"), |
288 prefix_length, | 288 prefix_length, |
289 result.description.length(), | 289 result.description.length(), |
290 ACMatchClassification::DIM, | 290 ACMatchClassification::DIM, |
291 &result.description_class); | 291 &result.description_class); |
292 | 292 |
293 result.transition = PageTransition::KEYWORD; | 293 result.transition = PageTransition::KEYWORD; |
294 | 294 |
295 return result; | 295 return result; |
296 } | 296 } |
OLD | NEW |