blob: 52b1cd1079faaf1ac1826ae463541518b3e7fcad [file] [log] [blame]
[email protected]6ce7f612012-09-05 23:53:071// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/autocomplete/zero_suggest_provider.h"
6
7#include "base/callback.h"
[email protected]bb1fb2b2013-05-31 00:21:018#include "base/i18n/case_conversion.h"
[email protected]6ce7f612012-09-05 23:53:079#include "base/json/json_string_value_serializer.h"
[email protected]bb1fb2b2013-05-31 00:21:0110#include "base/metrics/histogram.h"
[email protected]3853a4c2013-02-11 17:15:5711#include "base/prefs/pref_service.h"
[email protected]98570e12013-06-10 19:54:2212#include "base/strings/string16.h"
13#include "base/strings/string_util.h"
[email protected]135cb802013-06-09 16:44:2014#include "base/strings/utf_string_conversions.h"
[email protected]4dcb7972013-06-28 15:15:4115#include "base/time/time.h"
[email protected]2d915782013-08-29 09:50:2116#include "chrome/browser/autocomplete/autocomplete_classifier.h"
17#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
[email protected]6ce7f612012-09-05 23:53:0718#include "chrome/browser/autocomplete/autocomplete_input.h"
19#include "chrome/browser/autocomplete/autocomplete_match.h"
20#include "chrome/browser/autocomplete/autocomplete_provider_listener.h"
[email protected]bb1fb2b2013-05-31 00:21:0121#include "chrome/browser/autocomplete/history_url_provider.h"
22#include "chrome/browser/autocomplete/search_provider.h"
23#include "chrome/browser/autocomplete/url_prefix.h"
[email protected]8f064e52013-09-18 01:17:1424#include "chrome/browser/history/history_types.h"
25#include "chrome/browser/history/top_sites.h"
[email protected]bb1fb2b2013-05-31 00:21:0126#include "chrome/browser/metrics/variations/variations_http_header_provider.h"
[email protected]bb1fb2b2013-05-31 00:21:0127#include "chrome/browser/omnibox/omnibox_field_trial.h"
[email protected]6ce7f612012-09-05 23:53:0728#include "chrome/browser/profiles/profile.h"
[email protected]bb1fb2b2013-05-31 00:21:0129#include "chrome/browser/search/search.h"
[email protected]6ce7f612012-09-05 23:53:0730#include "chrome/browser/search_engines/template_url_service.h"
31#include "chrome/browser/search_engines/template_url_service_factory.h"
[email protected]4f3b4462013-07-27 19:20:1832#include "chrome/common/net/url_fixer_upper.h"
[email protected]a00008d42012-09-15 05:07:5833#include "chrome/common/pref_names.h"
[email protected]6ce7f612012-09-05 23:53:0734#include "chrome/common/url_constants.h"
[email protected]0cfddf1b2014-03-12 01:46:0035#include "content/public/browser/user_metrics.h"
[email protected]bb1fb2b2013-05-31 00:21:0136#include "net/base/escape.h"
[email protected]6ce7f612012-09-05 23:53:0737#include "net/base/load_flags.h"
[email protected]bb1fb2b2013-05-31 00:21:0138#include "net/base/net_util.h"
39#include "net/http/http_request_headers.h"
[email protected]6ce7f612012-09-05 23:53:0740#include "net/url_request/url_fetcher.h"
41#include "net/url_request/url_request_status.h"
[email protected]761fa4702013-07-02 15:25:1542#include "url/gurl.h"
[email protected]6ce7f612012-09-05 23:53:0743
44namespace {
[email protected]bb1fb2b2013-05-31 00:21:0145
46// TODO(hfung): The histogram code was copied and modified from
47// search_provider.cc. Refactor and consolidate the code.
48// We keep track in a histogram how many suggest requests we send, how
49// many suggest requests we invalidate (e.g., due to a user typing
50// another character), and how many replies we receive.
51// *** ADD NEW ENUMS AFTER ALL PREVIOUSLY DEFINED ONES! ***
52// (excluding the end-of-list enum value)
53// We do not want values of existing enums to change or else it screws
54// up the statistics.
55enum ZeroSuggestRequestsHistogramValue {
56 ZERO_SUGGEST_REQUEST_SENT = 1,
57 ZERO_SUGGEST_REQUEST_INVALIDATED,
58 ZERO_SUGGEST_REPLY_RECEIVED,
59 ZERO_SUGGEST_MAX_REQUEST_HISTOGRAM_VALUE
60};
61
62void LogOmniboxZeroSuggestRequest(
63 ZeroSuggestRequestsHistogramValue request_value) {
64 UMA_HISTOGRAM_ENUMERATION("Omnibox.ZeroSuggestRequests", request_value,
65 ZERO_SUGGEST_MAX_REQUEST_HISTOGRAM_VALUE);
66}
67
68// The maximum relevance of the top match from this provider.
69const int kDefaultVerbatimZeroSuggestRelevance = 1300;
70
71// Relevance value to use if it was not set explicitly by the server.
72const int kDefaultZeroSuggestRelevance = 100;
73
[email protected]6ce7f612012-09-05 23:53:0774} // namespace
75
[email protected]a00008d42012-09-15 05:07:5876// static
77ZeroSuggestProvider* ZeroSuggestProvider::Create(
78 AutocompleteProviderListener* listener,
79 Profile* profile) {
[email protected]bb1fb2b2013-05-31 00:21:0180 return new ZeroSuggestProvider(listener, profile);
[email protected]6ce7f612012-09-05 23:53:0781}
82
[email protected]6ce7f612012-09-05 23:53:0783void ZeroSuggestProvider::Start(const AutocompleteInput& input,
84 bool /*minimal_changes*/) {
[email protected]bb1fb2b2013-05-31 00:21:0185}
86
[email protected]bb1fb2b2013-05-31 00:21:0187void ZeroSuggestProvider::ResetSession() {
88 // The user has started editing in the omnibox, so leave
89 // |field_trial_triggered_in_session_| unchanged and set
90 // |field_trial_triggered_| to false since zero suggest is inactive now.
91 field_trial_triggered_ = false;
[email protected]162c8d9fa2014-03-18 20:25:4192
93 // This call clears out |matches_| so that they don't pollute prefix-based
94 // queries.
95 // TODO(mariakhomenko): Change the model to clear |matches_| on Start() like
96 // all the other providers.
[email protected]9c97f89c2013-06-25 03:12:1697 Stop(true);
[email protected]bb1fb2b2013-05-31 00:21:0198}
99
[email protected]25d7e742013-07-30 17:31:06100void ZeroSuggestProvider::StartZeroSuggest(
[email protected]9b9fa672013-11-07 06:04:52101 const GURL& current_page_url,
[email protected]25d7e742013-07-30 17:31:06102 AutocompleteInput::PageClassification page_classification,
[email protected]96920152013-12-04 21:00:16103 const base::string16& permanent_text) {
[email protected]bb1fb2b2013-05-31 00:21:01104 Stop(true);
105 field_trial_triggered_ = false;
106 field_trial_triggered_in_session_ = false;
[email protected]9b9fa672013-11-07 06:04:52107 permanent_text_ = permanent_text;
108 current_query_ = current_page_url.spec();
109 current_page_classification_ = page_classification;
110 current_url_match_ = MatchForCurrentURL();
111
112 const TemplateURL* default_provider =
113 template_url_service_->GetDefaultSearchProvider();
114 if (default_provider == NULL)
115 return;
[email protected]162c8d9fa2014-03-18 20:25:41116
[email protected]96920152013-12-04 21:00:16117 base::string16 prefix;
[email protected]9b9fa672013-11-07 06:04:52118 TemplateURLRef::SearchTermsArgs search_term_args(prefix);
[email protected]162c8d9fa2014-03-18 20:25:41119 GURL suggest_url(default_provider->suggestions_url_ref().ReplaceSearchTerms(
120 search_term_args));
121 if (!suggest_url.is_valid())
[email protected]6ce7f612012-09-05 23:53:07122 return;
[email protected]162c8d9fa2014-03-18 20:25:41123
124 // No need to send the current page URL in personalized suggest field trial.
125 if (CanSendURL(current_page_url, suggest_url, default_provider,
126 current_page_classification_, profile_) &&
127 !OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial()) {
128 // Update suggest_url to include the current_page_url.
129 search_term_args.current_page_url = current_query_;
130 suggest_url = GURL(default_provider->suggestions_url_ref().
131 ReplaceSearchTerms(search_term_args));
132 } else if (!CanShowZeroSuggestWithoutSendingURL(suggest_url,
133 current_page_url)) {
134 return;
135 }
136
[email protected]6ce7f612012-09-05 23:53:07137 done_ = false;
[email protected]6ce7f612012-09-05 23:53:07138 // TODO(jered): Consider adding locally-sourced zero-suggestions here too.
139 // These may be useful on the NTP or more relevant to the user than server
140 // suggestions, if based on local browsing history.
[email protected]9b9fa672013-11-07 06:04:52141 Run(suggest_url);
[email protected]6ce7f612012-09-05 23:53:07142}
143
[email protected]bb1fb2b2013-05-31 00:21:01144ZeroSuggestProvider::ZeroSuggestProvider(
145 AutocompleteProviderListener* listener,
146 Profile* profile)
[email protected]02346202014-02-05 05:18:30147 : BaseSearchProvider(listener, profile,
148 AutocompleteProvider::TYPE_ZERO_SUGGEST),
[email protected]bb1fb2b2013-05-31 00:21:01149 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)),
[email protected]8f064e52013-09-18 01:17:14150 weak_ptr_factory_(this) {
[email protected]6ce7f612012-09-05 23:53:07151}
152
153ZeroSuggestProvider::~ZeroSuggestProvider() {
154}
155
[email protected]cfa164bf2014-03-19 11:51:15156const TemplateURL* ZeroSuggestProvider::GetTemplateURL(bool is_keyword) const {
[email protected]9487b392014-02-14 02:48:18157 // Zero suggest provider should not receive keyword results.
[email protected]cfa164bf2014-03-19 11:51:15158 DCHECK(!is_keyword);
[email protected]9487b392014-02-14 02:48:18159 return template_url_service_->GetDefaultSearchProvider();
160}
161
[email protected]d4a94b92014-03-04 01:35:22162const AutocompleteInput ZeroSuggestProvider::GetInput(bool is_keyword) const {
163 return AutocompleteInput(
164 base::string16(), base::string16::npos, base::string16(),
165 GURL(current_query_), current_page_classification_, true, false, false,
166 AutocompleteInput::ALL_MATCHES);
[email protected]9487b392014-02-14 02:48:18167}
168
[email protected]cfa164bf2014-03-19 11:51:15169BaseSearchProvider::Results* ZeroSuggestProvider::GetResultsToFill(
170 bool is_keyword) {
171 DCHECK(!is_keyword);
172 return &results_;
173}
174
[email protected]9487b392014-02-14 02:48:18175bool ZeroSuggestProvider::ShouldAppendExtraParams(
176 const SuggestResult& result) const {
177 // We always use the default provider for search, so append the params.
178 return true;
179}
180
[email protected]ef6866f2014-02-18 08:26:34181void ZeroSuggestProvider::StopSuggest() {
[email protected]cfa164bf2014-03-19 11:51:15182 if (suggest_results_pending_ > 0)
[email protected]ef6866f2014-02-18 08:26:34183 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_INVALIDATED);
[email protected]cfa164bf2014-03-19 11:51:15184 suggest_results_pending_ = 0;
[email protected]ef6866f2014-02-18 08:26:34185 fetcher_.reset();
186}
187
188void ZeroSuggestProvider::ClearAllResults() {
[email protected]00404742014-02-20 13:09:05189 // We do not call Clear() on |results_| to retain |verbatim_relevance|
190 // value in the |results_| object. |verbatim_relevance| is used at the
191 // beginning of the next StartZeroSuggest() call to determine the current url
192 // match relevance.
193 results_.suggest_results.clear();
194 results_.navigation_results.clear();
[email protected]ef6866f2014-02-18 08:26:34195 current_query_.clear();
196 matches_.clear();
197}
198
[email protected]d4a94b92014-03-04 01:35:22199int ZeroSuggestProvider::GetDefaultResultRelevance() const {
200 return kDefaultZeroSuggestRelevance;
201}
202
[email protected]0cfddf1b2014-03-12 01:46:00203void ZeroSuggestProvider::RecordDeletionResult(bool success) {
204 if (success) {
205 content::RecordAction(
206 base::UserMetricsAction("Omnibox.ZeroSuggestDelete.Success"));
207 } else {
208 content::RecordAction(
209 base::UserMetricsAction("Omnibox.ZeroSuggestDelete.Failure"));
210 }
211}
212
[email protected]cfa164bf2014-03-19 11:51:15213void ZeroSuggestProvider::LogFetchComplete(bool success, bool is_keyword) {
214 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REPLY_RECEIVED);
215}
216
217bool ZeroSuggestProvider::IsKeywordFetcher(
218 const net::URLFetcher* fetcher) const {
219 // ZeroSuggestProvider does not have a keyword provider.
220 DCHECK_EQ(fetcher, fetcher_.get());
221 return false;
222}
223
224void ZeroSuggestProvider::UpdateMatches() {
225 done_ = true;
226 ConvertResultsToAutocompleteMatches();
227}
228
[email protected]bb1fb2b2013-05-31 00:21:01229void ZeroSuggestProvider::AddSuggestResultsToMap(
[email protected]02346202014-02-05 05:18:30230 const SuggestResults& results,
[email protected]02346202014-02-05 05:18:30231 MatchMap* map) {
[email protected]d4a94b92014-03-04 01:35:22232 for (size_t i = 0; i < results.size(); ++i)
[email protected]57482a72014-03-14 22:27:37233 AddMatchToMap(results[i], std::string(), i, false, map);
[email protected]bb1fb2b2013-05-31 00:21:01234}
235
[email protected]bb1fb2b2013-05-31 00:21:01236AutocompleteMatch ZeroSuggestProvider::NavigationToMatch(
[email protected]02346202014-02-05 05:18:30237 const NavigationResult& navigation) {
[email protected]bb1fb2b2013-05-31 00:21:01238 AutocompleteMatch match(this, navigation.relevance(), false,
239 AutocompleteMatchType::NAVSUGGEST);
240 match.destination_url = navigation.url();
241
[email protected]23db6492014-01-16 02:35:30242 // Zero suggest results should always omit protocols and never appear bold.
[email protected]bb1fb2b2013-05-31 00:21:01243 const std::string languages(
244 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
245 match.contents = net::FormatUrl(navigation.url(), languages,
246 net::kFormatUrlOmitAll, net::UnescapeRule::SPACES, NULL, NULL, NULL);
247 match.fill_into_edit +=
248 AutocompleteInput::FormattedStringWithEquivalentMeaning(navigation.url(),
249 match.contents);
[email protected]bb1fb2b2013-05-31 00:21:01250
[email protected]b959d7d42013-12-13 17:26:37251 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0,
[email protected]bb1fb2b2013-05-31 00:21:01252 match.contents.length(), ACMatchClassification::URL,
253 &match.contents_class);
[email protected]9c97f89c2013-06-25 03:12:16254
255 match.description =
256 AutocompleteMatch::SanitizeString(navigation.description());
[email protected]b959d7d42013-12-13 17:26:37257 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0,
[email protected]9c97f89c2013-06-25 03:12:16258 match.description.length(), ACMatchClassification::NONE,
259 &match.description_class);
[email protected]bb1fb2b2013-05-31 00:21:01260 return match;
261}
262
[email protected]9b9fa672013-11-07 06:04:52263void ZeroSuggestProvider::Run(const GURL& suggest_url) {
[email protected]cfa164bf2014-03-19 11:51:15264 suggest_results_pending_ = 0;
[email protected]bb1fb2b2013-05-31 00:21:01265 const int kFetcherID = 1;
[email protected]bb1fb2b2013-05-31 00:21:01266 fetcher_.reset(
267 net::URLFetcher::Create(kFetcherID,
268 suggest_url,
269 net::URLFetcher::GET, this));
270 fetcher_->SetRequestContext(profile_->GetRequestContext());
271 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
272 // Add Chrome experiment state to the request headers.
273 net::HttpRequestHeaders headers;
274 chrome_variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders(
275 fetcher_->GetOriginalURL(), profile_->IsOffTheRecord(), false, &headers);
276 fetcher_->SetExtraRequestHeaders(headers.ToString());
277
278 fetcher_->Start();
[email protected]8f064e52013-09-18 01:17:14279
280 if (OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial()) {
281 most_visited_urls_.clear();
282 history::TopSites* ts = profile_->GetTopSites();
283 if (ts) {
284 ts->GetMostVisitedURLs(
285 base::Bind(&ZeroSuggestProvider::OnMostVisitedUrlsAvailable,
[email protected]ce767ab22013-11-12 03:50:09286 weak_ptr_factory_.GetWeakPtr()), false);
[email protected]8f064e52013-09-18 01:17:14287 }
288 }
[email protected]cfa164bf2014-03-19 11:51:15289 suggest_results_pending_ = 1;
[email protected]bb1fb2b2013-05-31 00:21:01290 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT);
291}
292
[email protected]8f064e52013-09-18 01:17:14293void ZeroSuggestProvider::OnMostVisitedUrlsAvailable(
294 const history::MostVisitedURLList& urls) {
295 most_visited_urls_ = urls;
296}
297
[email protected]9c97f89c2013-06-25 03:12:16298void ZeroSuggestProvider::ConvertResultsToAutocompleteMatches() {
[email protected]bb1fb2b2013-05-31 00:21:01299 matches_.clear();
300
301 const TemplateURL* default_provider =
[email protected]6ce7f612012-09-05 23:53:07302 template_url_service_->GetDefaultSearchProvider();
303 // Fail if we can't set the clickthrough URL for query suggestions.
[email protected]bb1fb2b2013-05-31 00:21:01304 if (default_provider == NULL || !default_provider->SupportsReplacement())
[email protected]6ce7f612012-09-05 23:53:07305 return;
[email protected]6ce7f612012-09-05 23:53:07306
[email protected]00404742014-02-20 13:09:05307 MatchMap map;
308 AddSuggestResultsToMap(results_.suggest_results, &map);
309
310 const int num_query_results = map.size();
311 const int num_nav_results = results_.navigation_results.size();
[email protected]bb1fb2b2013-05-31 00:21:01312 const int num_results = num_query_results + num_nav_results;
[email protected]9c97f89c2013-06-25 03:12:16313 UMA_HISTOGRAM_COUNTS("ZeroSuggest.QueryResults", num_query_results);
314 UMA_HISTOGRAM_COUNTS("ZeroSuggest.URLResults", num_nav_results);
315 UMA_HISTOGRAM_COUNTS("ZeroSuggest.AllResults", num_results);
[email protected]bb1fb2b2013-05-31 00:21:01316
[email protected]8f064e52013-09-18 01:17:14317 // Show Most Visited results after ZeroSuggest response is received.
318 if (OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial()) {
[email protected]3feb8b002013-10-14 23:50:13319 if (!current_url_match_.destination_url.is_valid())
320 return;
[email protected]8f064e52013-09-18 01:17:14321 matches_.push_back(current_url_match_);
322 int relevance = 600;
323 if (num_results > 0) {
324 UMA_HISTOGRAM_COUNTS(
325 "Omnibox.ZeroSuggest.MostVisitedResultsCounterfactual",
326 most_visited_urls_.size());
327 }
[email protected]23db6492014-01-16 02:35:30328 const base::string16 current_query_string16(
329 base::ASCIIToUTF16(current_query_));
330 const std::string languages(
331 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
[email protected]8f064e52013-09-18 01:17:14332 for (size_t i = 0; i < most_visited_urls_.size(); i++) {
333 const history::MostVisitedURL& url = most_visited_urls_[i];
[email protected]02346202014-02-05 05:18:30334 NavigationResult nav(*this, url.url, url.title, false, relevance, true,
[email protected]23db6492014-01-16 02:35:30335 current_query_string16, languages);
[email protected]8f064e52013-09-18 01:17:14336 matches_.push_back(NavigationToMatch(nav));
337 --relevance;
338 }
339 return;
340 }
341
[email protected]9c97f89c2013-06-25 03:12:16342 if (num_results == 0)
[email protected]bb1fb2b2013-05-31 00:21:01343 return;
344
345 // TODO(jered): Rip this out once the first match is decoupled from the
346 // current typing in the omnibox.
[email protected]bb1fb2b2013-05-31 00:21:01347 matches_.push_back(current_url_match_);
348
[email protected]00404742014-02-20 13:09:05349 for (MatchMap::const_iterator it(map.begin()); it != map.end(); ++it)
[email protected]bb1fb2b2013-05-31 00:21:01350 matches_.push_back(it->second);
[email protected]bb1fb2b2013-05-31 00:21:01351
[email protected]00404742014-02-20 13:09:05352 const NavigationResults& nav_results(results_.navigation_results);
353 for (NavigationResults::const_iterator it(nav_results.begin());
354 it != nav_results.end(); ++it)
[email protected]bb1fb2b2013-05-31 00:21:01355 matches_.push_back(NavigationToMatch(*it));
[email protected]6ce7f612012-09-05 23:53:07356}
357
[email protected]bb1fb2b2013-05-31 00:21:01358AutocompleteMatch ZeroSuggestProvider::MatchForCurrentURL() {
[email protected]96920152013-12-04 21:00:16359 AutocompleteInput input(permanent_text_, base::string16::npos, base::string16(),
[email protected]25d7e742013-07-30 17:31:06360 GURL(current_query_), current_page_classification_,
[email protected]bb1fb2b2013-05-31 00:21:01361 false, false, true, AutocompleteInput::ALL_MATCHES);
[email protected]6ce7f612012-09-05 23:53:07362
[email protected]2d915782013-08-29 09:50:21363 AutocompleteMatch match;
364 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(
[email protected]51abb7b2014-02-09 23:00:08365 permanent_text_, false, true, current_page_classification_, &match, NULL);
[email protected]bb1fb2b2013-05-31 00:21:01366 match.is_history_what_you_typed_match = false;
[email protected]45f89a92013-08-12 13:41:36367 match.allowed_to_be_default_match = true;
[email protected]6ce7f612012-09-05 23:53:07368
[email protected]bb1fb2b2013-05-31 00:21:01369 // The placeholder suggestion for the current URL has high relevance so
370 // that it is in the first suggestion slot and inline autocompleted. It
371 // gets dropped as soon as the user types something.
[email protected]00404742014-02-20 13:09:05372 match.relevance = GetVerbatimRelevance();
[email protected]6ce7f612012-09-05 23:53:07373
[email protected]bb1fb2b2013-05-31 00:21:01374 return match;
[email protected]6ce7f612012-09-05 23:53:07375}
[email protected]00404742014-02-20 13:09:05376
377int ZeroSuggestProvider::GetVerbatimRelevance() const {
378 return results_.verbatim_relevance >= 0 ?
379 results_.verbatim_relevance : kDefaultVerbatimZeroSuggestRelevance;
380}
[email protected]162c8d9fa2014-03-18 20:25:41381
382bool ZeroSuggestProvider::CanShowZeroSuggestWithoutSendingURL(
383 const GURL& suggest_url,
384 const GURL& current_page_url) const {
385 if (!ZeroSuggestEnabled(suggest_url,
386 template_url_service_->GetDefaultSearchProvider(),
387 current_page_classification_, profile_))
388 return false;
389
390 // If we cannot send URLs, then only the MostVisited and Personalized
391 // variations can be shown.
392 if (!OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial() &&
393 !OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial())
394 return false;
395
396 // Only show zero suggest for HTTP[S] pages.
397 // TODO(mariakhomenko): We may be able to expand this set to include pages
398 // with other schemes (e.g. chrome://). That may require improvements to
399 // the formatting of the verbatim result returned by MatchForCurrentURL().
400 if (!current_page_url.is_valid() ||
401 ((current_page_url.scheme() != content::kHttpScheme) &&
402 (current_page_url.scheme() != content::kHttpsScheme)))
403 return false;
404
405 return true;
406}