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 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/history/top_sites.h" | 25 #include "chrome/browser/history/top_sites.h" |
26 #include "chrome/browser/metrics/variations/variations_http_header_provider.h" | 26 #include "chrome/browser/metrics/variations/variations_http_header_provider.h" |
27 #include "chrome/browser/omnibox/omnibox_field_trial.h" | 27 #include "chrome/browser/omnibox/omnibox_field_trial.h" |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/search/search.h" | 29 #include "chrome/browser/search/search.h" |
30 #include "chrome/browser/search_engines/template_url_service.h" | 30 #include "chrome/browser/search_engines/template_url_service.h" |
31 #include "chrome/browser/search_engines/template_url_service_factory.h" | 31 #include "chrome/browser/search_engines/template_url_service_factory.h" |
32 #include "chrome/common/net/url_fixer_upper.h" | 32 #include "chrome/common/net/url_fixer_upper.h" |
33 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
34 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
| 35 #include "components/metrics/proto/omnibox_input_type.pb.h" |
35 #include "components/pref_registry/pref_registry_syncable.h" | 36 #include "components/pref_registry/pref_registry_syncable.h" |
36 #include "content/public/browser/user_metrics.h" | 37 #include "content/public/browser/user_metrics.h" |
37 #include "net/base/escape.h" | 38 #include "net/base/escape.h" |
38 #include "net/base/load_flags.h" | 39 #include "net/base/load_flags.h" |
39 #include "net/base/net_util.h" | 40 #include "net/base/net_util.h" |
40 #include "net/http/http_request_headers.h" | 41 #include "net/http/http_request_headers.h" |
41 #include "net/url_request/url_fetcher.h" | 42 #include "net/url_request/url_fetcher.h" |
42 #include "net/url_request/url_request_status.h" | 43 #include "net/url_request/url_request_status.h" |
43 #include "url/gurl.h" | 44 #include "url/gurl.h" |
44 | 45 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 user_prefs::PrefRegistrySyncable* registry) { | 87 user_prefs::PrefRegistrySyncable* registry) { |
87 registry->RegisterStringPref( | 88 registry->RegisterStringPref( |
88 prefs::kZeroSuggestCachedResults, | 89 prefs::kZeroSuggestCachedResults, |
89 std::string(), | 90 std::string(), |
90 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 91 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
91 } | 92 } |
92 | 93 |
93 void ZeroSuggestProvider::Start(const AutocompleteInput& input, | 94 void ZeroSuggestProvider::Start(const AutocompleteInput& input, |
94 bool minimal_changes) { | 95 bool minimal_changes) { |
95 matches_.clear(); | 96 matches_.clear(); |
96 if (input.type() == AutocompleteInput::INVALID) | 97 if (input.type() == metrics::OmniboxInputType::INVALID) |
97 return; | 98 return; |
98 | 99 |
99 Stop(true); | 100 Stop(true); |
100 field_trial_triggered_ = false; | 101 field_trial_triggered_ = false; |
101 field_trial_triggered_in_session_ = false; | 102 field_trial_triggered_in_session_ = false; |
102 results_from_cache_ = false; | 103 results_from_cache_ = false; |
103 permanent_text_ = input.text(); | 104 permanent_text_ = input.text(); |
104 current_query_ = input.current_url().spec(); | 105 current_query_ = input.current_url().spec(); |
105 current_page_classification_ = input.current_page_classification(); | 106 current_page_classification_ = input.current_page_classification(); |
106 current_url_match_ = MatchForCurrentURL(); | 107 current_url_match_ = MatchForCurrentURL(); |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 std::string json_data = profile_->GetPrefs()->GetString( | 453 std::string json_data = profile_->GetPrefs()->GetString( |
453 prefs::kZeroSuggestCachedResults); | 454 prefs::kZeroSuggestCachedResults); |
454 if (!json_data.empty()) { | 455 if (!json_data.empty()) { |
455 scoped_ptr<base::Value> data(DeserializeJsonData(json_data)); | 456 scoped_ptr<base::Value> data(DeserializeJsonData(json_data)); |
456 if (data && ParseSuggestResults(*data.get(), false, &results_)) { | 457 if (data && ParseSuggestResults(*data.get(), false, &results_)) { |
457 ConvertResultsToAutocompleteMatches(); | 458 ConvertResultsToAutocompleteMatches(); |
458 results_from_cache_ = !matches_.empty(); | 459 results_from_cache_ = !matches_.empty(); |
459 } | 460 } |
460 } | 461 } |
461 } | 462 } |
OLD | NEW |