OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 // See comments on an identical NOTREACHED() in search_provider.cc. | 227 // See comments on an identical NOTREACHED() in search_provider.cc. |
228 NOTREACHED(); | 228 NOTREACHED(); |
229 } | 229 } |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 // static | 233 // static |
234 int KeywordProvider::CalculateRelevance(AutocompleteInput::Type type, | 234 int KeywordProvider::CalculateRelevance(AutocompleteInput::Type type, |
235 bool complete, | 235 bool complete, |
236 bool no_query_text_needed) { | 236 bool no_query_text_needed) { |
237 if (complete && no_query_text_needed) | 237 if (!complete) |
| 238 return (type == AutocompleteInput::URL) ? 700 : 450; |
| 239 if (no_query_text_needed) |
238 return 1500; | 240 return 1500; |
239 | 241 return (type == AutocompleteInput::QUERY) ? 1450 : 1100; |
240 switch (type) { | |
241 case AutocompleteInput::UNKNOWN: | |
242 case AutocompleteInput::REQUESTED_URL: | |
243 return complete ? 1100 : 450; | |
244 | |
245 case AutocompleteInput::URL: | |
246 return complete ? 1100 : 700; | |
247 | |
248 case AutocompleteInput::QUERY: | |
249 return complete ? 1400 : 650; | |
250 | |
251 default: | |
252 NOTREACHED(); | |
253 return 0; | |
254 } | |
255 } | 242 } |
256 | 243 |
257 AutocompleteMatch KeywordProvider::CreateAutocompleteMatch( | 244 AutocompleteMatch KeywordProvider::CreateAutocompleteMatch( |
258 TemplateURLModel* model, | 245 TemplateURLModel* model, |
259 const std::wstring keyword, | 246 const std::wstring keyword, |
260 const AutocompleteInput& input, | 247 const AutocompleteInput& input, |
261 size_t prefix_length, | 248 size_t prefix_length, |
262 const std::wstring& remaining_input) { | 249 const std::wstring& remaining_input) { |
263 DCHECK(model); | 250 DCHECK(model); |
264 // Get keyword data from data store. | 251 // Get keyword data from data store. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 AutocompleteMatch::ClassifyLocationInString(kKeywordDesc.find(L"%s"), | 287 AutocompleteMatch::ClassifyLocationInString(kKeywordDesc.find(L"%s"), |
301 prefix_length, | 288 prefix_length, |
302 result.description.length(), | 289 result.description.length(), |
303 ACMatchClassification::DIM, | 290 ACMatchClassification::DIM, |
304 &result.description_class); | 291 &result.description_class); |
305 | 292 |
306 result.transition = PageTransition::KEYWORD; | 293 result.transition = PageTransition::KEYWORD; |
307 | 294 |
308 return result; | 295 return result; |
309 } | 296 } |
OLD | NEW |