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 "chrome/browser/autocomplete/zero_suggest_provider.h" | 5 #include "chrome/browser/autocomplete/zero_suggest_provider.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/i18n/case_conversion.h" | 8 #include "base/i18n/case_conversion.h" |
9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 // Do not blindly trust the URL coming from the server to be valid. | 259 // Do not blindly trust the URL coming from the server to be valid. |
260 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(result), std::string())); | 260 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(result), std::string())); |
261 if (url.is_valid()) { | 261 if (url.is_valid()) { |
262 if (descriptions != NULL) | 262 if (descriptions != NULL) |
263 descriptions->GetString(index, &title); | 263 descriptions->GetString(index, &title); |
264 navigation_results->push_back(SearchProvider::NavigationResult( | 264 navigation_results->push_back(SearchProvider::NavigationResult( |
265 *this, url, title, false, relevance, relevances != NULL)); | 265 *this, url, title, false, relevance, relevances != NULL)); |
266 } | 266 } |
267 } else { | 267 } else { |
268 suggest_results->push_back(SearchProvider::SuggestResult( | 268 suggest_results->push_back(SearchProvider::SuggestResult( |
269 result, result, base::string16(), std::string(), std::string(), false, | 269 result, AutocompleteMatchType::SEARCH_SUGGEST, result, |
270 relevance, relevances != NULL, false)); | 270 base::string16(), std::string(), std::string(), false, relevance, |
| 271 relevances != NULL, false)); |
271 } | 272 } |
272 } | 273 } |
273 } | 274 } |
274 | 275 |
275 void ZeroSuggestProvider::AddSuggestResultsToMap( | 276 void ZeroSuggestProvider::AddSuggestResultsToMap( |
276 const SearchProvider::SuggestResults& results, | 277 const SearchProvider::SuggestResults& results, |
277 const TemplateURL* template_url, | 278 const TemplateURL* template_url, |
278 SearchProvider::MatchMap* map) { | 279 SearchProvider::MatchMap* map) { |
279 for (size_t i = 0; i < results.size(); ++i) { | 280 for (size_t i = 0; i < results.size(); ++i) { |
280 AddMatchToMap(results[i].relevance(), AutocompleteMatchType::SEARCH_SUGGEST, | 281 AddMatchToMap(results[i].relevance(), AutocompleteMatchType::SEARCH_SUGGEST, |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 match.is_history_what_you_typed_match = false; | 454 match.is_history_what_you_typed_match = false; |
454 match.allowed_to_be_default_match = true; | 455 match.allowed_to_be_default_match = true; |
455 | 456 |
456 // The placeholder suggestion for the current URL has high relevance so | 457 // The placeholder suggestion for the current URL has high relevance so |
457 // that it is in the first suggestion slot and inline autocompleted. It | 458 // that it is in the first suggestion slot and inline autocompleted. It |
458 // gets dropped as soon as the user types something. | 459 // gets dropped as soon as the user types something. |
459 match.relevance = verbatim_relevance_; | 460 match.relevance = verbatim_relevance_; |
460 | 461 |
461 return match; | 462 return match; |
462 } | 463 } |
OLD | NEW |