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

Side by Side Diff: chrome/browser/ui/views/payments/payment_method_view_controller.cc

Issue 2676663002: [Payments] Implements the credit card editor for Desktop UI (Closed)
Patch Set: formatting Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/payments/payment_method_view_controller.h" 5 #include "chrome/browser/ui/views/payments/payment_method_view_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
12 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" 11 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
12 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
13 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 13 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
14 #include "chrome/grit/generated_resources.h"
14 #include "components/payments/payment_request.h" 15 #include "components/payments/payment_request.h"
15 #include "components/strings/grit/components_strings.h" 16 #include "components/strings/grit/components_strings.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/views/controls/button/label_button.h"
19 #include "ui/views/controls/button/md_text_button.h"
20 #include "ui/views/layout/fill_layout.h"
17 21
18 namespace payments { 22 namespace payments {
19 23
24 namespace {
25
26 constexpr int kFirstTagValue = static_cast<int>(
27 payments::PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX);
28
29 enum class PaymentMethodViewControllerTags : int {
30 // The tag for the button that triggers the "add card" flow. Starts at
31 // |kFirstTagValue| not to conflict with tags common to all views.
32 ADD_CREDIT_CARD_BUTTON = kFirstTagValue,
33 };
34
35 } // namespace
36
20 PaymentMethodViewController::PaymentMethodViewController( 37 PaymentMethodViewController::PaymentMethodViewController(
21 PaymentRequest* request, 38 PaymentRequest* request,
22 PaymentRequestDialogView* dialog) 39 PaymentRequestDialogView* dialog)
23 : PaymentRequestSheetController(request, dialog) {} 40 : PaymentRequestSheetController(request, dialog) {}
24 41
25 PaymentMethodViewController::~PaymentMethodViewController() {} 42 PaymentMethodViewController::~PaymentMethodViewController() {}
26 43
27 std::unique_ptr<views::View> PaymentMethodViewController::CreateView() { 44 std::unique_ptr<views::View> PaymentMethodViewController::CreateView() {
28 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); 45 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>();
29 46
30 // TODO(anthonyvd): populate this view. 47 views::FillLayout* layout = new views::FillLayout();
48 content_view->SetLayoutManager(layout);
49
50 // Create the "Add a card" button.
51 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
52 this, l10n_util::GetStringUTF16(IDS_AUTOFILL_ADD_CREDITCARD_CAPTION));
53 button->set_tag(static_cast<int>(
54 PaymentMethodViewControllerTags::ADD_CREDIT_CARD_BUTTON));
55 button->set_id(
56 static_cast<int>(DialogViewID::PAYMENT_METHOD_ADD_CARD_BUTTON));
57 content_view->AddChildView(button);
31 58
32 return CreatePaymentView(CreateSheetHeaderView( 59 return CreatePaymentView(CreateSheetHeaderView(
33 true, 60 true,
34 l10n_util::GetStringUTF16( 61 l10n_util::GetStringUTF16(
35 IDS_PAYMENT_REQUEST_PAYMENT_METHOD_SECTION_NAME), 62 IDS_PAYMENT_REQUEST_PAYMENT_METHOD_SECTION_NAME),
36 this), 63 this),
37 std::move(content_view)); 64 std::move(content_view));
38 } 65 }
39 66
67 void PaymentMethodViewController::ButtonPressed(views::Button* sender,
68 const ui::Event& event) {
69 switch (sender->tag()) {
70 case static_cast<int>(
71 PaymentMethodViewControllerTags::ADD_CREDIT_CARD_BUTTON):
72 dialog()->ShowCreditCardEditor();
73 break;
74 default:
75 PaymentRequestSheetController::ButtonPressed(sender, event);
76 break;
77 }
78 }
79
40 } // namespace payments 80 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698