#include "chrome/browser/payments/chrome_payment_request_delegate.h"
#include <utility>
#include <vector>
#include "base/check_op.h"
#include "base/functional/bind.h"
#include "base/memory/ref_counted.h"
#include "build/build_config.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/browser_instance/browser_app_instance.h"
#include "chrome/browser/apps/browser_instance/browser_app_instance_tracker.h"
#include "chrome/browser/autofill/address_normalizer_factory.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/autofill/validation_rules_storage_factory.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/payments/payment_request_display_manager_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
#include "components/autofill/core/browser/address_normalizer_impl.h"
#include "components/autofill/core/browser/geo/region_data_loader_impl.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/ui/region_combobox_model.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/payments/content/payment_manifest_web_data_service.h"
#include "components/payments/content/payment_request.h"
#include "components/payments/content/payment_request_dialog.h"
#include "components/payments/content/ssl_validity_checker.h"
#include "components/payments/core/payment_prefs.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/webauthn/content/browser/internal_authenticator_impl.h"
#include "components/webdata_services/web_data_service_wrapper_factory.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom-shared.h"
#include "third_party/libaddressinput/chromium/chrome_metadata_source.h"
#include "third_party/libaddressinput/chromium/chrome_storage_impl.h"
namespace payments {
namespace {
std::unique_ptr<::i18n::addressinput::Source> GetAddressInputSource() { … }
std::unique_ptr<::i18n::addressinput::Storage> GetAddressInputStorage() { … }
bool FrameSupportsPayments(content::RenderFrameHost* rfh) { … }
}
ChromePaymentRequestDelegate::ChromePaymentRequestDelegate(
content::RenderFrameHost* render_frame_host)
: … { … }
ChromePaymentRequestDelegate::~ChromePaymentRequestDelegate() = default;
void ChromePaymentRequestDelegate::ShowDialog(
base::WeakPtr<PaymentRequest> request) { … }
void ChromePaymentRequestDelegate::RetryDialog() { … }
void ChromePaymentRequestDelegate::CloseDialog() { … }
void ChromePaymentRequestDelegate::ShowErrorMessage() { … }
void ChromePaymentRequestDelegate::ShowProcessingSpinner() { … }
autofill::PersonalDataManager*
ChromePaymentRequestDelegate::GetPersonalDataManager() { … }
const std::string& ChromePaymentRequestDelegate::GetApplicationLocale() const { … }
bool ChromePaymentRequestDelegate::IsOffTheRecord() const { … }
const GURL& ChromePaymentRequestDelegate::GetLastCommittedURL() const { … }
autofill::AddressNormalizer*
ChromePaymentRequestDelegate::GetAddressNormalizer() { … }
autofill::RegionDataLoader*
ChromePaymentRequestDelegate::GetRegionDataLoader() { … }
ukm::UkmRecorder* ChromePaymentRequestDelegate::GetUkmRecorder() { … }
std::string ChromePaymentRequestDelegate::GetAuthenticatedEmail() const { … }
PrefService* ChromePaymentRequestDelegate::GetPrefService() { … }
bool ChromePaymentRequestDelegate::IsBrowserWindowActive() const { … }
void ChromePaymentRequestDelegate::ShowNoMatchingPaymentCredentialDialog(
const std::u16string& merchant_name,
const std::string& rp_id,
base::OnceClosure response_callback,
base::OnceClosure opt_out_callback) { … }
content::RenderFrameHost* ChromePaymentRequestDelegate::GetRenderFrameHost()
const { … }
std::unique_ptr<webauthn::InternalAuthenticator>
ChromePaymentRequestDelegate::CreateInternalAuthenticator() const { … }
scoped_refptr<PaymentManifestWebDataService>
ChromePaymentRequestDelegate::GetPaymentManifestWebDataService() const { … }
PaymentRequestDisplayManager*
ChromePaymentRequestDelegate::GetDisplayManager() { … }
void ChromePaymentRequestDelegate::EmbedPaymentHandlerWindow(
const GURL& url,
PaymentHandlerOpenWindowCallback callback) { … }
bool ChromePaymentRequestDelegate::IsInteractive() const { … }
std::string
ChromePaymentRequestDelegate::GetInvalidSslCertificateErrorMessage() { … }
void ChromePaymentRequestDelegate::GetTwaPackageName(
GetTwaPackageNameCallback callback) const { … }
PaymentRequestDialog* ChromePaymentRequestDelegate::GetDialogForTesting() { … }
SecurePaymentConfirmationNoCreds*
ChromePaymentRequestDelegate::GetNoMatchingCredentialsDialogForTesting() { … }
std::optional<base::UnguessableToken>
ChromePaymentRequestDelegate::GetChromeOSTWAInstanceId() const { … }
const base::WeakPtr<PaymentUIObserver>
ChromePaymentRequestDelegate::GetPaymentUIObserver() const { … }
content::BrowserContext* ChromePaymentRequestDelegate::GetBrowserContextOrNull()
const { … }
}