Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: chrome/browser/autocomplete/zero_suggest_provider.cc

Issue 985503002: Omnibox - Make Omnibox Extensions Ignore Stop() Calls Due to User Idleness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make unit tests compile Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 92 }
93 93
94 void ZeroSuggestProvider::Start(const AutocompleteInput& input, 94 void ZeroSuggestProvider::Start(const AutocompleteInput& input,
95 bool minimal_changes, 95 bool minimal_changes,
96 bool called_due_to_focus) { 96 bool called_due_to_focus) {
97 matches_.clear(); 97 matches_.clear();
98 if (!called_due_to_focus || 98 if (!called_due_to_focus ||
99 input.type() == metrics::OmniboxInputType::INVALID) 99 input.type() == metrics::OmniboxInputType::INVALID)
100 return; 100 return;
101 101
102 Stop(true); 102 Stop(true, false);
103 field_trial_triggered_ = false; 103 field_trial_triggered_ = false;
104 field_trial_triggered_in_session_ = false; 104 field_trial_triggered_in_session_ = false;
105 results_from_cache_ = false; 105 results_from_cache_ = false;
106 permanent_text_ = input.text(); 106 permanent_text_ = input.text();
107 current_query_ = input.current_url().spec(); 107 current_query_ = input.current_url().spec();
108 current_page_classification_ = input.current_page_classification(); 108 current_page_classification_ = input.current_page_classification();
109 current_url_match_ = MatchForCurrentURL(); 109 current_url_match_ = MatchForCurrentURL();
110 110
111 const TemplateURL* default_provider = 111 const TemplateURL* default_provider =
112 template_url_service_->GetDefaultSearchProvider(); 112 template_url_service_->GetDefaultSearchProvider();
(...skipping 26 matching lines...) Expand all
139 } 139 }
140 140
141 done_ = false; 141 done_ = false;
142 // TODO(jered): Consider adding locally-sourced zero-suggestions here too. 142 // TODO(jered): Consider adding locally-sourced zero-suggestions here too.
143 // These may be useful on the NTP or more relevant to the user than server 143 // These may be useful on the NTP or more relevant to the user than server
144 // suggestions, if based on local browsing history. 144 // suggestions, if based on local browsing history.
145 MaybeUseCachedSuggestions(); 145 MaybeUseCachedSuggestions();
146 Run(suggest_url); 146 Run(suggest_url);
147 } 147 }
148 148
149 void ZeroSuggestProvider::Stop(bool clear_cached_results) { 149 void ZeroSuggestProvider::Stop(bool clear_cached_results,
150 bool due_to_user_inactivity) {
150 if (fetcher_) 151 if (fetcher_)
151 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_INVALIDATED); 152 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_INVALIDATED);
152 fetcher_.reset(); 153 fetcher_.reset();
153 waiting_for_most_visited_urls_request_ = false; 154 waiting_for_most_visited_urls_request_ = false;
154 done_ = true; 155 done_ = true;
155 156
156 if (clear_cached_results) { 157 if (clear_cached_results) {
157 // We do not call Clear() on |results_| to retain |verbatim_relevance| 158 // We do not call Clear() on |results_| to retain |verbatim_relevance|
158 // value in the |results_| object. |verbatim_relevance| is used at the 159 // value in the |results_| object. |verbatim_relevance| is used at the
159 // beginning of the next OnOmniboxFocused() call to determine the current 160 // beginning of the next OnOmniboxFocused() call to determine the current
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 if (!json_data.empty()) { 483 if (!json_data.empty()) {
483 scoped_ptr<base::Value> data( 484 scoped_ptr<base::Value> data(
484 SearchSuggestionParser::DeserializeJsonData(json_data)); 485 SearchSuggestionParser::DeserializeJsonData(json_data));
485 if (data && ParseSuggestResults( 486 if (data && ParseSuggestResults(
486 *data, kDefaultZeroSuggestRelevance, false, &results_)) { 487 *data, kDefaultZeroSuggestRelevance, false, &results_)) {
487 ConvertResultsToAutocompleteMatches(); 488 ConvertResultsToAutocompleteMatches();
488 results_from_cache_ = !matches_.empty(); 489 results_from_cache_ = !matches_.empty();
489 } 490 }
490 } 491 }
491 } 492 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/zero_suggest_provider.h ('k') | chrome/browser/autocomplete/zero_suggest_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698