#include "components/payments/content/utility/payment_manifest_parser.h"
#include <algorithm>
#include <string_view>
#include <utility>
#include "base/check_op.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "components/payments/content/utility/fingerprint_parser.h"
#include "components/payments/core/error_logger.h"
#include "components/payments/core/url_util.h"
#include "net/base/url_util.h"
#include "services/data_decoder/public/cpp/data_decoder.h"
#include "url/url_constants.h"
namespace payments {
namespace {
const size_t kMaximumNumberOfItems = …;
const size_t kMaximumNumberOfSupportedOrigins = …;
const size_t kMaximumNumberOfSupportedDelegations = …;
const size_t kMaximumPrintedStringLength = …;
const char* const kDefaultApplications = …;
const char* const kFingerprints = …;
const char* const kHttpPrefix = …;
const char* const kHttpsPrefix = …;
const char* const kId = …;
const char* const kMinVersion = …;
const char* const kPayment = …;
const char* const kPlatform = …;
const char* const kPlay = …;
const char* const kPreferRelatedApplications = …;
const char* const kRelatedApplications = …;
const char* const kServiceWorkerScope = …;
const char* const kServiceWorker = …;
const char* const kServiceWorkerSrc = …;
const char* const kServiceWorkerUseCache = …;
const char* const kSupportedDelegations = …;
const char* const kSupportedOrigins = …;
const char* const kWebAppIcons = …;
const char* const kWebAppIconSizes = …;
const char* const kWebAppIconSrc = …;
const char* const kWebAppIconType = …;
const char* const kWebAppName = …;
const std::string ValidateAndTruncateIfNeeded(const std::string& input,
bool* out_is_ASCII) { … }
bool ParseDefaultApplications(const GURL& manifest_url,
const base::Value::Dict* dict,
std::vector<GURL>* web_app_manifest_urls,
const ErrorLogger& log) { … }
bool ParseSupportedOrigins(const base::Value::Dict* dict,
std::vector<url::Origin>* supported_origins,
const ErrorLogger& log) { … }
void ParseIcons(const base::Value::Dict& dict,
const ErrorLogger& log,
std::vector<PaymentManifestParser::WebAppIcon>* icons) { … }
void ParsePreferredRelatedApplicationIdentifiers(
const base::Value::Dict& dict,
const ErrorLogger& log,
std::vector<std::string>* ids) { … }
bool GetString(const base::Value::Dict* dict,
std::string_view key,
std::string& result) { … }
}
PaymentManifestParser::WebAppIcon::WebAppIcon() = default;
PaymentManifestParser::WebAppIcon::~WebAppIcon() = default;
PaymentManifestParser::PaymentManifestParser(std::unique_ptr<ErrorLogger> log)
: … { … }
PaymentManifestParser::~PaymentManifestParser() = default;
void PaymentManifestParser::ParsePaymentMethodManifest(
const GURL& manifest_url,
const std::string& content,
PaymentMethodCallback callback) { … }
void PaymentManifestParser::ParseWebAppManifest(const std::string& content,
WebAppCallback callback) { … }
void PaymentManifestParser::ParseWebAppInstallationInfo(
const std::string& content,
WebAppInstallationInfoCallback callback) { … }
void PaymentManifestParser::ParsePaymentMethodManifestIntoVectors(
const GURL& manifest_url,
base::Value value,
const ErrorLogger& log,
std::vector<GURL>* web_app_manifest_urls,
std::vector<url::Origin>* supported_origins) { … }
bool PaymentManifestParser::ParseWebAppManifestIntoVector(
base::Value value,
const ErrorLogger& log,
std::vector<WebAppManifestSection>* output) { … }
bool PaymentManifestParser::ParseWebAppInstallationInfoIntoStructs(
base::Value value,
const ErrorLogger& log,
WebAppInstallationInfo* installation_info,
std::vector<WebAppIcon>* icons) { … }
void PaymentManifestParser::OnPaymentMethodParse(
const GURL& manifest_url,
PaymentMethodCallback callback,
data_decoder::DataDecoder::ValueOrError result) { … }
void PaymentManifestParser::OnWebAppParse(
WebAppCallback callback,
data_decoder::DataDecoder::ValueOrError result) { … }
void PaymentManifestParser::OnWebAppParseInstallationInfo(
WebAppInstallationInfoCallback callback,
data_decoder::DataDecoder::ValueOrError result) { … }
}