OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/shell/browser/layout_test/layout_test_payment_app_provider_imp
l.h" |
| 6 |
| 7 #include <string> |
| 8 #include <utility> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/memory/ptr_util.h" |
| 12 #include "components/payments/payment_app.mojom.h" |
| 13 #include "content/public/browser/payment_app_provider.h" |
| 14 #include "content/public/test/layouttest_support.h" |
| 15 #include "content/shell/browser/layout_test/layout_test_content_browser_client.h
" |
| 16 #include "content/shell/browser/shell_browser_context.h" |
| 17 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 18 |
| 19 namespace content { |
| 20 namespace { |
| 21 |
| 22 void GetAllManifestsCallback( |
| 23 const LayoutTestPaymentAppProviderImpl::GetAllPaymentAppIDsCallback& |
| 24 callback, |
| 25 PaymentAppProvider::Manifests manifests) { |
| 26 std::vector<int64_t> ids; |
| 27 for (const auto& manifest : manifests) { |
| 28 ids.push_back(manifest.first); |
| 29 } |
| 30 callback.Run(ids); |
| 31 } |
| 32 |
| 33 } // namespace |
| 34 |
| 35 LayoutTestPaymentAppProviderImpl::LayoutTestPaymentAppProviderImpl() {} |
| 36 |
| 37 LayoutTestPaymentAppProviderImpl::~LayoutTestPaymentAppProviderImpl() {} |
| 38 |
| 39 // static |
| 40 void LayoutTestPaymentAppProviderImpl::Create( |
| 41 mojom::LayoutTestPaymentAppProviderRequest request) { |
| 42 mojo::MakeStrongBinding(base::MakeUnique<LayoutTestPaymentAppProviderImpl>(), |
| 43 std::move(request)); |
| 44 } |
| 45 |
| 46 void LayoutTestPaymentAppProviderImpl::GetAllPaymentAppIDs( |
| 47 const GetAllPaymentAppIDsCallback& callback) { |
| 48 BrowserContext* browser_context = |
| 49 LayoutTestContentBrowserClient::Get()->browser_context(); |
| 50 PaymentAppProvider::GetInstance()->GetAllManifests( |
| 51 browser_context, base::Bind(&GetAllManifestsCallback, callback)); |
| 52 } |
| 53 |
| 54 void LayoutTestPaymentAppProviderImpl::InvokePaymentApp( |
| 55 int64_t registration_id) { |
| 56 payments::mojom::PaymentAppRequestDataPtr data = |
| 57 payments::mojom::PaymentAppRequestData::New(); |
| 58 data->methodData.push_back(payments::mojom::PaymentMethodData::New()); |
| 59 data->total = payments::mojom::PaymentItem::New(); |
| 60 data->total->amount = payments::mojom::PaymentCurrencyAmount::New(); |
| 61 |
| 62 content::PaymentAppProvider::GetInstance()->InvokePaymentApp( |
| 63 LayoutTestContentBrowserClient::Get()->browser_context(), registration_id, |
| 64 std::move(data)); |
| 65 } |
| 66 |
| 67 } // namespace content |
OLD | NEW |