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

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

Issue 462963002: [AiS] Reuse previous answer for verbatim. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 726
727 bool relevance_from_server; 727 bool relevance_from_server;
728 int verbatim_relevance = GetVerbatimRelevance(&relevance_from_server); 728 int verbatim_relevance = GetVerbatimRelevance(&relevance_from_server);
729 int did_not_accept_default_suggestion = 729 int did_not_accept_default_suggestion =
730 default_results_.suggest_results.empty() ? 730 default_results_.suggest_results.empty() ?
731 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE : 731 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE :
732 TemplateURLRef::NO_SUGGESTION_CHOSEN; 732 TemplateURLRef::NO_SUGGESTION_CHOSEN;
733 if (verbatim_relevance > 0) { 733 if (verbatim_relevance > 0) {
734 const base::string16& trimmed_verbatim = 734 const base::string16& trimmed_verbatim =
735 base::CollapseWhitespace(input_.text(), false); 735 base::CollapseWhitespace(input_.text(), false);
736
737 // Verbatim results don't get suggestions and hence, answers.
Mark P 2014/08/12 20:57:29 This feels like the wrong place to do this. By do
groby-ooo-7-16 2014/08/12 22:09:20 But I can't add it anywhere else - the answer need
Mark P 2014/08/12 23:17:43 Good point.
msw 2014/08/13 19:01:04 Why don't verbatim results get suggestions? Isn't
Mark P 2014/08/13 19:42:22 I'll answer on behalf of groby@: the server does n
738 // Scan previous matches if the last answer-bearing suggestion matches
msw 2014/08/13 19:01:04 Why not just check |last_answer_seen_| instead of
groby-ooo-7-16 2014/08/13 20:07:17 Because 1) last_answer_seen_ is only the query te
Mark P 2014/08/13 20:12:27 If this is happening, can you add to the bug that'
groby-ooo-7-16 2014/08/13 23:39:21 The cache still can't hold the answers content. Th
Mark P 2014/08/14 03:29:44 When the user ceases to edit something in the omni
739 // verbatim, and if so, copy over answer contents.
740 base::string16 answer_contents;
741 base::string16 answer_type;
742 for (ACMatches::iterator it = matches_.begin(); it != matches_.end();
743 ++it) {
744 if (!it->answer_contents.empty() &&
745 it->fill_into_edit == trimmed_verbatim) {
746 answer_contents = it->answer_contents;
747 answer_type = it->answer_type;
748 break;
749 }
750 }
751
736 SearchSuggestionParser::SuggestResult verbatim( 752 SearchSuggestionParser::SuggestResult verbatim(
737 trimmed_verbatim, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, 753 trimmed_verbatim, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED,
738 trimmed_verbatim, base::string16(), base::string16(), base::string16(), 754 trimmed_verbatim, base::string16(), base::string16(), answer_contents,
739 base::string16(), std::string(), std::string(), false, 755 answer_type, std::string(), std::string(), false, verbatim_relevance,
740 verbatim_relevance, relevance_from_server, false, 756 relevance_from_server, false, trimmed_verbatim);
741 trimmed_verbatim);
742 AddMatchToMap(verbatim, std::string(), did_not_accept_default_suggestion, 757 AddMatchToMap(verbatim, std::string(), did_not_accept_default_suggestion,
743 false, &map); 758 false, &map);
744 } 759 }
745 if (!keyword_input_.text().empty()) { 760 if (!keyword_input_.text().empty()) {
746 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); 761 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL();
747 // We only create the verbatim search query match for a keyword 762 // We only create the verbatim search query match for a keyword
748 // if it's not an extension keyword. Extension keywords are handled 763 // if it's not an extension keyword. Extension keywords are handled
749 // in KeywordProvider::Start(). (Extensions are complicated...) 764 // in KeywordProvider::Start(). (Extensions are complicated...)
750 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond 765 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond
751 // to the keyword verbatim search query. Do not create other matches 766 // to the keyword verbatim search query. Do not create other matches
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 last_answer_seen_.query_type = match->answer_type; 1277 last_answer_seen_.query_type = match->answer_type;
1263 } 1278 }
1264 1279
1265 void SearchProvider::DoAnswersQuery(const AutocompleteInput& input) { 1280 void SearchProvider::DoAnswersQuery(const AutocompleteInput& input) {
1266 // If the query text starts with trimmed input, this is valid prefetch data. 1281 // If the query text starts with trimmed input, this is valid prefetch data.
1267 prefetch_data_ = StartsWith(last_answer_seen_.full_query_text, 1282 prefetch_data_ = StartsWith(last_answer_seen_.full_query_text,
1268 base::CollapseWhitespace(input.text(), false), 1283 base::CollapseWhitespace(input.text(), false),
1269 false) ? 1284 false) ?
1270 last_answer_seen_ : AnswersQueryData(); 1285 last_answer_seen_ : AnswersQueryData();
1271 } 1286 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698