| 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 51a4daee25104ff76f197335ea7dddcce7cde045..dc13182222da6f78f0c3cd34f06bd04a693076de 100644
|
| --- a/content/browser/payments/payment_app_database.cc
|
| +++ b/content/browser/payments/payment_app_database.cc
|
| @@ -107,9 +107,23 @@ void PaymentAppDatabase::ReadAllManifests(
|
| weak_ptr_factory_.GetWeakPtr(), callback));
|
| }
|
|
|
| +void PaymentAppDatabase::DeletePaymentInstrument(
|
| + const GURL& scope,
|
| + const std::string& instrument_key,
|
| + DeletePaymentInstrumentCallback callback) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| +
|
| + service_worker_context_->FindReadyRegistrationForPattern(
|
| + scope,
|
| + base::Bind(
|
| + &PaymentAppDatabase::DidFindRegistrationToDeletePaymentInstrument,
|
| + weak_ptr_factory_.GetWeakPtr(), instrument_key,
|
| + base::Passed(std::move(callback))));
|
| +}
|
| +
|
| void PaymentAppDatabase::ReadPaymentInstrument(
|
| const GURL& scope,
|
| - const std::string& instrumentKey,
|
| + const std::string& instrument_key,
|
| ReadPaymentInstrumentCallback callback) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
|
|
| @@ -117,13 +131,13 @@ void PaymentAppDatabase::ReadPaymentInstrument(
|
| scope,
|
| base::Bind(
|
| &PaymentAppDatabase::DidFindRegistrationToReadPaymentInstrument,
|
| - weak_ptr_factory_.GetWeakPtr(), instrumentKey,
|
| + weak_ptr_factory_.GetWeakPtr(), instrument_key,
|
| base::Passed(std::move(callback))));
|
| }
|
|
|
| void PaymentAppDatabase::WritePaymentInstrument(
|
| const GURL& scope,
|
| - const std::string& instrumentKey,
|
| + const std::string& instrument_key,
|
| PaymentInstrumentPtr instrument,
|
| WritePaymentInstrumentCallback callback) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| @@ -132,7 +146,7 @@ void PaymentAppDatabase::WritePaymentInstrument(
|
| scope,
|
| base::Bind(
|
| &PaymentAppDatabase::DidFindRegistrationToWritePaymentInstrument,
|
| - weak_ptr_factory_.GetWeakPtr(), instrumentKey,
|
| + weak_ptr_factory_.GetWeakPtr(), instrument_key,
|
| base::Passed(std::move(instrument)),
|
| base::Passed(std::move(callback))));
|
| }
|
| @@ -249,8 +263,54 @@ void PaymentAppDatabase::DidReadAllManifests(
|
| callback.Run(std::move(manifests));
|
| }
|
|
|
| +void PaymentAppDatabase::DidFindRegistrationToDeletePaymentInstrument(
|
| + const std::string& instrument_key,
|
| + DeletePaymentInstrumentCallback 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::DidFindPaymentInstrument,
|
| + weak_ptr_factory_.GetWeakPtr(), registration->id(),
|
| + instrument_key, base::Passed(std::move(callback))));
|
| +}
|
| +
|
| +void PaymentAppDatabase::DidFindPaymentInstrument(
|
| + 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;
|
| + }
|
| +
|
| + service_worker_context_->ClearRegistrationUserData(
|
| + registration_id, {instrument_key},
|
| + base::Bind(&PaymentAppDatabase::DidDeletePaymentInstrument,
|
| + weak_ptr_factory_.GetWeakPtr(),
|
| + base::Passed(std::move(callback))));
|
| +}
|
| +
|
| +void PaymentAppDatabase::DidDeletePaymentInstrument(
|
| + DeletePaymentInstrumentCallback callback,
|
| + ServiceWorkerStatusCode status) {
|
| + DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
| + return std::move(callback).Run(status == SERVICE_WORKER_OK
|
| + ? PaymentHandlerStatus::SUCCESS
|
| + : PaymentHandlerStatus::NOT_FOUND);
|
| +}
|
| +
|
| void PaymentAppDatabase::DidFindRegistrationToReadPaymentInstrument(
|
| - const std::string& instrumentKey,
|
| + const std::string& instrument_key,
|
| ReadPaymentInstrumentCallback callback,
|
| ServiceWorkerStatusCode status,
|
| scoped_refptr<ServiceWorkerRegistration> registration) {
|
| @@ -262,7 +322,7 @@ void PaymentAppDatabase::DidFindRegistrationToReadPaymentInstrument(
|
| }
|
|
|
| service_worker_context_->GetRegistrationUserData(
|
| - registration->id(), {instrumentKey},
|
| + registration->id(), {instrument_key},
|
| base::Bind(&PaymentAppDatabase::DidReadPaymentInstrument,
|
| weak_ptr_factory_.GetWeakPtr(),
|
| base::Passed(std::move(callback))));
|
| @@ -290,7 +350,7 @@ void PaymentAppDatabase::DidReadPaymentInstrument(
|
| }
|
|
|
| void PaymentAppDatabase::DidFindRegistrationToWritePaymentInstrument(
|
| - const std::string& instrumentKey,
|
| + const std::string& instrument_key,
|
| PaymentInstrumentPtr instrument,
|
| WritePaymentInstrumentCallback callback,
|
| ServiceWorkerStatusCode status,
|
| @@ -315,7 +375,7 @@ void PaymentAppDatabase::DidFindRegistrationToWritePaymentInstrument(
|
|
|
| service_worker_context_->StoreRegistrationUserData(
|
| registration->id(), registration->pattern().GetOrigin(),
|
| - {{instrumentKey, serialized}},
|
| + {{instrument_key, serialized}},
|
| base::Bind(&PaymentAppDatabase::DidWritePaymentInstrument,
|
| weak_ptr_factory_.GetWeakPtr(),
|
| base::Passed(std::move(callback))));
|
|
|