Commit 716cd376 authored by groby@chromium.org's avatar groby@chromium.org

[AiS] Reuse previous answer for verbatim.

Verbatim queries do not see an answer. If the previous query had an
answer with a suggestion that matches the current verbatim text, reuse
that answer.

BUG=401486

Review URL: https://codereview.chromium.org/462963002

Cr-Commit-Position: refs/heads/master@{#289959}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289959 0039d316-1c4b-4281-b951-d872f2087c98
parent 2949d5bb
...@@ -733,12 +733,27 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() { ...@@ -733,12 +733,27 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() {
if (verbatim_relevance > 0) { if (verbatim_relevance > 0) {
const base::string16& trimmed_verbatim = const base::string16& trimmed_verbatim =
base::CollapseWhitespace(input_.text(), false); base::CollapseWhitespace(input_.text(), false);
// Verbatim results don't get suggestions and hence, answers.
// Scan previous matches if the last answer-bearing suggestion matches
// verbatim, and if so, copy over answer contents.
base::string16 answer_contents;
base::string16 answer_type;
for (ACMatches::iterator it = matches_.begin(); it != matches_.end();
++it) {
if (!it->answer_contents.empty() &&
it->fill_into_edit == trimmed_verbatim) {
answer_contents = it->answer_contents;
answer_type = it->answer_type;
break;
}
}
SearchSuggestionParser::SuggestResult verbatim( SearchSuggestionParser::SuggestResult verbatim(
trimmed_verbatim, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, trimmed_verbatim, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED,
trimmed_verbatim, base::string16(), base::string16(), base::string16(), trimmed_verbatim, base::string16(), base::string16(), answer_contents,
base::string16(), std::string(), std::string(), false, answer_type, std::string(), std::string(), false, verbatim_relevance,
verbatim_relevance, relevance_from_server, false, relevance_from_server, false, trimmed_verbatim);
trimmed_verbatim);
AddMatchToMap(verbatim, std::string(), did_not_accept_default_suggestion, AddMatchToMap(verbatim, std::string(), did_not_accept_default_suggestion,
false, &map); false, &map);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment