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

Side by Side Diff: components/omnibox/browser/base_search_provider.cc

Issue 2755503002: Add a new entry to omnibox_event.proto to log specific type of contextual suggestions (Closed)
Patch Set: Small fixes and sync. Created 3 years, 8 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 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 "components/omnibox/browser/base_search_provider.h" 5 #include "components/omnibox/browser/base_search_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 const base::string16& suggestion, 107 const base::string16& suggestion,
108 AutocompleteMatchType::Type type, 108 AutocompleteMatchType::Type type,
109 bool from_keyword_provider, 109 bool from_keyword_provider,
110 const TemplateURL* template_url, 110 const TemplateURL* template_url,
111 const SearchTermsData& search_terms_data) { 111 const SearchTermsData& search_terms_data) {
112 // These calls use a number of default values. For instance, they assume 112 // These calls use a number of default values. For instance, they assume
113 // that if this match is from a keyword provider, then the user is in keyword 113 // that if this match is from a keyword provider, then the user is in keyword
114 // mode. They also assume the caller knows what it's doing and we set 114 // mode. They also assume the caller knows what it's doing and we set
115 // this match to look as if it was received/created synchronously. 115 // this match to look as if it was received/created synchronously.
116 SearchSuggestionParser::SuggestResult suggest_result( 116 SearchSuggestionParser::SuggestResult suggest_result(
117 suggestion, type, suggestion, base::string16(), base::string16(), 117 suggestion, type, 0, suggestion, base::string16(), base::string16(),
118 base::string16(), base::string16(), nullptr, std::string(), 118 base::string16(), base::string16(), nullptr, std::string(), std::string(),
119 std::string(), from_keyword_provider, 0, false, false, base::string16()); 119 from_keyword_provider, 0, false, false, base::string16());
120 suggest_result.set_received_after_last_keystroke(false); 120 suggest_result.set_received_after_last_keystroke(false);
121 return CreateSearchSuggestion( 121 return CreateSearchSuggestion(
122 NULL, AutocompleteInput(), from_keyword_provider, suggest_result, 122 NULL, AutocompleteInput(), from_keyword_provider, suggest_result,
123 template_url, search_terms_data, 0, false); 123 template_url, search_terms_data, 0, false);
124 } 124 }
125 125
126 void BaseSearchProvider::DeleteMatch(const AutocompleteMatch& match) { 126 void BaseSearchProvider::DeleteMatch(const AutocompleteMatch& match) {
127 DCHECK(match.deletable); 127 DCHECK(match.deletable);
128 if (!match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey).empty()) { 128 if (!match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey).empty()) {
129 deletion_handlers_.push_back(base::MakeUnique<SuggestionDeletionHandler>( 129 deletion_handlers_.push_back(base::MakeUnique<SuggestionDeletionHandler>(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 suggestion.type()); 208 suggestion.type());
209 209
210 if (!template_url) 210 if (!template_url)
211 return match; 211 return match;
212 match.keyword = template_url->keyword(); 212 match.keyword = template_url->keyword();
213 match.contents = suggestion.match_contents(); 213 match.contents = suggestion.match_contents();
214 match.contents_class = suggestion.match_contents_class(); 214 match.contents_class = suggestion.match_contents_class();
215 match.answer_contents = suggestion.answer_contents(); 215 match.answer_contents = suggestion.answer_contents();
216 match.answer_type = suggestion.answer_type(); 216 match.answer_type = suggestion.answer_type();
217 match.answer = SuggestionAnswer::copy(suggestion.answer()); 217 match.answer = SuggestionAnswer::copy(suggestion.answer());
218 match.subtype_identifier = suggestion.subtype_identifier();
218 if (suggestion.type() == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) { 219 if (suggestion.type() == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) {
219 match.RecordAdditionalInfo( 220 match.RecordAdditionalInfo(
220 kACMatchPropertyInputText, base::UTF16ToUTF8(input.text())); 221 kACMatchPropertyInputText, base::UTF16ToUTF8(input.text()));
221 match.RecordAdditionalInfo( 222 match.RecordAdditionalInfo(
222 kACMatchPropertyContentsPrefix, 223 kACMatchPropertyContentsPrefix,
223 base::UTF16ToUTF8(suggestion.match_contents_prefix())); 224 base::UTF16ToUTF8(suggestion.match_contents_prefix()));
224 match.RecordAdditionalInfo( 225 match.RecordAdditionalInfo(
225 kACMatchPropertyContentsStartIndex, 226 kACMatchPropertyContentsStartIndex,
226 static_cast<int>( 227 static_cast<int>(
227 suggestion.suggestion().length() - match.contents.length())); 228 suggestion.suggestion().length() - match.contents.length()));
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 482
482 void BaseSearchProvider::OnDeletionComplete( 483 void BaseSearchProvider::OnDeletionComplete(
483 bool success, SuggestionDeletionHandler* handler) { 484 bool success, SuggestionDeletionHandler* handler) {
484 RecordDeletionResult(success); 485 RecordDeletionResult(success);
485 deletion_handlers_.erase(std::remove_if( 486 deletion_handlers_.erase(std::remove_if(
486 deletion_handlers_.begin(), deletion_handlers_.end(), 487 deletion_handlers_.begin(), deletion_handlers_.end(),
487 [handler](const std::unique_ptr<SuggestionDeletionHandler>& elem) { 488 [handler](const std::unique_ptr<SuggestionDeletionHandler>& elem) {
488 return elem.get() == handler; 489 return elem.get() == handler;
489 })); 490 }));
490 } 491 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/autocomplete_match.cc ('k') | components/omnibox/browser/base_search_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698