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

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

Issue 2700713005: [WebPayments] Updating Shipping List to use PaymentRequestRowView (Closed)
Patch Set: rebase 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
« no previous file with comments | « chrome/browser/ui/views/payments/shipping_list_view_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/shipping_list_view_controller.h" 5 #include "chrome/browser/ui/views/payments/shipping_list_view_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" 10 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
11 #include "chrome/browser/ui/views/payments/payment_request_row_view.h"
11 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 12 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
12 #include "components/payments/payment_request.h" 13 #include "components/payments/payment_request.h"
13 #include "components/strings/grit/components_strings.h" 14 #include "components/strings/grit/components_strings.h"
14 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/views/layout/box_layout.h" 16 #include "ui/views/layout/box_layout.h"
17 #include "ui/views/layout/grid_layout.h"
16 18
17 namespace payments { 19 namespace payments {
18 20
19 ShippingListViewController::ShippingListViewController( 21 ShippingListViewController::ShippingListViewController(
20 PaymentRequest* request, 22 PaymentRequest* request,
21 PaymentRequestDialogView* dialog) 23 PaymentRequestDialogView* dialog)
22 : PaymentRequestSheetController(request, dialog) {} 24 : PaymentRequestSheetController(request, dialog) {}
23 25
24 ShippingListViewController::~ShippingListViewController() {} 26 ShippingListViewController::~ShippingListViewController() {}
25 27
26 std::unique_ptr<views::View> ShippingListViewController::CreateView() { 28 std::unique_ptr<views::View> ShippingListViewController::CreateView() {
27 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); 29 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>();
28 30
29 views::BoxLayout* layout = 31 views::BoxLayout* layout =
30 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); 32 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0);
31 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_START); 33 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_START);
32 layout->set_cross_axis_alignment( 34 layout->set_cross_axis_alignment(
33 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); 35 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH);
34 content_view->SetLayoutManager(layout); 36 content_view->SetLayoutManager(layout);
35 37
36 for (auto* profile : request()->shipping_profiles()) { 38 for (auto* profile : request()->shipping_profiles()) {
37 // TODO(tmartino): Pass an actual locale in place of empty string. 39 // TODO(tmartino): Pass an actual locale in place of empty string.
38 content_view->AddChildView( 40 content_view->AddChildView(
39 GetShippingAddressLabel(AddressStyleType::DETAILED, std::string(), 41 CreateAddressRow(GetShippingAddressLabel(AddressStyleType::DETAILED,
40 *profile) 42 std::string(), *profile))
41 .release()); 43 .release());
42 } 44 }
43 45
44 return CreatePaymentView( 46 return CreatePaymentView(
45 CreateSheetHeaderView( 47 CreateSheetHeaderView(
46 /* show_back_arrow = */ true, 48 /* show_back_arrow = */ true,
47 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_SHIPPING_SECTION_NAME), 49 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_SHIPPING_SECTION_NAME),
48 this), 50 this),
49 std::move(content_view)); 51 std::move(content_view));
50 } 52 }
51 53
54 std::unique_ptr<views::Button> ShippingListViewController::CreateAddressRow(
55 std::unique_ptr<views::View> content) {
56 std::unique_ptr<PaymentRequestRowView> row =
57 base::MakeUnique<PaymentRequestRowView>(this);
58 views::GridLayout* layout = new views::GridLayout(row.get());
59 row->SetLayoutManager(layout);
60
61 layout->SetInsets(
62 kPaymentRequestRowVerticalInsets, kPaymentRequestRowHorizontalInsets,
63 kPaymentRequestRowVerticalInsets,
64 kPaymentRequestRowHorizontalInsets + kPaymentRequestRowExtraRightInset);
65
66 // Add a column listing the address.
67 views::ColumnSet* columns = layout->AddColumnSet(0);
68 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
69 views::GridLayout::USE_PREF, 0, 0);
70
71 layout->StartRow(0, 0);
72 content->set_can_process_events_within_subtree(false);
73 layout->AddView(content.release());
74
75 return std::move(row);
76 }
77
52 } // namespace payments 78 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/shipping_list_view_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698