Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / components / autofill / core / browser / autofill_experiments.cc
blob6d4ba03add2ee9f08d598ceb62600391bc6734b8
1 // Copyright 2015 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.
5 #include "components/autofill/core/browser/autofill_experiments.h"
7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h"
9 #include "base/prefs/pref_service.h"
10 #include "components/autofill/core/common/autofill_pref_names.h"
11 #include "components/autofill/core/common/autofill_switches.h"
13 namespace autofill {
15 bool IsAutofillEnabled(const PrefService* pref_service) {
16 std::string group_name =
17 base::FieldTrialList::FindFullName("AutofillEnabled");
18 if (group_name == "Disabled") // Assume enabled when no experiment.
19 return false;
21 // When experiment enables autofill, fall back on the user pref.
22 return pref_service->GetBoolean(prefs::kAutofillEnabled);
25 bool OfferStoreUnmaskedCards() {
26 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
27 // The checkbox can be forced on with a flag, but by default we don't store
28 // on Linux due to lack of system keychain integration. See crbug.com/162735
29 return base::CommandLine::ForCurrentProcess()->HasSwitch(
30 switches::kEnableOfferStoreUnmaskedWalletCards);
31 #else
32 // Query the field trial before checking command line flags to ensure UMA
33 // reports the correct group.
34 std::string group_name =
35 base::FieldTrialList::FindFullName("OfferStoreUnmaskedWalletCards");
37 // The checkbox can be forced on or off with flags.
38 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
39 switches::kEnableOfferStoreUnmaskedWalletCards))
40 return true;
41 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
42 switches::kDisableOfferStoreUnmaskedWalletCards))
43 return false;
45 // Otherwise use the field trial to show the checkbox or not.
46 return group_name != "Disabled";
47 #endif
50 } // namespace autofill