Commit 8037d06a authored by marq's avatar marq Committed by Commit bot

Remove Finch config control for contextual search.

BUG=679349

Review-Url: https://codereview.chromium.org/2627663002
Cr-Commit-Position: refs/heads/master@{#442847}
parent def63444
......@@ -42,9 +42,8 @@ typedef NS_ENUM(NSInteger, TouchToSearchPreferenceState) {
// Touch-to-Search feature.
@interface TouchToSearchPermissionsMediator : NSObject
// YES if the device supports Touch-to-Search (based on command line flags and
// Finch experiments). The return value will be the same over the lifetime of
// a Chrome process.
// YES if the device supports Touch-to-Search (based on command line flags). The
// return value will be the same over the lifetime of a Chrome process.
+ (BOOL)isTouchToSearchAvailableOnDevice;
// Designated initializer.
......
......@@ -9,7 +9,6 @@
#include "base/command_line.h"
#import "base/ios/weak_nsobject.h"
#include "base/logging.h"
#include "base/metrics/field_trial.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h"
#include "components/search_engines/template_url_service.h"
......@@ -24,9 +23,6 @@
#include "net/base/network_change_notifier.h"
namespace {
// Field trial constants.
const char kContextualSearchFieldTrialName[] = "ContextualSearchIOS";
const char kContextualSearchFieldTrialEnabled[] = "Enabled";
// Maps pref string values to state enum.
const struct {
const char* value;
......@@ -68,22 +64,25 @@ const struct {
@synthesize observing = _observing;
+ (BOOL)isTouchToSearchAvailableOnDevice {
// If the disable flag is flipped, the feature isn't available.
// If the enable flag is flipped, it's available.
// If the browser is in the field trial, it's available.
BOOL available = NO;
// By default the feature is not available. If the enable flag
// (switches::kEnableContextualSearch) is flipped, then it is available.
// The disable switch (switches::kDisableContextualSearch) is also supported,
// although it is only useful when Finch experiments are also supported.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableContextualSearch)) {
// If both enable and disable flags are present, disable wins.
return NO;
} else if (base::CommandLine::ForCurrentProcess()->HasSwitch(
}
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableContextualSearch)) {
available = YES;
} else {
available =
base::FieldTrialList::FindFullName(kContextualSearchFieldTrialName) ==
kContextualSearchFieldTrialEnabled;
// Even if the command line flag is flipped, don't enable the feature if
// test hooks disable it.
return !tests_hook::DisableContextualSearch();
}
return available && !tests_hook::DisableContextualSearch();
return NO;
}
- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState {
......
......@@ -555,11 +555,14 @@ TEST(TouchToSearchPermissionsAvailabilityTest, CommandLinePermissions) {
}
TEST(TouchToSearchPermissionsAvailabilityTest, FieldTrial) {
// Field trial support is not currently supported, so it is expected
// that under all field trial configs, the feature will remain disabled.
// If field trial support is added back in, this test should be updated.
const struct {
const std::string trial_group_name;
bool expect_available;
} tests[] = {
{"Enabled", true},
{"Enabled", false},
{"Disabled", false},
{"Control", false},
{"Spadoinkle", false},
......
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