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

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

Issue 456843003: Remove protected virtual methods from BaseSearchProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert getters 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/base_search_provider.h" 5 #include "chrome/browser/autocomplete/base_search_provider.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/prefs/pref_registry_simple.h" 8 #include "base/prefs/pref_registry_simple.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 const TemplateURL* template_url, 117 const TemplateURL* template_url,
118 const SearchTermsData& search_terms_data) { 118 const SearchTermsData& search_terms_data) {
119 return CreateSearchSuggestion( 119 return CreateSearchSuggestion(
120 NULL, AutocompleteInput(), SearchSuggestionParser::SuggestResult( 120 NULL, AutocompleteInput(), SearchSuggestionParser::SuggestResult(
121 suggestion, type, suggestion, base::string16(), base::string16(), 121 suggestion, type, suggestion, base::string16(), base::string16(),
122 base::string16(), base::string16(), std::string(), std::string(), 122 base::string16(), base::string16(), std::string(), std::string(),
123 from_keyword_provider, 0, false, false, base::string16()), 123 from_keyword_provider, 0, false, false, base::string16()),
124 template_url, search_terms_data, 0, false); 124 template_url, search_terms_data, 0, false);
125 } 125 }
126 126
127 void BaseSearchProvider::Stop(bool clear_cached_results) {
128 StopSuggest();
129 done_ = true;
130
131 if (clear_cached_results)
132 ClearAllResults();
133 }
134
135 void BaseSearchProvider::DeleteMatch(const AutocompleteMatch& match) { 127 void BaseSearchProvider::DeleteMatch(const AutocompleteMatch& match) {
136 DCHECK(match.deletable); 128 DCHECK(match.deletable);
137 if (!match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey).empty()) { 129 if (!match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey).empty()) {
138 deletion_handlers_.push_back(new SuggestionDeletionHandler( 130 deletion_handlers_.push_back(new SuggestionDeletionHandler(
139 match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey), 131 match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey),
140 profile_, 132 profile_,
141 base::Bind(&BaseSearchProvider::OnDeletionComplete, 133 base::Bind(&BaseSearchProvider::OnDeletionComplete,
142 base::Unretained(this)))); 134 base::Unretained(this))));
143 } 135 }
144 136
(...skipping 21 matching lines...) Expand all
166 std::vector<uint32> field_trial_hashes; 158 std::vector<uint32> field_trial_hashes;
167 OmniboxFieldTrial::GetActiveSuggestFieldTrialHashes(&field_trial_hashes); 159 OmniboxFieldTrial::GetActiveSuggestFieldTrialHashes(&field_trial_hashes);
168 for (size_t i = 0; i < field_trial_hashes.size(); ++i) { 160 for (size_t i = 0; i < field_trial_hashes.size(); ++i) {
169 if (field_trial_triggered_) 161 if (field_trial_triggered_)
170 new_entry.mutable_field_trial_triggered()->Add(field_trial_hashes[i]); 162 new_entry.mutable_field_trial_triggered()->Add(field_trial_hashes[i]);
171 if (field_trial_triggered_in_session_) { 163 if (field_trial_triggered_in_session_) {
172 new_entry.mutable_field_trial_triggered_in_session()->Add( 164 new_entry.mutable_field_trial_triggered_in_session()->Add(
173 field_trial_hashes[i]); 165 field_trial_hashes[i]);
174 } 166 }
175 } 167 }
176 ModifyProviderInfo(&new_entry);
177 } 168 }
178 169
179 // static 170 // static
180 const char BaseSearchProvider::kRelevanceFromServerKey[] = 171 const char BaseSearchProvider::kRelevanceFromServerKey[] =
181 "relevance_from_server"; 172 "relevance_from_server";
182 const char BaseSearchProvider::kShouldPrefetchKey[] = "should_prefetch"; 173 const char BaseSearchProvider::kShouldPrefetchKey[] = "should_prefetch";
183 const char BaseSearchProvider::kSuggestMetadataKey[] = "suggest_metadata"; 174 const char BaseSearchProvider::kSuggestMetadataKey[] = "suggest_metadata";
184 const char BaseSearchProvider::kDeletionUrlKey[] = "deletion_url"; 175 const char BaseSearchProvider::kDeletionUrlKey[] = "deletion_url";
185 const char BaseSearchProvider::kTrue[] = "true"; 176 const char BaseSearchProvider::kTrue[] = "true";
186 const char BaseSearchProvider::kFalse[] = "false"; 177 const char BaseSearchProvider::kFalse[] = "false";
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 for (std::vector<GURL>::const_iterator it = 451 for (std::vector<GURL>::const_iterator it =
461 results->answers_image_urls.begin(); 452 results->answers_image_urls.begin();
462 it != results->answers_image_urls.end(); ++it) 453 it != results->answers_image_urls.end(); ++it)
463 image_service->Prefetch(*it); 454 image_service->Prefetch(*it);
464 455
465 field_trial_triggered_ |= results->field_trial_triggered; 456 field_trial_triggered_ |= results->field_trial_triggered;
466 field_trial_triggered_in_session_ |= results->field_trial_triggered; 457 field_trial_triggered_in_session_ |= results->field_trial_triggered;
467 return true; 458 return true;
468 } 459 }
469 460
470 void BaseSearchProvider::ModifyProviderInfo(
471 metrics::OmniboxEventProto_ProviderInfo* provider_info) const {
472 }
473
474 void BaseSearchProvider::DeleteMatchFromMatches( 461 void BaseSearchProvider::DeleteMatchFromMatches(
475 const AutocompleteMatch& match) { 462 const AutocompleteMatch& match) {
476 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { 463 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) {
477 // Find the desired match to delete by checking the type and contents. 464 // Find the desired match to delete by checking the type and contents.
478 // We can't check the destination URL, because the autocomplete controller 465 // We can't check the destination URL, because the autocomplete controller
479 // may have reformulated that. Not that while checking for matching 466 // may have reformulated that. Not that while checking for matching
480 // contents works for personalized suggestions, if more match types gain 467 // contents works for personalized suggestions, if more match types gain
481 // deletion support, this algorithm may need to be re-examined. 468 // deletion support, this algorithm may need to be re-examined.
482 if (i->contents == match.contents && i->type == match.type) { 469 if (i->contents == match.contents && i->type == match.type) {
483 matches_.erase(i); 470 matches_.erase(i);
484 break; 471 break;
485 } 472 }
486 } 473 }
487 } 474 }
488 475
489 void BaseSearchProvider::OnDeletionComplete( 476 void BaseSearchProvider::OnDeletionComplete(
490 bool success, SuggestionDeletionHandler* handler) { 477 bool success, SuggestionDeletionHandler* handler) {
491 RecordDeletionResult(success); 478 RecordDeletionResult(success);
492 SuggestionDeletionHandlers::iterator it = std::find( 479 SuggestionDeletionHandlers::iterator it = std::find(
493 deletion_handlers_.begin(), deletion_handlers_.end(), handler); 480 deletion_handlers_.begin(), deletion_handlers_.end(), handler);
494 DCHECK(it != deletion_handlers_.end()); 481 DCHECK(it != deletion_handlers_.end());
495 deletion_handlers_.erase(it); 482 deletion_handlers_.erase(it);
496 } 483 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698