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

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

Issue 456843003: Remove protected virtual methods from BaseSearchProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/search_provider.h" 5 #include "chrome/browser/autocomplete/search_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 243 }
244 244
245 input_ = input; 245 input_ = input;
246 246
247 DoHistoryQuery(minimal_changes); 247 DoHistoryQuery(minimal_changes);
248 DoAnswersQuery(input); 248 DoAnswersQuery(input);
249 StartOrStopSuggestQuery(minimal_changes); 249 StartOrStopSuggestQuery(minimal_changes);
250 UpdateMatches(); 250 UpdateMatches();
251 } 251 }
252 252
253 void SearchProvider::Stop(bool clear_cached_results) {
254 StopSuggest();
255 done_ = true;
256
257 if (clear_cached_results)
258 ClearAllResults();
259 }
260
253 const TemplateURL* SearchProvider::GetTemplateURL(bool is_keyword) const { 261 const TemplateURL* SearchProvider::GetTemplateURL(bool is_keyword) const {
254 return is_keyword ? providers_.GetKeywordProviderURL() 262 return is_keyword ? providers_.GetKeywordProviderURL()
255 : providers_.GetDefaultProviderURL(); 263 : providers_.GetDefaultProviderURL();
256 } 264 }
257 265
258 const AutocompleteInput SearchProvider::GetInput(bool is_keyword) const { 266 const AutocompleteInput SearchProvider::GetInput(bool is_keyword) const {
259 return is_keyword ? keyword_input_ : input_; 267 return is_keyword ? keyword_input_ : input_;
260 } 268 }
261 269
262 bool SearchProvider::ShouldAppendExtraParams( 270 bool SearchProvider::ShouldAppendExtraParams(
263 const SearchSuggestionParser::SuggestResult& result) const { 271 const SearchSuggestionParser::SuggestResult& result) const {
264 return !result.from_keyword_provider() || 272 return !result.from_keyword_provider() ||
265 providers_.default_provider().empty(); 273 providers_.default_provider().empty();
266 } 274 }
267 275
268 void SearchProvider::StopSuggest() {
269 // Increment the appropriate field in the histogram by the number of
270 // pending requests that were invalidated.
271 for (int i = 0; i < suggest_results_pending_; ++i)
272 LogOmniboxSuggestRequest(REQUEST_INVALIDATED);
273 suggest_results_pending_ = 0;
274 timer_.Stop();
275 // Stop any in-progress URL fetches.
276 keyword_fetcher_.reset();
277 default_fetcher_.reset();
278 }
279
280 void SearchProvider::ClearAllResults() {
281 keyword_results_.Clear();
282 default_results_.Clear();
283 }
284
285 void SearchProvider::RecordDeletionResult(bool success) { 276 void SearchProvider::RecordDeletionResult(bool success) {
286 if (success) { 277 if (success) {
287 base::RecordAction( 278 base::RecordAction(
288 base::UserMetricsAction("Omnibox.ServerSuggestDelete.Success")); 279 base::UserMetricsAction("Omnibox.ServerSuggestDelete.Success"));
289 } else { 280 } else {
290 base::RecordAction( 281 base::RecordAction(
291 base::UserMetricsAction("Omnibox.ServerSuggestDelete.Failure")); 282 base::UserMetricsAction("Omnibox.ServerSuggestDelete.Failure"));
292 } 283 }
293 } 284 }
294 285
(...skipping 22 matching lines...) Expand all
317 results_updated = ParseSuggestResults(*data, -1, is_keyword, results); 308 results_updated = ParseSuggestResults(*data, -1, is_keyword, results);
318 if (results_updated) 309 if (results_updated)
319 SortResults(is_keyword, results); 310 SortResults(is_keyword, results);
320 } 311 }
321 } 312 }
322 UpdateMatches(); 313 UpdateMatches();
323 if (done_ || results_updated) 314 if (done_ || results_updated)
324 listener_->OnProviderUpdate(results_updated); 315 listener_->OnProviderUpdate(results_updated);
325 } 316 }
326 317
318 void SearchProvider::StopSuggest() {
319 // Increment the appropriate field in the histogram by the number of
320 // pending requests that were invalidated.
321 for (int i = 0; i < suggest_results_pending_; ++i)
322 LogOmniboxSuggestRequest(REQUEST_INVALIDATED);
323 suggest_results_pending_ = 0;
324 timer_.Stop();
325 // Stop any in-progress URL fetches.
326 keyword_fetcher_.reset();
327 default_fetcher_.reset();
328 }
329
330 void SearchProvider::ClearAllResults() {
331 keyword_results_.Clear();
332 default_results_.Clear();
333 }
334
327 void SearchProvider::UpdateMatchContentsClass( 335 void SearchProvider::UpdateMatchContentsClass(
328 const base::string16& input_text, 336 const base::string16& input_text,
329 SearchSuggestionParser::Results* results) { 337 SearchSuggestionParser::Results* results) {
330 for (SearchSuggestionParser::SuggestResults::iterator sug_it = 338 for (SearchSuggestionParser::SuggestResults::iterator sug_it =
331 results->suggest_results.begin(); 339 results->suggest_results.begin();
332 sug_it != results->suggest_results.end(); ++sug_it) { 340 sug_it != results->suggest_results.end(); ++sug_it) {
333 sug_it->ClassifyMatchContents(false, input_text); 341 sug_it->ClassifyMatchContents(false, input_text);
334 } 342 }
335 const std::string languages( 343 const std::string languages(
336 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); 344 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 last_answer_seen_.query_type = match->answer_type; 1260 last_answer_seen_.query_type = match->answer_type;
1253 } 1261 }
1254 1262
1255 void SearchProvider::DoAnswersQuery(const AutocompleteInput& input) { 1263 void SearchProvider::DoAnswersQuery(const AutocompleteInput& input) {
1256 // If the query text starts with trimmed input, this is valid prefetch data. 1264 // If the query text starts with trimmed input, this is valid prefetch data.
1257 prefetch_data_ = StartsWith(last_answer_seen_.full_query_text, 1265 prefetch_data_ = StartsWith(last_answer_seen_.full_query_text,
1258 base::CollapseWhitespace(input.text(), false), 1266 base::CollapseWhitespace(input.text(), false),
1259 false) ? 1267 false) ?
1260 last_answer_seen_ : AnswersQueryData(); 1268 last_answer_seen_ : AnswersQueryData();
1261 } 1269 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider.h ('k') | chrome/browser/autocomplete/zero_suggest_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698