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

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

Issue 2695653004: [Web Payments] Add a mechanism to build item lists in the PR dialog. (Closed)
Patch Set: Fix up some comments. Created 3 years, 9 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_request_sheet_controller.h" 5 #include "chrome/browser/ui/views/payments/payment_request_sheet_controller.h"
6 6
7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" 7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
8 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 8 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
9 #include "components/strings/grit/components_strings.h" 9 #include "components/strings/grit/components_strings.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/views/background.h" 11 #include "ui/views/background.h"
12 #include "ui/views/controls/button/md_text_button.h" 12 #include "ui/views/controls/button/md_text_button.h"
13 #include "ui/views/layout/box_layout.h" 13 #include "ui/views/layout/box_layout.h"
14 #include "ui/views/layout/grid_layout.h" 14 #include "ui/views/layout/grid_layout.h"
15 15
16 namespace payments { 16 namespace payments {
17 17
18 PaymentRequestSheetController::PaymentRequestSheetController( 18 PaymentRequestSheetController::PaymentRequestSheetController(
19 PaymentRequest* request, PaymentRequestDialogView* dialog) 19 PaymentRequest* request, PaymentRequestDialogView* dialog)
20 : request_(request), dialog_(dialog) { 20 : request_(request), dialog_(dialog) {
21 } 21 }
22 22
23 std::unique_ptr<views::Button> 23 std::unique_ptr<views::Button>
24 PaymentRequestSheetController::CreatePrimaryButton() { 24 PaymentRequestSheetController::CreatePrimaryButton() {
25 return nullptr; 25 return nullptr;
26 } 26 }
27 27
28 std::unique_ptr<views::View> PaymentRequestSheetController::CreateExtraView() {
29 return nullptr;
30 }
31
28 void PaymentRequestSheetController::ButtonPressed( 32 void PaymentRequestSheetController::ButtonPressed(
29 views::Button* sender, const ui::Event& event) { 33 views::Button* sender, const ui::Event& event) {
30 switch (static_cast<PaymentRequestCommonTags>(sender->tag())) { 34 switch (static_cast<PaymentRequestCommonTags>(sender->tag())) {
31 case PaymentRequestCommonTags::CLOSE_BUTTON_TAG: 35 case PaymentRequestCommonTags::CLOSE_BUTTON_TAG:
32 dialog()->CloseDialog(); 36 dialog()->CloseDialog();
33 break; 37 break;
34 case PaymentRequestCommonTags::BACK_BUTTON_TAG: 38 case PaymentRequestCommonTags::BACK_BUTTON_TAG:
35 dialog()->GoBack(); 39 dialog()->GoBack();
36 break; 40 break;
37 case PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX: 41 case PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 views::GridLayout* layout = new views::GridLayout(container.get()); 83 views::GridLayout* layout = new views::GridLayout(container.get());
80 container->SetLayoutManager(layout); 84 container->SetLayoutManager(layout);
81 85
82 views::ColumnSet* columns = layout->AddColumnSet(0); 86 views::ColumnSet* columns = layout->AddColumnSet(0);
83 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 87 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
84 0, views::GridLayout::USE_PREF, 0, 0); 88 0, views::GridLayout::USE_PREF, 0, 0);
85 columns->AddPaddingColumn(1, 0); 89 columns->AddPaddingColumn(1, 0);
86 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, 90 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
87 0, views::GridLayout::USE_PREF, 0, 0); 91 0, views::GridLayout::USE_PREF, 0, 0);
88 92
89 // The horizontal distance between the right/left edges of the dialog and the
90 // elements.
91 constexpr int kFooterHorizontalInset = 16;
92 // The vertical distance between footer elements and the top/bottom border
93 // (the bottom border is the edge of the dialog).
94 constexpr int kFooterVerticalInset = 16;
95 layout->SetInsets(kFooterVerticalInset, kFooterHorizontalInset,
Mathieu 2017/02/23 00:39:07 also I don't think this should be removed, since i
96 kFooterVerticalInset, kFooterHorizontalInset);
97
98 layout->StartRow(0, 0); 93 layout->StartRow(0, 0);
99 94 std::unique_ptr<views::View> extra_view = CreateExtraView();
100 layout->AddView(CreateLeadingFooterView().release()); 95 if (extra_view)
Mathieu 2017/02/22 23:00:32 This accidentally removed The leading footer view,
96 layout->AddView(extra_view.release());
97 else
98 layout->SkipColumns(1);
101 99
102 std::unique_ptr<views::View> trailing_buttons_container = 100 std::unique_ptr<views::View> trailing_buttons_container =
103 base::MakeUnique<views::View>(); 101 base::MakeUnique<views::View>();
104 102
105 constexpr int kButtonSpacing = 10;
106 trailing_buttons_container->SetLayoutManager(new views::BoxLayout( 103 trailing_buttons_container->SetLayoutManager(new views::BoxLayout(
107 views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing)); 104 views::BoxLayout::kHorizontal, kPaymentRequestRowHorizontalInsets,
105 kPaymentRequestRowVerticalInsets, kPaymentRequestButtonSpacing));
108 106
109 std::unique_ptr<views::Button> primary_button = CreatePrimaryButton(); 107 std::unique_ptr<views::Button> primary_button = CreatePrimaryButton();
110 if (primary_button) 108 if (primary_button)
111 trailing_buttons_container->AddChildView(primary_button.release()); 109 trailing_buttons_container->AddChildView(primary_button.release());
112 110
113 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton( 111 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
114 this, l10n_util::GetStringUTF16(IDS_CANCEL)); 112 this, l10n_util::GetStringUTF16(IDS_CANCEL));
115 button->set_tag(static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG)); 113 button->set_tag(static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG));
116 trailing_buttons_container->AddChildView(button); 114 trailing_buttons_container->AddChildView(button);
117 115
118 layout->AddView(trailing_buttons_container.release()); 116 layout->AddView(trailing_buttons_container.release());
119 117
120 return container; 118 return container;
121 } 119 }
122 120
123 std::unique_ptr<views::View> 121 std::unique_ptr<views::View>
124 PaymentRequestSheetController::CreateLeadingFooterView() { 122 PaymentRequestSheetController::CreateLeadingFooterView() {
125 return base::MakeUnique<views::View>(); 123 return base::MakeUnique<views::View>();
126 } 124 }
127 125
128 } // namespace payments 126 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698