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

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

Issue 2643643006: [WebPayments] Adding something resembling Shipping Address list (Closed)
Patch Set: Further rebasing Created 3 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/payments/shipping_list_view_controller.h"
6
7 #include <memory>
8 #include <utility>
9
10 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
11 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
12 #include "components/payments/payment_request.h"
13 #include "components/strings/grit/components_strings.h"
14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/views/layout/box_layout.h"
16
17 namespace payments {
18
19 ShippingListViewController::ShippingListViewController(
20 PaymentRequest* request,
21 PaymentRequestDialogView* dialog)
22 : PaymentRequestSheetController(request, dialog) {}
23
24 ShippingListViewController::~ShippingListViewController() {}
25
26 std::unique_ptr<views::View> ShippingListViewController::CreateView() {
27 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>();
28
29 views::BoxLayout* layout =
30 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0);
31 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_START);
32 layout->set_cross_axis_alignment(
33 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH);
34 content_view->SetLayoutManager(layout);
35
36 for (auto& profile : request()->shipping_profiles()) {
37 // TODO(tmartino): Pass an actual locale in place of empty string.
38 content_view->AddChildView(
39 GetShippingAddressLabel(AddressStyleType::DETAILED, std::string(),
40 *profile)
41 .release());
42 }
43
44 return CreatePaymentView(
45 CreateSheetHeaderView(
46 /* show_back_arrow = */ true,
47 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_SHIPPING_SECTION_NAME),
48 this),
49 std::move(content_view));
50 }
51
52 void ShippingListViewController::ButtonPressed(views::Button* sender,
53 const ui::Event& event) {
54 switch (sender->tag()) {
55 case static_cast<int>(PaymentRequestCommonTags::CLOSE_BUTTON_TAG):
56 dialog()->CloseDialog();
57 break;
58 case static_cast<int>(PaymentRequestCommonTags::BACK_BUTTON_TAG):
59 dialog()->GoBack();
60 break;
61 default:
62 NOTREACHED();
63 }
64 }
65
66 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/shipping_list_view_controller.h ('k') | components/payments/payment_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698