Index: content/browser/payments/payment_app_database.cc |
diff --git a/content/browser/payments/payment_app_database.cc b/content/browser/payments/payment_app_database.cc |
index dc13182222da6f78f0c3cd34f06bd04a693076de..324bdcea6e186245d97cc90fa7205c0538c12e59 100644 |
--- a/content/browser/payments/payment_app_database.cc |
+++ b/content/browser/payments/payment_app_database.cc |
@@ -135,6 +135,19 @@ void PaymentAppDatabase::ReadPaymentInstrument( |
base::Passed(std::move(callback)))); |
} |
+void PaymentAppDatabase::HasPaymentInstrument( |
+ const GURL& scope, |
+ const std::string& instrument_key, |
+ HasPaymentInstrumentCallback callback) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ |
+ service_worker_context_->FindReadyRegistrationForPattern( |
+ scope, |
+ base::Bind(&PaymentAppDatabase::DidFindRegistrationToHasPaymentInstrument, |
+ weak_ptr_factory_.GetWeakPtr(), instrument_key, |
+ base::Passed(std::move(callback)))); |
+} |
+ |
void PaymentAppDatabase::WritePaymentInstrument( |
const GURL& scope, |
const std::string& instrument_key, |
@@ -349,6 +362,39 @@ void PaymentAppDatabase::DidReadPaymentInstrument( |
std::move(callback).Run(std::move(instrument), PaymentHandlerStatus::SUCCESS); |
} |
+void PaymentAppDatabase::DidFindRegistrationToHasPaymentInstrument( |
+ const std::string& instrument_key, |
+ HasPaymentInstrumentCallback callback, |
+ ServiceWorkerStatusCode status, |
+ scoped_refptr<ServiceWorkerRegistration> registration) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ if (status != SERVICE_WORKER_OK) { |
+ std::move(callback).Run(PaymentHandlerStatus::NO_ACTIVE_WORKER); |
+ return; |
+ } |
+ |
+ service_worker_context_->GetRegistrationUserData( |
+ registration->id(), {instrument_key}, |
+ base::Bind(&PaymentAppDatabase::DidHasPaymentInstrument, |
+ weak_ptr_factory_.GetWeakPtr(), registration->id(), |
+ instrument_key, base::Passed(std::move(callback)))); |
+} |
+ |
+void PaymentAppDatabase::DidHasPaymentInstrument( |
+ int64_t registration_id, |
+ const std::string& instrument_key, |
+ DeletePaymentInstrumentCallback callback, |
+ const std::vector<std::string>& data, |
+ ServiceWorkerStatusCode status) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ if (status != SERVICE_WORKER_OK || data.size() != 1) { |
+ std::move(callback).Run(PaymentHandlerStatus::NOT_FOUND); |
+ return; |
+ } |
+ |
+ std::move(callback).Run(PaymentHandlerStatus::SUCCESS); |
+} |
+ |
void PaymentAppDatabase::DidFindRegistrationToWritePaymentInstrument( |
const std::string& instrument_key, |
PaymentInstrumentPtr instrument, |