| 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 3d6e102429b6fbc927c3dcef056144748f55835d..400f004fb7e0b225e392ca25cb44b6ce277cbf3a 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,32 @@
|
| #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.
|
| + ADD_CREDIT_CARD_BUTTON = kFirstTagValue,
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| PaymentMethodViewController::PaymentMethodViewController(
|
| PaymentRequest* request,
|
| PaymentRequestDialogView* dialog)
|
| @@ -27,7 +43,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,
|
| @@ -40,6 +66,10 @@ std::unique_ptr<views::View> PaymentMethodViewController::CreateView() {
|
| 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;
|
| case static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG):
|
| dialog()->CloseDialog();
|
| break;
|
|
|