Index: chrome/browser/autocomplete/search_provider.cc |
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc |
index d1e5998a928dc5ad2d193142044469201d336631..726b982232ff3c9bcd922d43ec853212b6a47daf 100644 |
--- a/chrome/browser/autocomplete/search_provider.cc |
+++ b/chrome/browser/autocomplete/search_provider.cc |
@@ -209,6 +209,7 @@ SearchProvider::SuggestResult::SuggestResult( |
const string16& match_contents, |
const string16& annotation, |
const std::string& suggest_query_params, |
+ const std::string& xsrf_token, |
bool from_keyword_provider, |
int relevance, |
bool relevance_from_server, |
@@ -218,6 +219,7 @@ SearchProvider::SuggestResult::SuggestResult( |
match_contents_(match_contents), |
annotation_(annotation), |
suggest_query_params_(suggest_query_params), |
+ xsrf_token_(xsrf_token), |
should_prefetch_(should_prefetch) { |
} |
@@ -352,6 +354,7 @@ AutocompleteMatch SearchProvider::CreateSearchSuggestion( |
const TemplateURL* template_url, |
const string16& query_string, |
const std::string& suggest_query_params, |
+ const std::string& xsrf_token, |
int accepted_suggestion, |
int omnibox_start_margin, |
bool append_extra_query_params) { |
@@ -390,6 +393,7 @@ AutocompleteMatch SearchProvider::CreateSearchSuggestion( |
match.search_terms_args->suggest_query_params = suggest_query_params; |
match.search_terms_args->append_extra_query_params = |
append_extra_query_params; |
+ match.search_terms_args->xsrf_token = xsrf_token; |
// This is the destination URL sans assisted query stats. This must be set |
// so the AutocompleteController can properly de-dupe; the controller will |
// eventually overwrite it before it reaches the user. |
@@ -1042,6 +1046,7 @@ bool SearchProvider::ParseSuggestResults(Value* root_val, bool is_keyword) { |
string16 disambiguating_query; |
string16 annotation; |
std::string suggest_query_params; |
+ std::string xsrf_token; |
if (suggestion_details && (type == "ENTITY") && |
suggestion_details->GetDictionary(index, &suggestion_detail) && |
suggestion_detail) { |
@@ -1050,11 +1055,15 @@ bool SearchProvider::ParseSuggestResults(Value* root_val, bool is_keyword) { |
!disambiguating_query.empty()) |
suggestion = disambiguating_query; |
suggestion_detail->GetString("q", &suggest_query_params); |
+ } else if (suggestion_details && (type == "PERSONALIZED_QUERY") && |
+ suggestion_details->GetDictionary(index, &suggestion_detail) && |
+ suggestion_detail) { |
+ suggestion_detail->GetString("x", &xsrf_token); |
} |
// TODO(kochi): Improve calculator suggestion presentation. |
results->suggest_results.push_back(SuggestResult( |
suggestion, match_contents, annotation, suggest_query_params, |
- is_keyword, relevance, true, should_prefetch)); |
+ xsrf_token, is_keyword, relevance, true, should_prefetch)); |
} |
} |
@@ -1104,6 +1113,7 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() { |
input_.text(), |
did_not_accept_default_suggestion, |
std::string(), |
+ std::string(), |
&map); |
} |
if (!keyword_input_.text().empty()) { |
@@ -1132,6 +1142,7 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() { |
keyword_input_.text(), |
did_not_accept_keyword_suggestion, |
std::string(), |
+ std::string(), |
&map); |
} |
} |
@@ -1380,6 +1391,7 @@ void SearchProvider::AddHistoryResultsToMap(const HistoryResults& results, |
i->suggestion(), |
did_not_accept_suggestion, |
std::string(), |
+ std::string(), |
map); |
} |
UMA_HISTOGRAM_TIMES("Omnibox.SearchProvider.AddHistoryResultsTime", |
@@ -1430,7 +1442,7 @@ SearchProvider::SuggestResults SearchProvider::ScoreHistoryResults( |
prevent_search_history_inlining); |
scored_results.push_back( |
SuggestResult(i->term, string16(), string16(), std::string(), |
- is_keyword, relevance, false, false)); |
+ std::string(), is_keyword, relevance, false, false)); |
} |
// History returns results sorted for us. However, we may have docked some |
@@ -1469,6 +1481,7 @@ void SearchProvider::AddSuggestResultsToMap(const SuggestResults& results, |
results[i].suggestion(), |
i, |
results[i].suggest_query_params(), |
+ results[i].xsrf_token(), |
map); |
} |
} |
@@ -1593,6 +1606,7 @@ void SearchProvider::AddMatchToMap(const string16& input_text, |
const string16& query_string, |
int accepted_suggestion, |
const std::string& suggest_query_params, |
+ const std::string& xsrf_token, |
MatchMap* map) { |
// On non-mobile, ask the instant controller for the appropriate start margin. |
// On mobile the start margin is unused, so leave the value as default there. |
@@ -1614,7 +1628,7 @@ void SearchProvider::AddMatchToMap(const string16& input_text, |
AutocompleteMatch match = CreateSearchSuggestion( |
this, input_, input_text, relevance, type, is_keyword, match_contents, |
annotation, template_url, query_string, suggest_query_params, |
- accepted_suggestion, omnibox_start_margin, |
+ xsrf_token, accepted_suggestion, omnibox_start_margin, |
!is_keyword || providers_.default_provider().empty()); |
if (!match.destination_url.is_valid()) |
return; |