chromium/components/commerce/core/commerce_feature_list.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/commerce/core/commerce_feature_list.h"

#include <unordered_map>
#include <unordered_set>

#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "base/no_destructor.h"
#include "base/strings/string_util.h"
#include "base/values.h"
#include "build/buildflag.h"
#if !BUILDFLAG(IS_ANDROID)
#include "components/commerce/core/commerce_heuristics_data.h"
#endif  // !BUILDFLAG(IS_ANDROID)
#include "components/commerce/core/commerce_heuristics_data_metrics_helper.h"
#include "components/commerce/core/pref_names.h"
#include "third_party/re2/src/re2/re2.h"

namespace commerce {

namespace {

CountryLocaleMap;

// Get a map of enabled countries to the set of allowed locales for that
// country on a per-feature basis. Just because a locale is enabled for one
// country doesn't mean it can or should be enabled in others. The checks using
// this map should convert all countries and locales to lower case as they may
// differ depending on the API used to access them.
const CountryLocaleMap& GetAllowedCountryToLocaleMap() {}

constexpr base::FeatureParam<std::string> kRulePartnerMerchantPattern{};

constexpr base::FeatureParam<std::string> kCouponPartnerMerchantPattern{};

const re2::RE2& GetRulePartnerMerchantPattern() {}

const re2::RE2& GetCouponPartnerMerchantPattern() {}

}  // namespace

namespace switches {
// Specifies whether ChromeCart is enabled.
const char kEnableChromeCart[] =;
}  // namespace switches

BASE_FEATURE();

BASE_FEATURE();

BASE_FEATURE();

BASE_FEATURE();

BASE_FEATURE();

BASE_FEATURE();
#if BUILDFLAG(IS_ANDROID)
BASE_FEATURE(kCommerceMerchantViewerRegionLaunched,
             "CommerceMerchantViewerRegionLaunched",
             base::FEATURE_ENABLED_BY_DEFAULT);
#else
BASE_FEATURE();
#endif  // BUILDFLAG(IS_ANDROID)

BASE_FEATURE();

BASE_FEATURE();

#if BUILDFLAG(IS_ANDROID)
BASE_FEATURE(kCommercePriceTrackingRegionLaunched,
             "CommercePriceTrackingRegionLaunched",
             base::FEATURE_ENABLED_BY_DEFAULT);
#else
BASE_FEATURE();
#endif  // BUILDFLAG(IS_ANDROID)

BASE_FEATURE();
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || \
    BUILDFLAG(IS_CHROMEOS)
BASE_FEATURE();
#else
BASE_FEATURE(kPriceInsightsRegionLaunched,
             "PriceInsightsRegionLaunched",
             base::FEATURE_DISABLED_BY_DEFAULT);
#endif
const char kPriceInsightsDelayChipParam[] =;
const base::FeatureParam<bool> kPriceInsightsDelayChip{};
const char kPriceInsightsChipLabelExpandOnHighPriceParam[] =;
const base::FeatureParam<bool> kPriceInsightsChipLabelExpandOnHighPrice{};
const char kPriceInsightsShowFeedbackParam[] =;
const base::FeatureParam<bool> kPriceInsightsShowFeedback{};
const char kPriceInsightsUseCacheParam[] =;
const base::FeatureParam<bool> kPriceInsightsUseCache{};
const char kProductSpecsMigrateToMultiSpecificsParam[] =;
const base::FeatureParam<bool> kProductSpecsMigrateToMultiSpecifics{};

// Tonal colors for the expanded state of the price tracking chip on desktop.
BASE_FEATURE();

// Promotion in Magic Stack for Price Tracking users from other platforms.
BASE_FEATURE();

BASE_FEATURE();

// Sync title (in addition to all other attributes) in
// ProductComparisonSpecifics.
BASE_FEATURE();

// Kill switch for unsupported fields becoming supported in the event of a
// browser upgrade.
BASE_FEATURE();

// Stores Product Specifications across multiple specifics instead of one.
BASE_FEATURE();

BASE_FEATURE();

// Discount on navigation
BASE_FEATURE();

const char kDiscountOnShoppyPageParam[] =;
const base::FeatureParam<bool> kDiscountOnShoppyPage{};

#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX) || \
    BUILDFLAG(IS_CHROMEOS)
BASE_FEATURE();
#else
BASE_FEATURE(kEnableDiscountInfoApiRegionLaunched,
             "EnableDiscountInfoApiRegionLaunched",
             base::FEATURE_DISABLED_BY_DEFAULT);
#endif

BASE_FEATURE();
const char kHistoryClustersBehaviorParam[] =;
const base::FeatureParam<int> kHistoryClustersBehavior{};
const char kMerchantWideBehaviorParam[] =;
const base::FeatureParam<int> kMerchantWideBehavior{};
const char kNonMerchantWideBehaviorParam[] =;
const base::FeatureParam<int> kNonMerchantWideBehavior{};

BASE_FEATURE();

const base::FeatureParam<bool> kDeleteAllMerchantsOnClearBrowsingHistory{};

BASE_FEATURE();
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || \
    BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_IOS)
BASE_FEATURE();
#else
BASE_FEATURE(kShoppingListRegionLaunched,
             "ShoppingListRegionLaunched",
             base::FEATURE_DISABLED_BY_DEFAULT);
#endif

BASE_FEATURE();

BASE_FEATURE();

BASE_FEATURE();

BASE_FEATURE();

#if BUILDFLAG(IS_IOS)
BASE_FEATURE(kPriceInsightsIos,
             "PriceInsightsIos",
             base::FEATURE_DISABLED_BY_DEFAULT);

BASE_FEATURE(kPriceInsightsHighPriceIos,
             "PriceInsightsHighPrice",
             base::FEATURE_DISABLED_BY_DEFAULT);
#endif

BASE_FEATURE();

BASE_FEATURE();

BASE_FEATURE();

BASE_FEATURE();

const char kRetailCouponsWithCodeParam[] =;

// Params use for Discount Consent v2.
BASE_FEATURE();

BASE_FEATURE();

BASE_FEATURE();

BASE_FEATURE();

BASE_FEATURE();
BASE_FEATURE();
BASE_FEATURE();

const char kParcelTrackingTestDataParam[] =;
const char kParcelTrackingTestDataParamDelivered[] =;
const char kParcelTrackingTestDataParamInProgress[] =;
const char kParcelTrackingTestDataParamOutForDelivery[] =;

// Params for Discount Consent V2 in the NTP Cart module.
const char kNtpChromeCartModuleDiscountConsentNtpVariationParam[] =;
const base::FeatureParam<int> kNtpChromeCartModuleDiscountConsentNtpVariation{};
const char kNtpChromeCartModuleDiscountConsentReshowTimeParam[] =;
const base::FeatureParam<base::TimeDelta>
    kNtpChromeCartModuleDiscountConsentReshowTime{};
const char kNtpChromeCartModuleDiscountConsentMaxDismissalCountParam[] =;
const base::FeatureParam<int>
    kNtpChromeCartModuleDiscountConsentMaxDismissalCount{};

// String change variation params.
const char kNtpChromeCartModuleDiscountConsentStringChangeContentParam[] =;
const base::FeatureParam<std::string>
    kNtpChromeCartModuleDiscountConsentStringChangeContent{};

const char kNtpChromeCartModuleDiscountConsentInlineShowCloseButtonParam[] =;
const base::FeatureParam<bool>
    kNtpChromeCartModuleDiscountConsentInlineShowCloseButton{};

// Discount consent v2 step 1 params.
const char
    kNtpChromeCartModuleDiscountConsentNtpStepOneUseStaticContentParam[] =;
const base::FeatureParam<bool>
    kNtpChromeCartModuleDiscountConsentNtpStepOneUseStaticContent{};
const char kNtpChromeCartModuleDiscountConsentNtpStepOneStaticContentParam[] =;
const base::FeatureParam<std::string>
    kNtpChromeCartModuleDiscountConsentNtpStepOneStaticContent{};
const char kNtpChromeCartModuleDiscountConsentNtpStepOneContentOneCartParam[] =;
const base::FeatureParam<std::string>
    kNtpChromeCartModuleDiscountConsentNtpStepOneContentOneCart{};
const char kNtpChromeCartModuleDiscountConsentNtpStepOneContentTwoCartsParam[] =;
const base::FeatureParam<std::string>
    kNtpChromeCartModuleDiscountConsentNtpStepOneContentTwoCarts{};
const char
    kNtpChromeCartModuleDiscountConsentNtpStepOneContentThreeCartsParam[] =;
const base::FeatureParam<std::string>
    kNtpChromeCartModuleDiscountConsentNtpStepOneContentThreeCarts{};

// Discount consent v2 step 2 params.
const char kNtpChromeCartModuleDiscountConsentNtpStepTwoContentParam[] =;
const base::FeatureParam<std::string>
    kNtpChromeCartModuleDiscountConsentNtpStepTwoContent{};
const char
    kNtpChromeCartModuleDiscountConsentInlineStepTwoDifferentColorParam[] =;
const base::FeatureParam<bool>
    kNtpChromeCartModuleDiscountConsentInlineStepTwoDifferentColor{};
const char kNtpChromeCartModuleDiscountConsentNtpDialogContentTitleParam[] =;
const base::FeatureParam<std::string>
    kNtpChromeCartModuleDiscountConsentNtpDialogContentTitle{};

const char kContextualConsentShowOnCartAndCheckoutPageParam[] =;
const base::FeatureParam<bool> kContextualConsentShowOnCartAndCheckoutPage{};
const char kContextualConsentShowOnSRPParam[] =;
const base::FeatureParam<bool> kContextualConsentShowOnSRP{};

const char kCommerceHintAndroidHeuristicsImprovementParam[] =;

const char kCodeBasedRuleDiscountParam[] =;
const base::FeatureParam<bool> kCodeBasedRuleDiscount{};
const char kCodeBasedRuleDiscountCouponDeletionTimeParam[] =;
const base::FeatureParam<base::TimeDelta>
    kCodeBasedRuleDiscountCouponDeletionTime{};

const char kProductSpecificationsSetValidForClusteringTimeParam[] =;
const base::FeatureParam<base::TimeDelta>
    kProductSpecificationsSetValidForClusteringTime{};
const char kProductSpecificationsUseServerClusteringParam[] =;
const base::FeatureParam<bool> kProductSpecificationsUseServerClustering{};
const char kProductSpecificationsEnableQualityLoggingParam[] =;
const base::FeatureParam<bool> kProductSpecificationsEnableQualityLogging{};

const char kRevertIconOnFailureParam[] =;
const base::FeatureParam<bool> kRevertIconOnFailure{};

bool IsPartnerMerchant(const GURL& url) {}

bool IsRuleDiscountPartnerMerchant(const GURL& url) {}

bool IsCouponDiscountPartnerMerchant(const GURL& url) {}

bool IsCartDiscountFeatureEnabled() {}

bool IsCouponWithCodeEnabled() {}

bool IsFakeDataEnabled() {}

bool isContextualConsentEnabled() {}

bool IsShoppingListAllowedForEnterprise(PrefService* prefs) {}

bool IsEnabledForCountryAndLocale(const base::Feature& feature,
                                  std::string country,
                                  std::string locale) {}

bool IsRegionLockedFeatureEnabled(const base::Feature& feature,
                                  const base::Feature& feature_region_launched,
                                  const std::string& country_code,
                                  const std::string& locale) {}

#if !BUILDFLAG(IS_ANDROID)
base::TimeDelta GetDiscountFetchDelay() {}

bool IsNoDiscountMerchant(const GURL& url) {}
#endif
}  // namespace commerce