| Index: chrome/browser/ui/views/payments/payment_method_view_controller.cc
|
| diff --git a/chrome/browser/ui/views/payments/payment_method_view_controller.cc b/chrome/browser/ui/views/payments/payment_method_view_controller.cc
|
| index f439fd1028e1763c7807fe6a2e8159ef83422752..0c98740092576b4b4e848892b0fccf9006b3b34e 100644
|
| --- a/chrome/browser/ui/views/payments/payment_method_view_controller.cc
|
| +++ b/chrome/browser/ui/views/payments/payment_method_view_controller.cc
|
| @@ -7,16 +7,33 @@
|
| #include <memory>
|
| #include <utility>
|
|
|
| -#include "base/logging.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
|
| +#include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
|
| #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
|
| +#include "chrome/grit/generated_resources.h"
|
| #include "components/payments/payment_request.h"
|
| #include "components/strings/grit/components_strings.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| +#include "ui/views/controls/button/label_button.h"
|
| +#include "ui/views/controls/button/md_text_button.h"
|
| +#include "ui/views/layout/fill_layout.h"
|
|
|
| namespace payments {
|
|
|
| +namespace {
|
| +
|
| +constexpr int kFirstTagValue = static_cast<int>(
|
| + payments::PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX);
|
| +
|
| +enum class PaymentMethodViewControllerTags : int {
|
| + // The tag for the button that triggers the "add card" flow. Starts at
|
| + // |kFirstTagValue| not to conflict with tags common to all views.
|
| + ADD_CREDIT_CARD_BUTTON = kFirstTagValue,
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| PaymentMethodViewController::PaymentMethodViewController(
|
| PaymentRequest* request,
|
| PaymentRequestDialogView* dialog)
|
| @@ -27,7 +44,17 @@ PaymentMethodViewController::~PaymentMethodViewController() {}
|
| std::unique_ptr<views::View> PaymentMethodViewController::CreateView() {
|
| std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>();
|
|
|
| - // TODO(anthonyvd): populate this view.
|
| + views::FillLayout* layout = new views::FillLayout();
|
| + content_view->SetLayoutManager(layout);
|
| +
|
| + // Create the "Add a card" button.
|
| + views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
|
| + this, l10n_util::GetStringUTF16(IDS_AUTOFILL_ADD_CREDITCARD_CAPTION));
|
| + button->set_tag(static_cast<int>(
|
| + PaymentMethodViewControllerTags::ADD_CREDIT_CARD_BUTTON));
|
| + button->set_id(
|
| + static_cast<int>(DialogViewID::PAYMENT_METHOD_ADD_CARD_BUTTON));
|
| + content_view->AddChildView(button);
|
|
|
| return CreatePaymentView(CreateSheetHeaderView(
|
| true,
|
| @@ -37,4 +64,17 @@ std::unique_ptr<views::View> PaymentMethodViewController::CreateView() {
|
| std::move(content_view));
|
| }
|
|
|
| +void PaymentMethodViewController::ButtonPressed(views::Button* sender,
|
| + const ui::Event& event) {
|
| + switch (sender->tag()) {
|
| + case static_cast<int>(
|
| + PaymentMethodViewControllerTags::ADD_CREDIT_CARD_BUTTON):
|
| + dialog()->ShowCreditCardEditor();
|
| + break;
|
| + default:
|
| + PaymentRequestSheetController::ButtonPressed(sender, event);
|
| + break;
|
| + }
|
| +}
|
| +
|
| } // namespace payments
|
|
|