Commit 823509e0 authored by Tommy Li's avatar Tommy Li Committed by Commit Bot

Reland "[omnibox] ZeroSuggestProvider: classify search results w/ input text"

This is a reland of 197dd2b5

This is an unedited reland. The old one was reverted because of a crash, but
this CL should fix the crash, making this reland safe:

https://chromium-review.googlesource.com/c/chromium/src/+/1955787

Original change's description:
> [omnibox] ZeroSuggestProvider: classify search results w/ input text
>
> Currently, when we get search suggest results back from
> ZeroSuggestProvider, nothing is bolded. This is inconsistent with
> as-you-type search suggestions.
>
> The root cause is that we purposely set AutocompleteInput::input_text
> to an empty string for all ZeroSuggest queries, to avoid leaking the
> user's current URL. (The URL is separately included in eligible).
>
> The lack of bolding is an unintended side effect.
>
> This CL fixes that, by re-classifying all the search suggest results
> that come back with the real input text on the client side.
>
> This is primarily intended to improve On Focus Query Refinements,
> but this will affect all ZeroSuggest modes that return search results
> from a non-empty omnibox. (Should not affect NTP).
>
> Note nothing is bolded at all when the input text is empty (on NTP).
>
> Navigational suggestions are not affected by this CL. They are
> currently not bolded at all.
>
> Bug: 963173
> Change-Id: I7982c780f4b03f3d2b4992051d291fe1cd86f4b7
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1947765
> Reviewed-by: manuk hovanesian <manukh@chromium.org>
> Commit-Queue: Tommy Li <tommycli@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#721114}

Bug: 963173
Change-Id: I4a6d1195a47cab19ef4cc9e1b3756e3f6ab9f20c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1954250Reviewed-by: default avatarmanuk hovanesian <manukh@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722655}
parent 8693d2fe
......@@ -35,6 +35,7 @@
#include "components/omnibox/browser/omnibox_pref_names.h"
#include "components/omnibox/browser/remote_suggestions_service.h"
#include "components/omnibox/browser/search_provider.h"
#include "components/omnibox/browser/search_suggestion_parser.h"
#include "components/omnibox/browser/verbatim_match.h"
#include "components/omnibox/common/omnibox_features.h"
#include "components/pref_registry/pref_registry_syncable.h"
......@@ -451,13 +452,6 @@ bool ZeroSuggestProvider::UpdateResults(const std::string& json_data) {
return results_updated;
}
void ZeroSuggestProvider::AddSuggestResultsToMap(
const SearchSuggestionParser::SuggestResults& results,
MatchMap* map) {
for (size_t i = 0; i < results.size(); ++i)
AddMatchToMap(results[i], std::string(), i, false, false, map);
}
AutocompleteMatch ZeroSuggestProvider::NavigationToMatch(
const SearchSuggestionParser::NavigationResult& navigation) {
AutocompleteMatch match(this, navigation.relevance(), false,
......@@ -524,7 +518,16 @@ void ZeroSuggestProvider::ConvertResultsToAutocompleteMatches() {
return;
MatchMap map;
AddSuggestResultsToMap(results_.suggest_results, &map);
// Add all the SuggestResults to the map, re-classifying based on the
// permanent text as we go. This is to make ZeroSuggest results formatted in
// a congruent way with as-you-type search suggestions.
for (size_t i = 0; i < results_.suggest_results.size(); ++i) {
results_.suggest_results[i].ClassifyMatchContents(true, permanent_text_);
AddMatchToMap(results_.suggest_results[i], std::string(), i, false, false,
&map);
}
const int num_query_results = map.size();
const int num_nav_results = results_.navigation_results.size();
......
......@@ -128,12 +128,6 @@ class ZeroSuggestProvider : public BaseSearchProvider {
// The return value is true only when |results_| changed.
bool UpdateResults(const std::string& json_data);
// Adds AutocompleteMatches for each of the suggestions in |results| to
// |map|.
void AddSuggestResultsToMap(
const SearchSuggestionParser::SuggestResults& results,
MatchMap* map);
// Returns an AutocompleteMatch for a navigational suggestion |navigation|.
AutocompleteMatch NavigationToMatch(
const SearchSuggestionParser::NavigationResult& navigation);
......
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