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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 ZeroSuggestProvider* ZeroSuggestProvider::Create( | 78 ZeroSuggestProvider* ZeroSuggestProvider::Create( |
79 AutocompleteProviderListener* listener, | 79 AutocompleteProviderListener* listener, |
80 TemplateURLService* template_url_service, | 80 TemplateURLService* template_url_service, |
81 Profile* profile) { | 81 Profile* profile) { |
82 return new ZeroSuggestProvider(listener, template_url_service, profile); | 82 return new ZeroSuggestProvider(listener, template_url_service, profile); |
83 } | 83 } |
84 | 84 |
85 // static | 85 // static |
86 void ZeroSuggestProvider::RegisterProfilePrefs( | 86 void ZeroSuggestProvider::RegisterProfilePrefs( |
87 user_prefs::PrefRegistrySyncable* registry) { | 87 user_prefs::PrefRegistrySyncable* registry) { |
88 registry->RegisterStringPref( | 88 registry->RegisterStringPref(prefs::kZeroSuggestCachedResults, std::string()); |
89 prefs::kZeroSuggestCachedResults, | |
90 std::string(), | |
91 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
92 } | 89 } |
93 | 90 |
94 void ZeroSuggestProvider::Start(const AutocompleteInput& input, | 91 void ZeroSuggestProvider::Start(const AutocompleteInput& input, |
95 bool minimal_changes, | 92 bool minimal_changes, |
96 bool called_due_to_focus) { | 93 bool called_due_to_focus) { |
97 matches_.clear(); | 94 matches_.clear(); |
98 if (!called_due_to_focus || | 95 if (!called_due_to_focus || |
99 input.type() == metrics::OmniboxInputType::INVALID) | 96 input.type() == metrics::OmniboxInputType::INVALID) |
100 return; | 97 return; |
101 | 98 |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 if (!json_data.empty()) { | 483 if (!json_data.empty()) { |
487 scoped_ptr<base::Value> data( | 484 scoped_ptr<base::Value> data( |
488 SearchSuggestionParser::DeserializeJsonData(json_data)); | 485 SearchSuggestionParser::DeserializeJsonData(json_data)); |
489 if (data && ParseSuggestResults( | 486 if (data && ParseSuggestResults( |
490 *data, kDefaultZeroSuggestRelevance, false, &results_)) { | 487 *data, kDefaultZeroSuggestRelevance, false, &results_)) { |
491 ConvertResultsToAutocompleteMatches(); | 488 ConvertResultsToAutocompleteMatches(); |
492 results_from_cache_ = !matches_.empty(); | 489 results_from_cache_ = !matches_.empty(); |
493 } | 490 } |
494 } | 491 } |
495 } | 492 } |
OLD | NEW |