| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/autofill/core/browser/autofill_experiments.h" | 5 #include "components/autofill/core/browser/autofill_experiments.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "components/autofill/core/common/autofill_pref_names.h" | 13 #include "components/autofill/core/common/autofill_pref_names.h" |
| 14 #include "components/autofill/core/common/autofill_switches.h" | 14 #include "components/autofill/core/common/autofill_switches.h" |
| 15 #include "components/prefs/pref_service.h" | 15 #include "components/prefs/pref_service.h" |
| 16 #include "components/sync_driver/sync_service.h" | 16 #include "components/sync_driver/sync_service.h" |
| 17 #include "components/variations/variations_associated_data.h" | 17 #include "components/variations/variations_associated_data.h" |
| 18 #include "google_apis/gaia/gaia_auth_util.h" | 18 #include "google_apis/gaia/gaia_auth_util.h" |
| 19 | 19 |
| 20 namespace autofill { | 20 namespace autofill { |
| 21 | 21 |
| 22 const base::Feature kAutofillCreditCardAssist{ |
| 23 "AutofillCreditCardAssist", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 22 const base::Feature kAutofillProfileCleanup{"AutofillProfileCleanup", | 24 const base::Feature kAutofillProfileCleanup{"AutofillProfileCleanup", |
| 23 base::FEATURE_DISABLED_BY_DEFAULT}; | 25 base::FEATURE_DISABLED_BY_DEFAULT}; |
| 24 const base::Feature kAutofillCreditCardSigninPromo{ | 26 const base::Feature kAutofillCreditCardSigninPromo{ |
| 25 "AutofillCreditCardSigninPromo", base::FEATURE_DISABLED_BY_DEFAULT}; | 27 "AutofillCreditCardSigninPromo", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 26 const char kCreditCardSigninPromoImpressionLimitParamKey[] = "impression_limit"; | 28 const char kCreditCardSigninPromoImpressionLimitParamKey[] = "impression_limit"; |
| 27 | 29 |
| 28 bool IsAutofillEnabled(const PrefService* pref_service) { | 30 bool IsAutofillEnabled(const PrefService* pref_service) { |
| 29 return pref_service->GetBoolean(prefs::kAutofillEnabled); | 31 return pref_service->GetBoolean(prefs::kAutofillEnabled); |
| 30 } | 32 } |
| 31 | 33 |
| 32 bool IsInAutofillSuggestionsDisabledExperiment() { | 34 bool IsInAutofillSuggestionsDisabledExperiment() { |
| 33 std::string group_name = | 35 std::string group_name = |
| 34 base::FieldTrialList::FindFullName("AutofillEnabled"); | 36 base::FieldTrialList::FindFullName("AutofillEnabled"); |
| 35 return group_name == "Disabled"; | 37 return group_name == "Disabled"; |
| 36 } | 38 } |
| 37 | 39 |
| 38 bool IsAutofillProfileCleanupEnabled() { | 40 bool IsAutofillProfileCleanupEnabled() { |
| 39 return base::FeatureList::IsEnabled(kAutofillProfileCleanup); | 41 return base::FeatureList::IsEnabled(kAutofillProfileCleanup); |
| 40 } | 42 } |
| 41 | 43 |
| 42 bool IsAutofillCreditCardSigninPromoEnabled() { | 44 bool IsAutofillCreditCardSigninPromoEnabled() { |
| 43 return base::FeatureList::IsEnabled(kAutofillCreditCardSigninPromo); | 45 return base::FeatureList::IsEnabled(kAutofillCreditCardSigninPromo); |
| 44 } | 46 } |
| 45 | 47 |
| 48 bool IsAutofillCreditCardAssistEnabled() { |
| 49 return base::FeatureList::IsEnabled(kAutofillCreditCardAssist); |
| 50 } |
| 51 |
| 46 int GetCreditCardSigninPromoImpressionLimit() { | 52 int GetCreditCardSigninPromoImpressionLimit() { |
| 47 int impression_limit; | 53 int impression_limit; |
| 48 std::string param_value = variations::GetVariationParamValueByFeature( | 54 std::string param_value = variations::GetVariationParamValueByFeature( |
| 49 kAutofillCreditCardSigninPromo, | 55 kAutofillCreditCardSigninPromo, |
| 50 kCreditCardSigninPromoImpressionLimitParamKey); | 56 kCreditCardSigninPromoImpressionLimitParamKey); |
| 51 if (!param_value.empty() && base::StringToInt(param_value, &impression_limit)) | 57 if (!param_value.empty() && base::StringToInt(param_value, &impression_limit)) |
| 52 return impression_limit; | 58 return impression_limit; |
| 53 | 59 |
| 54 return 0; | 60 return 0; |
| 55 } | 61 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } | 129 } |
| 124 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 130 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 125 switches::kDisableOfferUploadCreditCards)) { | 131 switches::kDisableOfferUploadCreditCards)) { |
| 126 return false; | 132 return false; |
| 127 } | 133 } |
| 128 | 134 |
| 129 return !group_name.empty() && group_name != "Disabled"; | 135 return !group_name.empty() && group_name != "Disabled"; |
| 130 } | 136 } |
| 131 | 137 |
| 132 } // namespace autofill | 138 } // namespace autofill |
| OLD | NEW |