Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" | 14 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" |
| 15 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" | 15 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
| 16 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" | 16 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" |
| 17 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 18 #include "components/payments/content/payment_request.h" | |
| 19 #include "components/payments/core/currency_formatter.h" | 18 #include "components/payments/core/currency_formatter.h" |
| 20 #include "components/strings/grit/components_strings.h" | 19 #include "components/strings/grit/components_strings.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/gfx/font.h" | 21 #include "ui/gfx/font.h" |
| 23 #include "ui/views/border.h" | 22 #include "ui/views/border.h" |
| 23 #include "ui/views/controls/button/md_text_button.h" | |
| 24 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
| 25 #include "ui/views/controls/styled_label.h" | 25 #include "ui/views/controls/styled_label.h" |
| 26 #include "ui/views/layout/box_layout.h" | 26 #include "ui/views/layout/box_layout.h" |
| 27 #include "ui/views/layout/grid_layout.h" | 27 #include "ui/views/layout/grid_layout.h" |
| 28 #include "ui/views/view.h" | 28 #include "ui/views/view.h" |
| 29 | 29 |
| 30 namespace payments { | 30 namespace payments { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 layout->AddView(amount_label.release()); | 77 layout->AddView(amount_label.release()); |
| 78 | 78 |
| 79 return row; | 79 return row; |
| 80 } | 80 } |
| 81 | 81 |
| 82 } // namespace | 82 } // namespace |
| 83 | 83 |
| 84 OrderSummaryViewController::OrderSummaryViewController( | 84 OrderSummaryViewController::OrderSummaryViewController( |
| 85 PaymentRequest* request, | 85 PaymentRequest* request, |
| 86 PaymentRequestDialogView* dialog) | 86 PaymentRequestDialogView* dialog) |
| 87 : PaymentRequestSheetController(request, dialog) {} | 87 : PaymentRequestSheetController(request, dialog), pay_button_(nullptr) { |
| 88 request->AddObserver(this); | |
| 89 } | |
| 88 | 90 |
| 89 OrderSummaryViewController::~OrderSummaryViewController() {} | 91 OrderSummaryViewController::~OrderSummaryViewController() { |
| 92 request()->RemoveObserver(this); | |
| 93 } | |
| 90 | 94 |
| 91 std::unique_ptr<views::View> OrderSummaryViewController::CreateView() { | 95 std::unique_ptr<views::View> OrderSummaryViewController::CreateView() { |
| 92 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); | 96 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); |
| 93 | 97 |
| 94 views::BoxLayout* layout = new views::BoxLayout( | 98 views::BoxLayout* layout = new views::BoxLayout( |
| 95 views::BoxLayout::kVertical, 0, 0, 0); | 99 views::BoxLayout::kVertical, 0, 0, 0); |
| 96 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_START); | 100 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_START); |
| 97 layout->set_cross_axis_alignment( | 101 layout->set_cross_axis_alignment( |
| 98 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); | 102 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); |
| 99 content_view->SetLayoutManager(layout); | 103 content_view->SetLayoutManager(layout); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 .release()); | 136 .release()); |
| 133 | 137 |
| 134 return CreatePaymentView( | 138 return CreatePaymentView( |
| 135 CreateSheetHeaderView( | 139 CreateSheetHeaderView( |
| 136 true, | 140 true, |
| 137 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_TITLE), | 141 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_TITLE), |
| 138 this), | 142 this), |
| 139 std::move(content_view)); | 143 std::move(content_view)); |
| 140 } | 144 } |
| 141 | 145 |
| 146 std::unique_ptr<views::Button> | |
| 147 OrderSummaryViewController::CreatePrimaryButton() { | |
| 148 std::unique_ptr<views::Button> button( | |
| 149 views::MdTextButton::CreateSecondaryUiBlueButton( | |
| 150 this, l10n_util::GetStringUTF16(IDS_PAYMENTS_PAY_BUTTON))); | |
| 151 button->set_tag(static_cast<int>(PaymentRequestCommonTags::PAY_BUTTON_TAG)); | |
| 152 button->set_id(static_cast<int>(DialogViewID::PAYMENT_SHEET_PAY_BUTTON)); | |
|
anthonyvd
2017/03/01 18:36:08
nit: This view ID should probably be just PAY_BUTT
Mathieu
2017/03/01 19:23:02
ah yes done
| |
| 153 pay_button_ = button.get(); | |
| 154 UpdatePayButtonState(request()->is_ready_to_pay()); | |
| 155 return button; | |
| 156 } | |
| 157 | |
| 158 void OrderSummaryViewController::OnSelectedInformationChanged() { | |
| 159 UpdatePayButtonState(request()->is_ready_to_pay()); | |
| 160 } | |
| 161 | |
| 162 void OrderSummaryViewController::UpdatePayButtonState(bool enabled) { | |
| 163 pay_button_->SetEnabled(enabled); | |
| 164 } | |
| 165 | |
| 142 } // namespace payments | 166 } // namespace payments |
| OLD | NEW |