Commit 864725b8 authored by Gheorghe Comanici's avatar Gheorghe Comanici Committed by Commit Bot

Add fallback to MostVisited URLs when pers 0-query is not supported.

This CL adds a fallback to display MostVisited URLs when personalized
zero-query is enabled with ChromeHomePersonalizedOmniboxSuggestions but
the user's default search engine is not Google.

Bug: 781994
Change-Id: I489052f3a33e2f97d86138760f8f2d135515c241
Reviewed-on: https://chromium-review.googlesource.com/777502
Commit-Queue: Gheorghe Comanici <gcomanici@chromium.org>
Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519855}
parent efd308da
......@@ -333,6 +333,7 @@ bool OmniboxFieldTrial::InZeroSuggestMostVisitedWithoutSerpFieldTrial(
#endif
}
// static
bool OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial(
PrefService* prefs) {
std::string variant(variations::GetVariationParamValue(
......
......@@ -35,6 +35,7 @@
#include "components/omnibox/browser/verbatim_match.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/search_engines/search_engine_type.h"
#include "components/search_engines/template_url_service.h"
#include "components/url_formatter/url_formatter.h"
#include "components/variations/net/variations_http_headers.h"
......@@ -86,6 +87,31 @@ const int kDefaultZeroSuggestRelevance = 100;
// Used for testing whether zero suggest is ever available.
constexpr char kArbitraryInsecureUrlString[] = "http://www.google.com/";
// Used to determine whether or not Most Visited URLs will be displayed.
// This is true in either of these two cases:
// 1. The user is in zero suggest most visited field trial.
// 2. The user is in zero suggest field trial that enables search-for
// queries as suggestions and the user does not have Google set up as
// their default search engine
bool DisplayZeroSuggestMostVisitedURLs(
PrefService* prefs,
const TemplateURLService* template_url_service) {
if (OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial(prefs))
return true;
if (OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial(prefs) &&
template_url_service != nullptr) {
const TemplateURL* default_provider =
template_url_service->GetDefaultSearchProvider();
return default_provider == nullptr ||
default_provider->GetEngineType(
template_url_service->search_terms_data()) !=
SEARCH_ENGINE_GOOGLE;
}
return false;
}
} // namespace
// static
......@@ -170,8 +196,8 @@ void ZeroSuggestProvider::Start(const AutocompleteInput& input,
// suggestions, if based on local browsing history.
MaybeUseCachedSuggestions();
if (OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial(
client()->GetPrefs())) {
if (DisplayZeroSuggestMostVisitedURLs(client()->GetPrefs(),
template_url_service)) {
most_visited_urls_.clear();
scoped_refptr<history::TopSites> ts = client()->GetTopSites();
if (ts) {
......@@ -442,8 +468,8 @@ void ZeroSuggestProvider::ConvertResultsToAutocompleteMatches() {
UMA_HISTOGRAM_COUNTS("ZeroSuggest.AllResults", num_results);
// Show Most Visited results after ZeroSuggest response is received.
if (OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial(
client()->GetPrefs())) {
if (DisplayZeroSuggestMostVisitedURLs(client()->GetPrefs(),
template_url_service)) {
if (!current_url_match_.destination_url.is_valid())
return;
matches_.push_back(current_url_match_);
......
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