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..16f5ce39e2e4e7093fe308f4b4d76e613baf3aaa |
--- /dev/null |
+++ b/content/shell/browser/layout_test/layout_test_payment_app_provider_impl.cc |
@@ -0,0 +1,64 @@ |
+// 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 "base/memory/ptr_util.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 |