Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / components / autofill / core / browser / autofill_experiments.cc
blobc43f5b43e6dc6c3ed9b0533020a145962e4df8e8
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 return pref_service->GetBoolean(prefs::kAutofillEnabled);
19 bool IsInAutofillSuggestionsDisabledExperiment() {
20 std::string group_name =
21 base::FieldTrialList::FindFullName("AutofillEnabled");
22 return group_name == "Disabled";
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