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

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

Issue 2844673002: PaymentHandler: Implement PaymentInstruments.has(). (Closed)
Patch Set: PaymentHandler: Implement PaymentInstruments.has(). Created 3 years, 8 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_app_database.h ('k') | content/browser/payments/payment_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « content/browser/payments/payment_app_database.h ('k') | content/browser/payments/payment_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698