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

Unified Diff: content/shell/browser/layout_test/layout_test_payment_app_provider_impl.cc

Issue 2647243002: PaymentApp: Implement PaymentAppProvider for LayoutTest.
Patch Set: PaymentApp: Implement PaymentAppProvider for LayoutTest. Created 3 years, 11 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/shell/browser/layout_test/layout_test_payment_app_provider_impl.cc
diff --git a/content/shell/browser/layout_test/layout_test_payment_app_provider_impl.cc b/content/shell/browser/layout_test/layout_test_payment_app_provider_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bdb723cbaff8b6132144fbd07e51e6393ec6ad4d
--- /dev/null
+++ b/content/shell/browser/layout_test/layout_test_payment_app_provider_impl.cc
@@ -0,0 +1,67 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/shell/browser/layout_test/layout_test_payment_app_provider_impl.h"
+
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "base/memory/ptr_util.h"
+#include "components/payments/payment_app.mojom.h"
+#include "content/public/browser/payment_app_provider.h"
+#include "content/public/test/layouttest_support.h"
+#include "content/shell/browser/layout_test/layout_test_content_browser_client.h"
+#include "content/shell/browser/shell_browser_context.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+
+namespace content {
+namespace {
+
+void GetAllManifestsCallback(
+ const LayoutTestPaymentAppProviderImpl::GetAllPaymentAppIDsCallback&
+ callback,
+ PaymentAppProvider::Manifests manifests) {
+ std::vector<int64_t> ids;
+ for (const auto& manifest : manifests) {
+ ids.push_back(manifest.first);
+ }
+ callback.Run(ids);
+}
+
+} // namespace
+
+LayoutTestPaymentAppProviderImpl::LayoutTestPaymentAppProviderImpl() {}
+
+LayoutTestPaymentAppProviderImpl::~LayoutTestPaymentAppProviderImpl() {}
+
+// static
+void LayoutTestPaymentAppProviderImpl::Create(
+ mojom::LayoutTestPaymentAppProviderRequest request) {
+ mojo::MakeStrongBinding(base::MakeUnique<LayoutTestPaymentAppProviderImpl>(),
+ std::move(request));
+}
+
+void LayoutTestPaymentAppProviderImpl::GetAllPaymentAppIDs(
+ const GetAllPaymentAppIDsCallback& callback) {
+ BrowserContext* browser_context =
+ LayoutTestContentBrowserClient::Get()->browser_context();
+ PaymentAppProvider::GetInstance()->GetAllManifests(
+ browser_context, base::Bind(&GetAllManifestsCallback, callback));
+}
+
+void LayoutTestPaymentAppProviderImpl::InvokePaymentApp(
+ int64_t registration_id) {
+ payments::mojom::PaymentAppRequestDataPtr data =
+ payments::mojom::PaymentAppRequestData::New();
+ data->methodData.push_back(payments::mojom::PaymentMethodData::New());
+ data->total = payments::mojom::PaymentItem::New();
+ data->total->amount = payments::mojom::PaymentCurrencyAmount::New();
+
+ content::PaymentAppProvider::GetInstance()->InvokePaymentApp(
+ LayoutTestContentBrowserClient::Get()->browser_context(), registration_id,
+ std::move(data));
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698