Commit 29c0bcc6 authored by Ce Chen's avatar Ce Chen Committed by Commit Bot

[omnibox] add a Finch flag to allow on device head suggest in incognito mode.

Bug: 925072
Change-Id: I8b9f355f33d95e7a35510eae8d5a671544f7fe6e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1784354Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: Ce Chen <cch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693927}
parent 1984cc5f
...@@ -680,6 +680,11 @@ bool OmniboxFieldTrial::IsOmniboxWrapPopupPositionEnabled() { ...@@ -680,6 +680,11 @@ bool OmniboxFieldTrial::IsOmniboxWrapPopupPositionEnabled() {
return base::FeatureList::IsEnabled(omnibox::kOmniboxWrapPopupPosition); return base::FeatureList::IsEnabled(omnibox::kOmniboxWrapPopupPosition);
} }
bool OmniboxFieldTrial::IsOnDeviceHeadProviderEnabledForIncognito() {
return base::GetFieldTrialParamByFeatureAsBool(omnibox::kOnDeviceHeadProvider,
"EnableForIncongnito", false);
}
const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] =
"OmniboxBundledExperimentV1"; "OmniboxBundledExperimentV1";
const char OmniboxFieldTrial::kDisableProvidersRule[] = "DisableProviders"; const char OmniboxFieldTrial::kDisableProvidersRule[] = "DisableProviders";
......
...@@ -421,6 +421,9 @@ bool IsMaxURLMatchesFeatureEnabled(); ...@@ -421,6 +421,9 @@ bool IsMaxURLMatchesFeatureEnabled();
// between top and bottom is enabled. // between top and bottom is enabled.
bool IsOmniboxWrapPopupPositionEnabled(); bool IsOmniboxWrapPopupPositionEnabled();
// Returns whether on device head provider is enabled for incognito mode.
bool IsOnDeviceHeadProviderEnabledForIncognito();
// --------------------------------------------------------- // ---------------------------------------------------------
// Clipboard URL suggestions: // Clipboard URL suggestions:
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "components/omnibox/browser/autocomplete_provider_listener.h" #include "components/omnibox/browser/autocomplete_provider_listener.h"
#include "components/omnibox/browser/base_search_provider.h" #include "components/omnibox/browser/base_search_provider.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/omnibox/browser/on_device_head_provider.h" #include "components/omnibox/browser/on_device_head_provider.h"
#include "components/omnibox/common/omnibox_features.h" #include "components/omnibox/common/omnibox_features.h"
#include "components/search_engines/search_terms_data.h" #include "components/search_engines/search_terms_data.h"
...@@ -103,8 +104,14 @@ bool OnDeviceHeadProvider::IsOnDeviceHeadProviderAllowed( ...@@ -103,8 +104,14 @@ bool OnDeviceHeadProvider::IsOnDeviceHeadProviderAllowed(
input.type() == metrics::OmniboxInputType::EMPTY) input.type() == metrics::OmniboxInputType::EMPTY)
return false; return false;
// Make sure search suggest is enabled and user is not in incognito. // Check whether search suggest is enabled.
if (client()->IsOffTheRecord() || !client()->SearchSuggestEnabled()) if (!client()->SearchSuggestEnabled())
return false;
// Make sure user is not in incognito, unless on device head provider is
// enabled for incognito.
if (client()->IsOffTheRecord() &&
!OmniboxFieldTrial::IsOnDeviceHeadProviderEnabledForIncognito())
return false; return false;
// Reject on focus request. // Reject on focus request.
......
...@@ -107,6 +107,7 @@ TEST_F(OnDeviceHeadProviderTest, RejectIncognito) { ...@@ -107,6 +107,7 @@ TEST_F(OnDeviceHeadProviderTest, RejectIncognito) {
input.set_want_asynchronous_matches(true); input.set_want_asynchronous_matches(true);
EXPECT_CALL(*client_.get(), IsOffTheRecord()).WillOnce(Return(true)); EXPECT_CALL(*client_.get(), IsOffTheRecord()).WillOnce(Return(true));
EXPECT_CALL(*client_.get(), SearchSuggestEnabled()).WillOnce(Return(true));
provider_->Start(input, false); provider_->Start(input, false);
if (!provider_->done()) if (!provider_->done())
......
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