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

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

Issue 2592833002: [WebPayments] Start populating the Payment Sheet. (Closed)
Patch Set: Created 3 years, 12 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/order_summary_view_controller.h" 5 #include "chrome/browser/ui/views/payments/order_summary_view_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/payments/payment_request_impl.h"
13 #include "chrome/browser/ui/views/payments/payment_request_dialog.h" 14 #include "chrome/browser/ui/views/payments/payment_request_dialog.h"
14 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 15 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
15 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
17 #include "components/strings/grit/components_strings.h"
16 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/views/controls/button/label_button.h" 19 #include "ui/views/controls/label.h"
18 #include "ui/views/controls/button/md_text_button.h"
19 #include "ui/views/layout/grid_layout.h" 20 #include "ui/views/layout/grid_layout.h"
20 #include "ui/views/view.h" 21 #include "ui/views/view.h"
21 22
22 namespace {
23
24 // The tag for the button that navigates back to the payment sheet.
25 constexpr int kBackButtonTag = 0;
26
27 } // namespace
28
29 namespace payments { 23 namespace payments {
30 24
31 OrderSummaryViewController::OrderSummaryViewController( 25 OrderSummaryViewController::OrderSummaryViewController(
32 PaymentRequestImpl* impl, PaymentRequestDialog* dialog) 26 PaymentRequestImpl* impl, PaymentRequestDialog* dialog)
33 : PaymentRequestSheetController(impl, dialog) {} 27 : PaymentRequestSheetController(impl, dialog) {}
34 28
35 OrderSummaryViewController::~OrderSummaryViewController() {} 29 OrderSummaryViewController::~OrderSummaryViewController() {}
36 30
37 std::unique_ptr<views::View> OrderSummaryViewController::CreateView() { 31 std::unique_ptr<views::View> OrderSummaryViewController::CreateView() {
38 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); 32 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>();
39 33
40 views::GridLayout* layout = new views::GridLayout(content_view.get()); 34 views::GridLayout* layout = new views::GridLayout(content_view.get());
41 content_view->SetLayoutManager(layout); 35 content_view->SetLayoutManager(layout);
42 views::ColumnSet* columns = layout->AddColumnSet(0); 36 views::ColumnSet* columns = layout->AddColumnSet(0);
43 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, 37 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
44 0, views::GridLayout::USE_PREF, 0, 0); 38 0, views::GridLayout::USE_PREF, 0, 0);
45 39
46 layout->StartRow(0, 0); 40 layout->StartRow(0, 0);
47 views::LabelButton* back_button = 41 layout->AddView(new views::Label(
48 views::MdTextButton::CreateSecondaryUiBlueButton( 42 l10n_util::GetStringFUTF16(
49 this, base::ASCIIToUTF16("Back")); 43 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_TOTAL_FORMAT,
50 back_button->set_tag(kBackButtonTag); 44 l10n_util::GetStringUTF16(
51 layout->AddView(back_button); 45 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_TOTAL),
46 base::ASCIIToUTF16(impl()->details()->total->amount->value),
47 base::ASCIIToUTF16(impl()->details()->total->amount->currency))));
please use gerrit instead 2017/01/04 15:55:27 By the way, you will eventually need to write a C+
anthonyvd 2017/01/04 19:08:55 Makes sense, will do.
52 48
53 return payments::CreatePaymentView( 49 return payments::CreatePaymentView(
54 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_TITLE), 50 CreateSheetHeaderView(
51 true,
52 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_TITLE),
53 this),
55 std::move(content_view)); 54 std::move(content_view));
56 } 55 }
57 56
58 void OrderSummaryViewController::ButtonPressed( 57 void OrderSummaryViewController::ButtonPressed(
59 views::Button* sender, const ui::Event& event) { 58 views::Button* sender, const ui::Event& event) {
60 DCHECK_EQ(kBackButtonTag, sender->tag()); 59 if (sender->tag() == CLOSE_BUTTON_TAG) {
sky 2017/01/04 17:24:45 no {}. optional: use a switch statement.
anthonyvd 2017/01/04 19:08:55 Done.
61 60 dialog()->CloseDialog();
62 dialog()->GoBack(); 61 } else if (sender->tag() == BACK_BUTTON_TAG) {
62 dialog()->GoBack();
63 }
63 } 64 }
64 65
65 } // namespace payments 66 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698