#include "components/commerce/core/commerce_heuristics_data.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/no_destructor.h"
#include "base/time/time_delta_from_string.h"
namespace commerce_heuristics {
namespace {
constexpr char kMerchantNameType[] = …;
constexpr char kMerchantCartURLType[] = …;
constexpr char kMerchantCartURLRegexType[] = …;
constexpr char kMerchantCheckoutURLRegexType[] = …;
constexpr char kMerchantPurchaseURLRegexType[] = …;
constexpr char kSkipAddToCartRegexType[] = …;
constexpr char kSkipProductPatternType[] = …;
constexpr char kRuleDiscountPartnerMerchantPatternType[] = …;
constexpr char kCouponDiscountPartnerMerchantPatternType[] = …;
constexpr char kNoDiscountMerchantPatternType[] = …;
constexpr char kCartPagetURLPatternType[] = …;
constexpr char kCheckoutPageURLPatternType[] = …;
constexpr char kPurchaseButtonTextPatternType[] = …;
constexpr char kAddToCartRequestPatternType[] = …;
constexpr char kDiscountFetchDelayType[] = …;
}
CommerceHeuristicsData& CommerceHeuristicsData::GetInstance() { … }
CommerceHeuristicsData::CommerceHeuristicsData() = default;
CommerceHeuristicsData::~CommerceHeuristicsData() = default;
void CommerceHeuristicsData::UpdateVersion(base::Version version) { … }
const std::string CommerceHeuristicsData::GetVersion() { … }
bool CommerceHeuristicsData::PopulateDataFromComponent(
const std::string& hint_json_data,
const std::string& global_json_data,
const std::string& product_id_json_data,
const std::string& cart_extraction_script) { … }
std::optional<std::string> CommerceHeuristicsData::GetMerchantName(
const std::string& domain) { … }
std::optional<std::string> CommerceHeuristicsData::GetMerchantCartURL(
const std::string& domain) { … }
std::optional<std::string>
CommerceHeuristicsData::GetHintHeuristicsJSONForDomain(
const std::string& domain) { … }
std::optional<std::string> CommerceHeuristicsData::GetGlobalHeuristicsJSON() { … }
const re2::RE2* CommerceHeuristicsData::GetProductSkipPattern() { … }
const re2::RE2*
CommerceHeuristicsData::GetRuleDiscountPartnerMerchantPattern() { … }
const re2::RE2*
CommerceHeuristicsData::GetCouponDiscountPartnerMerchantPattern() { … }
const re2::RE2* CommerceHeuristicsData::GetNoDiscountMerchantPattern() { … }
const re2::RE2* CommerceHeuristicsData::GetCartPageURLPattern() { … }
const re2::RE2* CommerceHeuristicsData::GetCheckoutPageURLPattern() { … }
const re2::RE2* CommerceHeuristicsData::GetPurchaseButtonTextPattern() { … }
const re2::RE2* CommerceHeuristicsData::GetAddToCartRequestPattern() { … }
const re2::RE2* CommerceHeuristicsData::GetCartPageURLPatternForDomain(
const std::string& domain) { … }
const re2::RE2* CommerceHeuristicsData::GetCheckoutPageURLPatternForDomain(
const std::string& domain) { … }
const re2::RE2* CommerceHeuristicsData::GetPurchasePageURLPatternForDomain(
const std::string& domain) { … }
const re2::RE2* CommerceHeuristicsData::GetSkipAddToCartPatternForDomain(
const std::string& domain) { … }
std::string CommerceHeuristicsData::GetProductIDExtractionJSON() { … }
std::string CommerceHeuristicsData::GetCartProductExtractionScript() { … }
std::optional<base::TimeDelta> CommerceHeuristicsData::GetDiscountFetchDelay() { … }
std::optional<std::string> CommerceHeuristicsData::GetCommerceHintHeuristics(
const std::string& type,
const std::string& domain) { … }
std::optional<std::string> CommerceHeuristicsData::GetCommerceGlobalHeuristics(
const std::string& type) { … }
const re2::RE2* CommerceHeuristicsData::GetCommerceHintHeuristicsRegex(
std::map<std::string, std::unique_ptr<re2::RE2>>& map,
const std::string type,
const std::string domain) { … }
std::unique_ptr<re2::RE2> CommerceHeuristicsData::ConstructGlobalRegex(
const std::string& type) { … }
}