blob: 47251fb55a1d8c31d06d2c56d8077a53fc7ade45 [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/http/http_response_headers.h"
41#include "net/url_request/url_fetcher.h"
42#include "net/url_request/url_request_status.h"
[email protected]761fa4702013-07-02 15:25:1543#include "url/gurl.h"
[email protected]6ce7f612012-09-05 23:53:0744
45namespace {
[email protected]bb1fb2b2013-05-31 00:21:0146
47// TODO(hfung): The histogram code was copied and modified from
48// search_provider.cc. Refactor and consolidate the code.
49// We keep track in a histogram how many suggest requests we send, how
50// many suggest requests we invalidate (e.g., due to a user typing
51// another character), and how many replies we receive.
52// *** ADD NEW ENUMS AFTER ALL PREVIOUSLY DEFINED ONES! ***
53// (excluding the end-of-list enum value)
54// We do not want values of existing enums to change or else it screws
55// up the statistics.
56enum ZeroSuggestRequestsHistogramValue {
57 ZERO_SUGGEST_REQUEST_SENT = 1,
58 ZERO_SUGGEST_REQUEST_INVALIDATED,
59 ZERO_SUGGEST_REPLY_RECEIVED,
60 ZERO_SUGGEST_MAX_REQUEST_HISTOGRAM_VALUE
61};
62
63void LogOmniboxZeroSuggestRequest(
64 ZeroSuggestRequestsHistogramValue request_value) {
65 UMA_HISTOGRAM_ENUMERATION("Omnibox.ZeroSuggestRequests", request_value,
66 ZERO_SUGGEST_MAX_REQUEST_HISTOGRAM_VALUE);
67}
68
69// The maximum relevance of the top match from this provider.
70const int kDefaultVerbatimZeroSuggestRelevance = 1300;
71
72// Relevance value to use if it was not set explicitly by the server.
73const int kDefaultZeroSuggestRelevance = 100;
74
[email protected]6ce7f612012-09-05 23:53:0775} // namespace
76
[email protected]a00008d42012-09-15 05:07:5877// static
78ZeroSuggestProvider* ZeroSuggestProvider::Create(
79 AutocompleteProviderListener* listener,
80 Profile* profile) {
[email protected]bb1fb2b2013-05-31 00:21:0181 return new ZeroSuggestProvider(listener, profile);
[email protected]6ce7f612012-09-05 23:53:0782}
83
[email protected]6ce7f612012-09-05 23:53:0784void ZeroSuggestProvider::Start(const AutocompleteInput& input,
85 bool /*minimal_changes*/) {
[email protected]bb1fb2b2013-05-31 00:21:0186}
87
[email protected]bb1fb2b2013-05-31 00:21:0188void ZeroSuggestProvider::ResetSession() {
89 // The user has started editing in the omnibox, so leave
90 // |field_trial_triggered_in_session_| unchanged and set
91 // |field_trial_triggered_| to false since zero suggest is inactive now.
92 field_trial_triggered_ = false;
[email protected]162c8d9fa2014-03-18 20:25:4193
94 // This call clears out |matches_| so that they don't pollute prefix-based
95 // queries.
96 // TODO(mariakhomenko): Change the model to clear |matches_| on Start() like
97 // all the other providers.
[email protected]9c97f89c2013-06-25 03:12:1698 Stop(true);
[email protected]bb1fb2b2013-05-31 00:21:0199}
100
101void ZeroSuggestProvider::OnURLFetchComplete(const net::URLFetcher* source) {
102 have_pending_request_ = false;
103 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REPLY_RECEIVED);
104
105 std::string json_data;
106 source->GetResponseAsString(&json_data);
107 const bool request_succeeded =
108 source->GetStatus().is_success() && source->GetResponseCode() == 200;
109
[email protected]bb1fb2b2013-05-31 00:21:01110 if (request_succeeded) {
[email protected]843e4afb2014-02-07 23:11:03111 scoped_ptr<base::Value> data(DeserializeJsonData(json_data));
[email protected]8f064e52013-09-18 01:17:14112 if (data.get())
[email protected]d4a94b92014-03-04 01:35:22113 ParseSuggestResults(*data.get(), false, &results_);
[email protected]bb1fb2b2013-05-31 00:21:01114 }
115 done_ = true;
116
[email protected]8f064e52013-09-18 01:17:14117 ConvertResultsToAutocompleteMatches();
118 if (!matches_.empty())
[email protected]bb1fb2b2013-05-31 00:21:01119 listener_->OnProviderUpdate(true);
[email protected]6ce7f612012-09-05 23:53:07120}
121
[email protected]25d7e742013-07-30 17:31:06122void ZeroSuggestProvider::StartZeroSuggest(
[email protected]9b9fa672013-11-07 06:04:52123 const GURL& current_page_url,
[email protected]25d7e742013-07-30 17:31:06124 AutocompleteInput::PageClassification page_classification,
[email protected]96920152013-12-04 21:00:16125 const base::string16& permanent_text) {
[email protected]bb1fb2b2013-05-31 00:21:01126 Stop(true);
127 field_trial_triggered_ = false;
128 field_trial_triggered_in_session_ = false;
[email protected]9b9fa672013-11-07 06:04:52129 permanent_text_ = permanent_text;
130 current_query_ = current_page_url.spec();
131 current_page_classification_ = page_classification;
132 current_url_match_ = MatchForCurrentURL();
133
134 const TemplateURL* default_provider =
135 template_url_service_->GetDefaultSearchProvider();
136 if (default_provider == NULL)
137 return;
[email protected]162c8d9fa2014-03-18 20:25:41138
[email protected]96920152013-12-04 21:00:16139 base::string16 prefix;
[email protected]9b9fa672013-11-07 06:04:52140 TemplateURLRef::SearchTermsArgs search_term_args(prefix);
[email protected]162c8d9fa2014-03-18 20:25:41141 GURL suggest_url(default_provider->suggestions_url_ref().ReplaceSearchTerms(
142 search_term_args));
143 if (!suggest_url.is_valid())
[email protected]6ce7f612012-09-05 23:53:07144 return;
[email protected]162c8d9fa2014-03-18 20:25:41145
146 // No need to send the current page URL in personalized suggest field trial.
147 if (CanSendURL(current_page_url, suggest_url, default_provider,
148 current_page_classification_, profile_) &&
149 !OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial()) {
150 // Update suggest_url to include the current_page_url.
151 search_term_args.current_page_url = current_query_;
152 suggest_url = GURL(default_provider->suggestions_url_ref().
153 ReplaceSearchTerms(search_term_args));
154 } else if (!CanShowZeroSuggestWithoutSendingURL(suggest_url,
155 current_page_url)) {
156 return;
157 }
158
[email protected]6ce7f612012-09-05 23:53:07159 done_ = false;
[email protected]6ce7f612012-09-05 23:53:07160 // TODO(jered): Consider adding locally-sourced zero-suggestions here too.
161 // These may be useful on the NTP or more relevant to the user than server
162 // suggestions, if based on local browsing history.
[email protected]9b9fa672013-11-07 06:04:52163 Run(suggest_url);
[email protected]6ce7f612012-09-05 23:53:07164}
165
[email protected]bb1fb2b2013-05-31 00:21:01166ZeroSuggestProvider::ZeroSuggestProvider(
167 AutocompleteProviderListener* listener,
168 Profile* profile)
[email protected]02346202014-02-05 05:18:30169 : BaseSearchProvider(listener, profile,
170 AutocompleteProvider::TYPE_ZERO_SUGGEST),
[email protected]bb1fb2b2013-05-31 00:21:01171 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)),
[email protected]bb1fb2b2013-05-31 00:21:01172 have_pending_request_(false),
[email protected]8f064e52013-09-18 01:17:14173 weak_ptr_factory_(this) {
[email protected]6ce7f612012-09-05 23:53:07174}
175
176ZeroSuggestProvider::~ZeroSuggestProvider() {
177}
178
[email protected]9487b392014-02-14 02:48:18179const TemplateURL* ZeroSuggestProvider::GetTemplateURL(
180 const SuggestResult& result) const {
181 // Zero suggest provider should not receive keyword results.
182 DCHECK(!result.from_keyword_provider());
183 return template_url_service_->GetDefaultSearchProvider();
184}
185
[email protected]d4a94b92014-03-04 01:35:22186const AutocompleteInput ZeroSuggestProvider::GetInput(bool is_keyword) const {
187 return AutocompleteInput(
188 base::string16(), base::string16::npos, base::string16(),
189 GURL(current_query_), current_page_classification_, true, false, false,
190 AutocompleteInput::ALL_MATCHES);
[email protected]9487b392014-02-14 02:48:18191}
192
193bool ZeroSuggestProvider::ShouldAppendExtraParams(
194 const SuggestResult& result) const {
195 // We always use the default provider for search, so append the params.
196 return true;
197}
198
[email protected]ef6866f2014-02-18 08:26:34199void ZeroSuggestProvider::StopSuggest() {
200 if (have_pending_request_)
201 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_INVALIDATED);
202 have_pending_request_ = false;
203 fetcher_.reset();
204}
205
206void ZeroSuggestProvider::ClearAllResults() {
[email protected]00404742014-02-20 13:09:05207 // We do not call Clear() on |results_| to retain |verbatim_relevance|
208 // value in the |results_| object. |verbatim_relevance| is used at the
209 // beginning of the next StartZeroSuggest() call to determine the current url
210 // match relevance.
211 results_.suggest_results.clear();
212 results_.navigation_results.clear();
[email protected]ef6866f2014-02-18 08:26:34213 current_query_.clear();
214 matches_.clear();
215}
216
[email protected]d4a94b92014-03-04 01:35:22217int ZeroSuggestProvider::GetDefaultResultRelevance() const {
218 return kDefaultZeroSuggestRelevance;
219}
220
[email protected]0cfddf1b2014-03-12 01:46:00221void ZeroSuggestProvider::RecordDeletionResult(bool success) {
222 if (success) {
223 content::RecordAction(
224 base::UserMetricsAction("Omnibox.ZeroSuggestDelete.Success"));
225 } else {
226 content::RecordAction(
227 base::UserMetricsAction("Omnibox.ZeroSuggestDelete.Failure"));
228 }
229}
230
[email protected]bb1fb2b2013-05-31 00:21:01231void ZeroSuggestProvider::AddSuggestResultsToMap(
[email protected]02346202014-02-05 05:18:30232 const SuggestResults& results,
[email protected]02346202014-02-05 05:18:30233 MatchMap* map) {
[email protected]d4a94b92014-03-04 01:35:22234 for (size_t i = 0; i < results.size(); ++i)
[email protected]57482a72014-03-14 22:27:37235 AddMatchToMap(results[i], std::string(), i, false, map);
[email protected]bb1fb2b2013-05-31 00:21:01236}
237
[email protected]bb1fb2b2013-05-31 00:21:01238AutocompleteMatch ZeroSuggestProvider::NavigationToMatch(
[email protected]02346202014-02-05 05:18:30239 const NavigationResult& navigation) {
[email protected]bb1fb2b2013-05-31 00:21:01240 AutocompleteMatch match(this, navigation.relevance(), false,
241 AutocompleteMatchType::NAVSUGGEST);
242 match.destination_url = navigation.url();
243
[email protected]23db6492014-01-16 02:35:30244 // Zero suggest results should always omit protocols and never appear bold.
[email protected]bb1fb2b2013-05-31 00:21:01245 const std::string languages(
246 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
247 match.contents = net::FormatUrl(navigation.url(), languages,
248 net::kFormatUrlOmitAll, net::UnescapeRule::SPACES, NULL, NULL, NULL);
249 match.fill_into_edit +=
250 AutocompleteInput::FormattedStringWithEquivalentMeaning(navigation.url(),
251 match.contents);
[email protected]bb1fb2b2013-05-31 00:21:01252
[email protected]b959d7d42013-12-13 17:26:37253 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0,
[email protected]bb1fb2b2013-05-31 00:21:01254 match.contents.length(), ACMatchClassification::URL,
255 &match.contents_class);
[email protected]9c97f89c2013-06-25 03:12:16256
257 match.description =
258 AutocompleteMatch::SanitizeString(navigation.description());
[email protected]b959d7d42013-12-13 17:26:37259 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0,
[email protected]9c97f89c2013-06-25 03:12:16260 match.description.length(), ACMatchClassification::NONE,
261 &match.description_class);
[email protected]bb1fb2b2013-05-31 00:21:01262 return match;
263}
264
[email protected]9b9fa672013-11-07 06:04:52265void ZeroSuggestProvider::Run(const GURL& suggest_url) {
[email protected]bb1fb2b2013-05-31 00:21:01266 have_pending_request_ = false;
267 const int kFetcherID = 1;
[email protected]bb1fb2b2013-05-31 00:21:01268 fetcher_.reset(
269 net::URLFetcher::Create(kFetcherID,
270 suggest_url,
271 net::URLFetcher::GET, this));
272 fetcher_->SetRequestContext(profile_->GetRequestContext());
273 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
274 // Add Chrome experiment state to the request headers.
275 net::HttpRequestHeaders headers;
276 chrome_variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders(
277 fetcher_->GetOriginalURL(), profile_->IsOffTheRecord(), false, &headers);
278 fetcher_->SetExtraRequestHeaders(headers.ToString());
279
280 fetcher_->Start();
[email protected]8f064e52013-09-18 01:17:14281
282 if (OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial()) {
283 most_visited_urls_.clear();
284 history::TopSites* ts = profile_->GetTopSites();
285 if (ts) {
286 ts->GetMostVisitedURLs(
287 base::Bind(&ZeroSuggestProvider::OnMostVisitedUrlsAvailable,
[email protected]ce767ab22013-11-12 03:50:09288 weak_ptr_factory_.GetWeakPtr()), false);
[email protected]8f064e52013-09-18 01:17:14289 }
290 }
[email protected]bb1fb2b2013-05-31 00:21:01291 have_pending_request_ = true;
292 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT);
293}
294
[email protected]8f064e52013-09-18 01:17:14295void ZeroSuggestProvider::OnMostVisitedUrlsAvailable(
296 const history::MostVisitedURLList& urls) {
297 most_visited_urls_ = urls;
298}
299
[email protected]9c97f89c2013-06-25 03:12:16300void ZeroSuggestProvider::ConvertResultsToAutocompleteMatches() {
[email protected]bb1fb2b2013-05-31 00:21:01301 matches_.clear();
302
303 const TemplateURL* default_provider =
[email protected]6ce7f612012-09-05 23:53:07304 template_url_service_->GetDefaultSearchProvider();
305 // Fail if we can't set the clickthrough URL for query suggestions.
[email protected]bb1fb2b2013-05-31 00:21:01306 if (default_provider == NULL || !default_provider->SupportsReplacement())
[email protected]6ce7f612012-09-05 23:53:07307 return;
[email protected]6ce7f612012-09-05 23:53:07308
[email protected]00404742014-02-20 13:09:05309 MatchMap map;
310 AddSuggestResultsToMap(results_.suggest_results, &map);
311
312 const int num_query_results = map.size();
313 const int num_nav_results = results_.navigation_results.size();
[email protected]bb1fb2b2013-05-31 00:21:01314 const int num_results = num_query_results + num_nav_results;
[email protected]9c97f89c2013-06-25 03:12:16315 UMA_HISTOGRAM_COUNTS("ZeroSuggest.QueryResults", num_query_results);
316 UMA_HISTOGRAM_COUNTS("ZeroSuggest.URLResults", num_nav_results);
317 UMA_HISTOGRAM_COUNTS("ZeroSuggest.AllResults", num_results);
[email protected]bb1fb2b2013-05-31 00:21:01318
[email protected]8f064e52013-09-18 01:17:14319 // Show Most Visited results after ZeroSuggest response is received.
320 if (OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial()) {
[email protected]3feb8b002013-10-14 23:50:13321 if (!current_url_match_.destination_url.is_valid())
322 return;
[email protected]8f064e52013-09-18 01:17:14323 matches_.push_back(current_url_match_);
324 int relevance = 600;
325 if (num_results > 0) {
326 UMA_HISTOGRAM_COUNTS(
327 "Omnibox.ZeroSuggest.MostVisitedResultsCounterfactual",
328 most_visited_urls_.size());
329 }
[email protected]23db6492014-01-16 02:35:30330 const base::string16 current_query_string16(
331 base::ASCIIToUTF16(current_query_));
332 const std::string languages(
333 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
[email protected]8f064e52013-09-18 01:17:14334 for (size_t i = 0; i < most_visited_urls_.size(); i++) {
335 const history::MostVisitedURL& url = most_visited_urls_[i];
[email protected]02346202014-02-05 05:18:30336 NavigationResult nav(*this, url.url, url.title, false, relevance, true,
[email protected]23db6492014-01-16 02:35:30337 current_query_string16, languages);
[email protected]8f064e52013-09-18 01:17:14338 matches_.push_back(NavigationToMatch(nav));
339 --relevance;
340 }
341 return;
342 }
343
[email protected]9c97f89c2013-06-25 03:12:16344 if (num_results == 0)
[email protected]bb1fb2b2013-05-31 00:21:01345 return;
346
347 // TODO(jered): Rip this out once the first match is decoupled from the
348 // current typing in the omnibox.
[email protected]bb1fb2b2013-05-31 00:21:01349 matches_.push_back(current_url_match_);
350
[email protected]00404742014-02-20 13:09:05351 for (MatchMap::const_iterator it(map.begin()); it != map.end(); ++it)
[email protected]bb1fb2b2013-05-31 00:21:01352 matches_.push_back(it->second);
[email protected]bb1fb2b2013-05-31 00:21:01353
[email protected]00404742014-02-20 13:09:05354 const NavigationResults& nav_results(results_.navigation_results);
355 for (NavigationResults::const_iterator it(nav_results.begin());
356 it != nav_results.end(); ++it)
[email protected]bb1fb2b2013-05-31 00:21:01357 matches_.push_back(NavigationToMatch(*it));
[email protected]6ce7f612012-09-05 23:53:07358}
359
[email protected]bb1fb2b2013-05-31 00:21:01360AutocompleteMatch ZeroSuggestProvider::MatchForCurrentURL() {
[email protected]96920152013-12-04 21:00:16361 AutocompleteInput input(permanent_text_, base::string16::npos, base::string16(),
[email protected]25d7e742013-07-30 17:31:06362 GURL(current_query_), current_page_classification_,
[email protected]bb1fb2b2013-05-31 00:21:01363 false, false, true, AutocompleteInput::ALL_MATCHES);
[email protected]6ce7f612012-09-05 23:53:07364
[email protected]2d915782013-08-29 09:50:21365 AutocompleteMatch match;
366 AutocompleteClassifierFactory::GetForProfile(profile_)->Classify(
[email protected]51abb7b2014-02-09 23:00:08367 permanent_text_, false, true, current_page_classification_, &match, NULL);
[email protected]bb1fb2b2013-05-31 00:21:01368 match.is_history_what_you_typed_match = false;
[email protected]45f89a92013-08-12 13:41:36369 match.allowed_to_be_default_match = true;
[email protected]6ce7f612012-09-05 23:53:07370
[email protected]bb1fb2b2013-05-31 00:21:01371 // The placeholder suggestion for the current URL has high relevance so
372 // that it is in the first suggestion slot and inline autocompleted. It
373 // gets dropped as soon as the user types something.
[email protected]00404742014-02-20 13:09:05374 match.relevance = GetVerbatimRelevance();
[email protected]6ce7f612012-09-05 23:53:07375
[email protected]bb1fb2b2013-05-31 00:21:01376 return match;
[email protected]6ce7f612012-09-05 23:53:07377}
[email protected]00404742014-02-20 13:09:05378
379int ZeroSuggestProvider::GetVerbatimRelevance() const {
380 return results_.verbatim_relevance >= 0 ?
381 results_.verbatim_relevance : kDefaultVerbatimZeroSuggestRelevance;
382}
[email protected]162c8d9fa2014-03-18 20:25:41383
384bool ZeroSuggestProvider::CanShowZeroSuggestWithoutSendingURL(
385 const GURL& suggest_url,
386 const GURL& current_page_url) const {
387 if (!ZeroSuggestEnabled(suggest_url,
388 template_url_service_->GetDefaultSearchProvider(),
389 current_page_classification_, profile_))
390 return false;
391
392 // If we cannot send URLs, then only the MostVisited and Personalized
393 // variations can be shown.
394 if (!OmniboxFieldTrial::InZeroSuggestMostVisitedFieldTrial() &&
395 !OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial())
396 return false;
397
398 // Only show zero suggest for HTTP[S] pages.
399 // TODO(mariakhomenko): We may be able to expand this set to include pages
400 // with other schemes (e.g. chrome://). That may require improvements to
401 // the formatting of the verbatim result returned by MatchForCurrentURL().
402 if (!current_page_url.is_valid() ||
403 ((current_page_url.scheme() != content::kHttpScheme) &&
404 (current_page_url.scheme() != content::kHttpsScheme)))
405 return false;
406
407 return true;
408}