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

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

Issue 2789093002: [Payments] Desktop: implement shipping address/option change (Closed)
Patch Set: compile fix Created 3 years, 8 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 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" 15 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
16 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" 16 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
17 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 17 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
18 #include "chrome/grit/generated_resources.h" 18 #include "chrome/grit/generated_resources.h"
19 #include "components/payments/content/payment_request_spec.h"
20 #include "components/payments/core/currency_formatter.h" 19 #include "components/payments/core/currency_formatter.h"
21 #include "components/strings/grit/components_strings.h" 20 #include "components/strings/grit/components_strings.h"
22 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/gfx/font.h" 22 #include "ui/gfx/font.h"
24 #include "ui/views/border.h" 23 #include "ui/views/border.h"
25 #include "ui/views/controls/button/md_text_button.h" 24 #include "ui/views/controls/button/md_text_button.h"
26 #include "ui/views/controls/label.h" 25 #include "ui/views/controls/label.h"
27 #include "ui/views/controls/styled_label.h" 26 #include "ui/views/controls/styled_label.h"
28 #include "ui/views/layout/box_layout.h" 27 #include "ui/views/layout/box_layout.h"
29 #include "ui/views/layout/grid_layout.h" 28 #include "ui/views/layout/grid_layout.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return row; 80 return row;
82 } 81 }
83 82
84 } // namespace 83 } // namespace
85 84
86 OrderSummaryViewController::OrderSummaryViewController( 85 OrderSummaryViewController::OrderSummaryViewController(
87 PaymentRequestSpec* spec, 86 PaymentRequestSpec* spec,
88 PaymentRequestState* state, 87 PaymentRequestState* state,
89 PaymentRequestDialogView* dialog) 88 PaymentRequestDialogView* dialog)
90 : PaymentRequestSheetController(spec, state, dialog), pay_button_(nullptr) { 89 : PaymentRequestSheetController(spec, state, dialog), pay_button_(nullptr) {
90 spec->AddObserver(this);
91 state->AddObserver(this); 91 state->AddObserver(this);
92 } 92 }
93 93
94 OrderSummaryViewController::~OrderSummaryViewController() { 94 OrderSummaryViewController::~OrderSummaryViewController() {
95 spec()->RemoveObserver(this);
95 state()->RemoveObserver(this); 96 state()->RemoveObserver(this);
96 } 97 }
97 98
99 void OrderSummaryViewController::OnSpecUpdated() {
100 UpdateContentView();
101 }
102
103 void OrderSummaryViewController::OnSelectedInformationChanged() {
104 UpdatePayButtonState(state()->is_ready_to_pay());
105 }
106
98 std::unique_ptr<views::Button> 107 std::unique_ptr<views::Button>
99 OrderSummaryViewController::CreatePrimaryButton() { 108 OrderSummaryViewController::CreatePrimaryButton() {
100 std::unique_ptr<views::Button> button( 109 std::unique_ptr<views::Button> button(
101 views::MdTextButton::CreateSecondaryUiBlueButton( 110 views::MdTextButton::CreateSecondaryUiBlueButton(
102 this, l10n_util::GetStringUTF16(IDS_PAYMENTS_PAY_BUTTON))); 111 this, l10n_util::GetStringUTF16(IDS_PAYMENTS_PAY_BUTTON)));
103 button->set_tag(static_cast<int>(PaymentRequestCommonTags::PAY_BUTTON_TAG)); 112 button->set_tag(static_cast<int>(PaymentRequestCommonTags::PAY_BUTTON_TAG));
104 button->set_id(static_cast<int>(DialogViewID::PAY_BUTTON)); 113 button->set_id(static_cast<int>(DialogViewID::PAY_BUTTON));
105 pay_button_ = button.get(); 114 pay_button_ = button.get();
106 UpdatePayButtonState(state()->is_ready_to_pay()); 115 UpdatePayButtonState(state()->is_ready_to_pay());
107 return button; 116 return button;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 spec()->GetFormattedCurrencyAmount( 151 spec()->GetFormattedCurrencyAmount(
143 spec()->details().total->amount->value)); 152 spec()->details().total->amount->value));
144 153
145 content_view->AddChildView( 154 content_view->AddChildView(
146 CreateLineItemView(base::UTF8ToUTF16(spec()->details().total->label), 155 CreateLineItemView(base::UTF8ToUTF16(spec()->details().total->label),
147 total_label_value, true, 156 total_label_value, true,
148 DialogViewID::ORDER_SUMMARY_TOTAL_AMOUNT_LABEL) 157 DialogViewID::ORDER_SUMMARY_TOTAL_AMOUNT_LABEL)
149 .release()); 158 .release());
150 } 159 }
151 160
152 void OrderSummaryViewController::OnSelectedInformationChanged() {
153 UpdatePayButtonState(state()->is_ready_to_pay());
154 }
155
156 void OrderSummaryViewController::UpdatePayButtonState(bool enabled) { 161 void OrderSummaryViewController::UpdatePayButtonState(bool enabled) {
157 pay_button_->SetEnabled(enabled); 162 pay_button_->SetEnabled(enabled);
158 } 163 }
159 164
160 } // namespace payments 165 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698