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