[omnibox] Add TemplateURLRef::SearchTermsArgs::omnibox_focus_type
Add an omnibox_focus_type member to TemplateURLRef::SearchTermsArgs.
In a followup CL, this enum value will be used to build up the proper
suggest URL.
This also refactors RemoteSuggestionsService to take a SearchTermsArgs
parameter, so that ZeroSuggestProvider can set the ON_FOCUS value.
We don't want RemoteSuggestionsService to set ON_FOCUS, as it would
seems surprising for all requests coming from RemoteSuggestionsService
to be presumed to be on-focus. (Even though that's true today.)
Bug: 963173
Change-Id: I6202b68876398b9fc2a2258898a1c975225db13b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1670123
Reviewed-by: Mark Pearson <[email protected]>
Commit-Queue: Tommy Li <[email protected]>
Cr-Commit-Position: refs/heads/master@{#673038}
diff --git a/components/omnibox/browser/zero_suggest_provider.cc b/components/omnibox/browser/zero_suggest_provider.cc
index 6d8d4d3..23d25bfa 100644
--- a/components/omnibox/browser/zero_suggest_provider.cc
+++ b/components/omnibox/browser/zero_suggest_provider.cc
@@ -163,8 +163,12 @@
current_page_classification_ = input.current_page_classification();
current_url_match_ = MatchForCurrentURL();
+ TemplateURLRef::SearchTermsArgs search_terms_args;
+ search_terms_args.page_classification = current_page_classification_;
+ search_terms_args.omnibox_focus_type =
+ TemplateURLRef::SearchTermsArgs::OmniboxFocusType::ON_FOCUS;
GURL suggest_url = RemoteSuggestionsService::EndpointUrl(
- /*current_url=*/"", input, client()->GetTemplateURLService());
+ search_terms_args, client()->GetTemplateURLService());
if (!suggest_url.is_valid())
return;
@@ -191,14 +195,14 @@
return;
}
- const std::string current_url =
+ search_terms_args.current_page_url =
result_type_running_ == REMOTE_SEND_URL ? current_query_ : std::string();
// Create a request for suggestions, routing completion to
// OnRemoteSuggestionsLoaderAvailable.
client()
->GetRemoteSuggestionsService(/*create_if_necessary=*/true)
->CreateSuggestionsRequest(
- current_url, client()->GetCurrentVisitTimestamp(), input,
+ search_terms_args, client()->GetCurrentVisitTimestamp(),
client()->GetTemplateURLService(),
base::BindOnce(
&ZeroSuggestProvider::OnRemoteSuggestionsLoaderAvailable,
@@ -278,9 +282,8 @@
client->GetTemplateURLService();
// Template URL service can be null in tests.
if (template_url_service != nullptr) {
- AutocompleteInput empty_input;
GURL suggest_url = RemoteSuggestionsService::EndpointUrl(
- /*current_url=*/"", /*empty input*/ empty_input, template_url_service);
+ TemplateURLRef::SearchTermsArgs(), template_url_service);
// To check whether this is allowed, use an arbitrary insecure (http) URL
// as the URL we'd want suggestions for. The value of OTHER as the current
// page classification is to correspond with that URL.