Skip to content

Commit

Permalink
Omnibox: Add Experiment Flag to Allow Zero Suggest on HTTPS Pages
Browse files Browse the repository at this point in the history
BUG=698301

Review-Url: https://codereview.chromium.org/2732473005
Cr-Commit-Position: refs/heads/master@{#454725}
  • Loading branch information
mpearson authored and Commit bot committed Mar 4, 2017
1 parent a9a7fa9 commit 780787a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
12 changes: 12 additions & 0 deletions chrome/browser/autocomplete/search_provider_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3226,6 +3226,18 @@ TEST_F(SearchProviderTest, CanSendURL) {
GURL("https://www.google.com/complete/search"), &google_template_url,
metrics::OmniboxEventProto::OTHER, SearchTermsData(), &client));

// Non-HTTP page URL on different domain, yet with feature flag to allow
// this turned on.
{
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(
omnibox::kSearchProviderContextAllowHttpsUrls);
EXPECT_TRUE(SearchProvider::CanSendURL(
GURL("https://www.notgoogle.com/search"),
GURL("https://www.google.com/complete/search"), &google_template_url,
metrics::OmniboxEventProto::OTHER, SearchTermsData(), &client));
}

// Non-HTTPS provider.
EXPECT_FALSE(SearchProvider::CanSendURL(
GURL("http://www.google.com/search"),
Expand Down
20 changes: 13 additions & 7 deletions components/omnibox/browser/base_search_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stddef.h>
#include <stdint.h>

#include "base/feature_list.h"
#include "base/i18n/case_conversion.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
Expand Down Expand Up @@ -337,13 +338,18 @@ bool BaseSearchProvider::CanSendURL(
if (!current_page_url.is_valid())
return false;

// Only allow HTTP URLs or HTTPS URLs for the same domain as the search
// provider.
if ((current_page_url.scheme() != url::kHttpScheme) &&
((current_page_url.scheme() != url::kHttpsScheme) ||
!net::registry_controlled_domains::SameDomainOrHost(
current_page_url, suggest_url,
net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES)))
// Only allow HTTP URLs or HTTPS URLs. For HTTPS URLs, require that either
// the appropriate feature flag is enabled or the URL is the same domain as
// the search provider.
const bool scheme_allowed =
(current_page_url.scheme() == url::kHttpScheme) ||
((current_page_url.scheme() == url::kHttpsScheme) &&
(base::FeatureList::IsEnabled(
omnibox::kSearchProviderContextAllowHttpsUrls) ||
net::registry_controlled_domains::SameDomainOrHost(
current_page_url, suggest_url,
net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES)));
if (!scheme_allowed)
return false;

if (!client->TabSyncEnabledAndUnencrypted())
Expand Down
7 changes: 7 additions & 0 deletions components/omnibox/browser/omnibox_field_trial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ const base::Feature kEnableClipboardProvider {
const base::Feature kSearchProviderWarmUpOnFocus{
"OmniboxWarmUpSearchProviderOnFocus", base::FEATURE_DISABLED_BY_DEFAULT};

// Feature used to enable the transmission of HTTPS URLs as part of the
// context to the suggest server (assuming SearchProvider is permitted to
// transmit URLs for context in the first place).
const base::Feature kSearchProviderContextAllowHttpsUrls{
"OmniboixSearchProviderContextAllowHttpsUrls",
base::FEATURE_DISABLED_BY_DEFAULT};

} // namespace omnibox

namespace {
Expand Down
1 change: 1 addition & 0 deletions components/omnibox/browser/omnibox_field_trial.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern const base::Feature kNewOmniboxAnswerTypes;
extern const base::Feature kOmniboxEntitySuggestions;
extern const base::Feature kEnableClipboardProvider;
extern const base::Feature kSearchProviderWarmUpOnFocus;
extern const base::Feature kSearchProviderContextAllowHttpsUrls;
}

// The set of parameters customizing the HUP scoring.
Expand Down

0 comments on commit 780787a

Please sign in to comment.