Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Unified Diff: content/browser/payments/payment_manager.cc

Issue 2958333002: [Payments] Implement web payment app manifest (Closed)
Patch Set: rename and comments Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/payments/payment_manager.h ('k') | content/browser/payments/payment_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/payments/payment_manager.cc
diff --git a/content/browser/payments/payment_manager.cc b/content/browser/payments/payment_manager.cc
index ce9445ed27b4d9727a5db7e15ddda15a0eed5da8..753fe245f985c65094ae46ba5e3037e29168e230 100644
--- a/content/browser/payments/payment_manager.cc
+++ b/content/browser/payments/payment_manager.cc
@@ -34,8 +34,11 @@ PaymentManager::PaymentManager(
base::Bind(&PaymentManager::OnConnectionError, base::Unretained(this)));
}
-void PaymentManager::Init(const std::string& scope) {
+void PaymentManager::Init(const std::string& context,
+ const std::string& scope) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ should_set_payment_app_info_ = true;
+ context_ = GURL(context);
scope_ = GURL(scope);
}
@@ -80,8 +83,32 @@ void PaymentManager::SetPaymentInstrument(
PaymentManager::SetPaymentInstrumentCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- payment_app_context_->payment_app_database()->WritePaymentInstrument(
- scope_, instrument_key, std::move(details), std::move(callback));
+ if (should_set_payment_app_info_) {
+ payment_app_context_->payment_app_database()->WritePaymentInstrument(
+ scope_, instrument_key, std::move(details),
+ base::BindOnce(
+ &PaymentManager::SetPaymentInstrumentIntermediateCallback,
+ weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
+ } else {
+ payment_app_context_->payment_app_database()->WritePaymentInstrument(
+ scope_, instrument_key, std::move(details), std::move(callback));
+ }
+}
+
+void PaymentManager::SetPaymentInstrumentIntermediateCallback(
+ PaymentManager::SetPaymentInstrumentCallback callback,
+ payments::mojom::PaymentHandlerStatus status) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ if (status != payments::mojom::PaymentHandlerStatus::SUCCESS ||
+ !should_set_payment_app_info_) {
+ std::move(callback).Run(status);
+ return;
+ }
+
+ payment_app_context_->payment_app_database()->FetchAndWritePaymentAppInfo(
+ context_, scope_, std::move(callback));
+ should_set_payment_app_info_ = false;
}
void PaymentManager::ClearPaymentInstruments(
« no previous file with comments | « content/browser/payments/payment_manager.h ('k') | content/browser/payments/payment_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698