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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 268 |
269 void ZeroSuggestProvider::UpdateMatches() { | 269 void ZeroSuggestProvider::UpdateMatches() { |
270 done_ = true; | 270 done_ = true; |
271 ConvertResultsToAutocompleteMatches(); | 271 ConvertResultsToAutocompleteMatches(); |
272 } | 272 } |
273 | 273 |
274 void ZeroSuggestProvider::AddSuggestResultsToMap( | 274 void ZeroSuggestProvider::AddSuggestResultsToMap( |
275 const SearchSuggestionParser::SuggestResults& results, | 275 const SearchSuggestionParser::SuggestResults& results, |
276 MatchMap* map) { | 276 MatchMap* map) { |
277 for (size_t i = 0; i < results.size(); ++i) | 277 for (size_t i = 0; i < results.size(); ++i) |
278 AddMatchToMap(results[i], std::string(), i, false, map); | 278 AddMatchToMap(results[i], std::string(), i, false, false, map); |
279 } | 279 } |
280 | 280 |
281 AutocompleteMatch ZeroSuggestProvider::NavigationToMatch( | 281 AutocompleteMatch ZeroSuggestProvider::NavigationToMatch( |
282 const SearchSuggestionParser::NavigationResult& navigation) { | 282 const SearchSuggestionParser::NavigationResult& navigation) { |
283 AutocompleteMatch match(this, navigation.relevance(), false, | 283 AutocompleteMatch match(this, navigation.relevance(), false, |
284 navigation.type()); | 284 navigation.type()); |
285 match.destination_url = navigation.url(); | 285 match.destination_url = navigation.url(); |
286 | 286 |
287 // Zero suggest results should always omit protocols and never appear bold. | 287 // Zero suggest results should always omit protocols and never appear bold. |
288 const std::string languages( | 288 const std::string languages( |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 prefs::kZeroSuggestCachedResults); | 457 prefs::kZeroSuggestCachedResults); |
458 if (!json_data.empty()) { | 458 if (!json_data.empty()) { |
459 scoped_ptr<base::Value> data( | 459 scoped_ptr<base::Value> data( |
460 SearchSuggestionParser::DeserializeJsonData(json_data)); | 460 SearchSuggestionParser::DeserializeJsonData(json_data)); |
461 if (data && ParseSuggestResults(*data.get(), false, &results_)) { | 461 if (data && ParseSuggestResults(*data.get(), false, &results_)) { |
462 ConvertResultsToAutocompleteMatches(); | 462 ConvertResultsToAutocompleteMatches(); |
463 results_from_cache_ = !matches_.empty(); | 463 results_from_cache_ = !matches_.empty(); |
464 } | 464 } |
465 } | 465 } |
466 } | 466 } |
OLD | NEW |