#include "components/payments/content/payment_request_state.h"
#include <set>
#include <utility>
#include <vector>
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/observer_list.h"
#include "base/ranges/algorithm.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "components/autofill/core/browser/address_data_manager.h"
#include "components/autofill/core/browser/address_normalizer.h"
#include "components/autofill/core/browser/autofill_data_util.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/geo/autofill_country.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/validation.h"
#include "components/payments/content/content_payment_request_delegate.h"
#include "components/payments/content/payment_app.h"
#include "components/payments/content/payment_manifest_web_data_service.h"
#include "components/payments/content/payment_response_helper.h"
#include "components/payments/content/service_worker_payment_app.h"
#include "components/payments/core/error_strings.h"
#include "components/payments/core/features.h"
#include "components/payments/core/method_strings.h"
#include "components/payments/core/payment_request_data_util.h"
#include "components/payments/core/payments_experimental_features.h"
#include "components/webauthn/core/browser/internal_authenticator.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_features.h"
namespace payments {
namespace {
void CallStatusCallback(PaymentRequestState::StatusCallback callback,
bool status) { … }
void PostStatusCallback(PaymentRequestState::StatusCallback callback,
bool status) { … }
}
PaymentRequestState::PaymentRequestState(
std::unique_ptr<PaymentAppService> payment_app_service,
content::RenderFrameHost* initiator_render_frame_host,
const GURL& top_level_origin,
const GURL& frame_origin,
const url::Origin& frame_security_origin,
base::WeakPtr<PaymentRequestSpec> spec,
base::WeakPtr<Delegate> delegate,
const std::string& app_locale,
autofill::PersonalDataManager* personal_data_manager,
base::WeakPtr<ContentPaymentRequestDelegate> payment_request_delegate,
base::WeakPtr<JourneyLogger> journey_logger,
base::WeakPtr<CSPChecker> csp_checker)
: … { … }
PaymentRequestState::~PaymentRequestState() { … }
content::WebContents* PaymentRequestState::GetWebContents() { … }
base::WeakPtr<ContentPaymentRequestDelegate>
PaymentRequestState::GetPaymentRequestDelegate() const { … }
void PaymentRequestState::ShowProcessingSpinner() { … }
base::WeakPtr<PaymentRequestSpec> PaymentRequestState::GetSpec() const { … }
void PaymentRequestState::GetTwaPackageName(
GetTwaPackageNameCallback callback) { … }
const GURL& PaymentRequestState::GetTopOrigin() { … }
const GURL& PaymentRequestState::GetFrameOrigin() { … }
const url::Origin& PaymentRequestState::GetFrameSecurityOrigin() { … }
content::RenderFrameHost* PaymentRequestState::GetInitiatorRenderFrameHost()
const { … }
content::GlobalRenderFrameHostId
PaymentRequestState::GetInitiatorRenderFrameHostId() const { … }
const std::vector<mojom::PaymentMethodDataPtr>&
PaymentRequestState::GetMethodData() const { … }
std::unique_ptr<webauthn::InternalAuthenticator>
PaymentRequestState::CreateInternalAuthenticator() const { … }
scoped_refptr<PaymentManifestWebDataService>
PaymentRequestState::GetPaymentManifestWebDataService() const { … }
bool PaymentRequestState::IsOffTheRecord() const { … }
void PaymentRequestState::OnPaymentAppCreated(std::unique_ptr<PaymentApp> app) { … }
void PaymentRequestState::OnPaymentAppCreationError(
const std::string& error_message,
AppCreationFailureReason reason) { … }
void PaymentRequestState::OnDoneCreatingPaymentApps() { … }
void PaymentRequestState::SetCanMakePaymentEvenWithoutApps() { … }
base::WeakPtr<CSPChecker> PaymentRequestState::GetCSPChecker() { … }
void PaymentRequestState::SetOptOutOffered() { … }
std::optional<base::UnguessableToken>
PaymentRequestState::GetChromeOSTWAInstanceId() const { … }
void PaymentRequestState::OnPaymentResponseReady(
mojom::PaymentResponsePtr payment_response) { … }
void PaymentRequestState::OnPaymentResponseError(
const std::string& error_message) { … }
void PaymentRequestState::OnSpecUpdated() { … }
void PaymentRequestState::CanMakePayment(StatusCallback callback) { … }
void PaymentRequestState::HasEnrolledInstrument(StatusCallback callback) { … }
void PaymentRequestState::AreRequestedMethodsSupported(
MethodsSupportedCallback callback) { … }
void PaymentRequestState::OnAbort() { … }
void PaymentRequestState::CheckRequestedMethodsSupported(
MethodsSupportedCallback callback) { … }
std::string PaymentRequestState::GetAuthenticatedEmail() const { … }
void PaymentRequestState::AddObserver(Observer* observer) { … }
void PaymentRequestState::RemoveObserver(Observer* observer) { … }
void PaymentRequestState::GeneratePaymentResponse() { … }
void PaymentRequestState::OnPaymentAppWindowClosed() { … }
void PaymentRequestState::RecordUseStats() { … }
void PaymentRequestState::SetAvailablePaymentAppForRetry() { … }
void PaymentRequestState::AddAutofillShippingProfile(
bool selected,
const autofill::AutofillProfile& profile) { … }
void PaymentRequestState::AddAutofillContactProfile(
bool selected,
const autofill::AutofillProfile& profile) { … }
void PaymentRequestState::SetSelectedShippingOption(
const std::string& shipping_option_id) { … }
void PaymentRequestState::SetSelectedShippingProfile(
autofill::AutofillProfile* profile) { … }
void PaymentRequestState::SetSelectedContactProfile(
autofill::AutofillProfile* profile) { … }
void PaymentRequestState::SetSelectedApp(base::WeakPtr<PaymentApp> app) { … }
const std::string& PaymentRequestState::GetApplicationLocale() { … }
autofill::PersonalDataManager* PaymentRequestState::GetPersonalDataManager() { … }
autofill::RegionDataLoader* PaymentRequestState::GetRegionDataLoader() { … }
bool PaymentRequestState::IsPaymentAppInvoked() const { … }
autofill::AddressNormalizer* PaymentRequestState::GetAddressNormalizer() { … }
bool PaymentRequestState::IsInitialized() const { … }
void PaymentRequestState::SelectDefaultShippingAddressAndNotifyObservers() { … }
bool PaymentRequestState::ShouldShowShippingSection() const { … }
bool PaymentRequestState::ShouldShowContactSection() const { … }
base::WeakPtr<PaymentRequestState> PaymentRequestState::AsWeakPtr() { … }
void PaymentRequestState::PopulateProfileCache() { … }
void PaymentRequestState::SetDefaultProfileSelections() { … }
void PaymentRequestState::UpdateIsReadyToPayAndNotifyObservers() { … }
void PaymentRequestState::NotifyOnGetAllPaymentAppsFinished() { … }
void PaymentRequestState::NotifyOnSelectedInformationChanged() { … }
bool PaymentRequestState::ArePaymentDetailsSatisfied() { … }
bool PaymentRequestState::ArePaymentOptionsSatisfied() { … }
void PaymentRequestState::OnAddressNormalized(
bool success,
const autofill::AutofillProfile& normalized_profile) { … }
void PaymentRequestState::OnGetTwaPackageName(
GetTwaPackageNameCallback callback,
const std::string& twa_package_name) { … }
bool PaymentRequestState::IsInTwa() const { … }
bool PaymentRequestState::GetCanMakePaymentValue() const { … }
bool PaymentRequestState::GetHasEnrolledInstrumentValue() const { … }
}