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

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

Issue 2866063004: payment app android
Patch Set: payment app android Created 3 years, 7 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
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 00e79cf9db20157f91dee5b7f7ceb9d13f267a42..3eb84f4b44b5d47d4bd3682a52b878db9c8a7eaa 100644
--- a/content/browser/payments/payment_app_database.cc
+++ b/content/browser/payments/payment_app_database.cc
@@ -83,6 +83,9 @@ PaymentInstrumentPtr DeserializePaymentInstrument(const std::string& input) {
return nullptr;
PaymentInstrumentPtr instrument = PaymentInstrument::New();
+ instrument->registration_id = instrument_proto.registration_id();
+ instrument->instrument_key = instrument_proto.instrument_key();
+ instrument->origin = GURL(instrument_proto.origin());
instrument->name = instrument_proto.name();
for (const auto& method : instrument_proto.enabled_methods())
instrument->enabled_methods.push_back(method);
@@ -135,6 +138,17 @@ void PaymentAppDatabase::ReadAllManifests(
weak_ptr_factory_.GetWeakPtr(), callback));
}
+void PaymentAppDatabase::ReadAllPaymentApps(
+ ReadAllPaymentAppsCallback callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ service_worker_context_->GetUserDataForAllRegistrationsByKeyPrefix(
+ kPaymentInstrumentPrefix,
+ base::Bind(&PaymentAppDatabase::DidReadAllPaymentApps,
+ weak_ptr_factory_.GetWeakPtr(),
+ base::Passed(std::move(callback))));
+}
+
void PaymentAppDatabase::DeletePaymentInstrument(
const GURL& scope,
const std::string& instrument_key,
@@ -328,6 +342,30 @@ void PaymentAppDatabase::DidReadAllManifests(
callback.Run(std::move(manifests));
}
+void PaymentAppDatabase::DidReadAllPaymentApps(
+ ReadAllPaymentAppsCallback callback,
+ const std::vector<std::pair<int64_t, std::string>>& raw_data,
+ ServiceWorkerStatusCode status) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (status != SERVICE_WORKER_OK) {
+ std::move(callback).Run(PaymentApps());
+ return;
+ }
+
+ PaymentApps apps;
+ for (const auto& item_of_raw_data : raw_data) {
+ PaymentInstrumentPtr instrument =
+ DeserializePaymentInstrument(item_of_raw_data.second);
+ if (!instrument)
+ continue;
+ if (!base::ContainsKey(apps, instrument->origin))
+ apps.insert(std::make_pair(instrument->origin, Instruments()));
+ apps[instrument->origin].push_back(std::move(instrument));
+ }
+
+ std::move(callback).Run(std::move(apps));
+}
+
void PaymentAppDatabase::DidFindRegistrationToDeletePaymentInstrument(
const std::string& instrument_key,
DeletePaymentInstrumentCallback callback,
@@ -499,6 +537,9 @@ void PaymentAppDatabase::DidFindRegistrationToWritePaymentInstrument(
}
PaymentInstrumentProto instrument_proto;
+ instrument_proto.set_registration_id(registration->id());
+ instrument_proto.set_instrument_key(instrument_key);
+ instrument_proto.set_origin(registration->pattern().GetOrigin().spec());
instrument_proto.set_name(instrument->name);
for (const auto& method : instrument->enabled_methods) {
instrument_proto.add_enabled_methods(method);
« no previous file with comments | « content/browser/payments/payment_app_database.h ('k') | content/browser/payments/payment_app_provider_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698