| 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 return true; | 449 return true; |
| 450 } | 450 } |
| 451 | 451 |
| 452 void ZeroSuggestProvider::MaybeUseCachedSuggestions() { | 452 void ZeroSuggestProvider::MaybeUseCachedSuggestions() { |
| 453 if (!OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial()) | 453 if (!OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial()) |
| 454 return; | 454 return; |
| 455 | 455 |
| 456 std::string json_data = profile_->GetPrefs()->GetString( | 456 std::string json_data = profile_->GetPrefs()->GetString( |
| 457 prefs::kZeroSuggestCachedResults); | 457 prefs::kZeroSuggestCachedResults); |
| 458 if (!json_data.empty()) { | 458 if (!json_data.empty()) { |
| 459 scoped_ptr<base::Value> data(DeserializeJsonData(json_data)); | 459 scoped_ptr<base::Value> data( |
| 460 SearchSuggestionParser::DeserializeJsonData(json_data)); |
| 460 if (data && ParseSuggestResults(*data.get(), false, &results_)) { | 461 if (data && ParseSuggestResults(*data.get(), false, &results_)) { |
| 461 ConvertResultsToAutocompleteMatches(); | 462 ConvertResultsToAutocompleteMatches(); |
| 462 results_from_cache_ = !matches_.empty(); | 463 results_from_cache_ = !matches_.empty(); |
| 463 } | 464 } |
| 464 } | 465 } |
| 465 } | 466 } |
| OLD | NEW |