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

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

Issue 2730123002: [Web Payments] Add inline items to the Order Summary section. (Closed)
Patch Set: Address comments. Created 3 years, 9 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 | « no previous file | chrome/browser/ui/views/payments/payment_request_views_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" 15 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
15 #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"
16 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 17 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
17 #include "chrome/grit/generated_resources.h" 18 #include "chrome/grit/generated_resources.h"
18 #include "components/payments/core/currency_formatter.h" 19 #include "components/payments/core/currency_formatter.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 std::unique_ptr<views::View> OrderSummaryViewController::CreateView() { 96 std::unique_ptr<views::View> OrderSummaryViewController::CreateView() {
96 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); 97 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>();
97 98
98 views::BoxLayout* layout = new views::BoxLayout( 99 views::BoxLayout* layout = new views::BoxLayout(
99 views::BoxLayout::kVertical, 0, 0, 0); 100 views::BoxLayout::kVertical, 0, 0, 0);
100 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_START); 101 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_START);
101 layout->set_cross_axis_alignment( 102 layout->set_cross_axis_alignment(
102 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH); 103 views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH);
103 content_view->SetLayoutManager(layout); 104 content_view->SetLayoutManager(layout);
104 105
105 CurrencyFormatter* formatter = request()->GetOrCreateCurrencyFormatter(
106 request()->details()->total->amount->currency,
107 request()->details()->total->amount->currency_system,
108 g_browser_process->GetApplicationLocale());
109
110 // Set the ID for the first few line items labels, for testing. 106 // Set the ID for the first few line items labels, for testing.
111 const std::vector<DialogViewID> line_items{ 107 const std::vector<DialogViewID> line_items{
112 DialogViewID::ORDER_SUMMARY_LINE_ITEM_1, 108 DialogViewID::ORDER_SUMMARY_LINE_ITEM_1,
113 DialogViewID::ORDER_SUMMARY_LINE_ITEM_2, 109 DialogViewID::ORDER_SUMMARY_LINE_ITEM_2,
114 DialogViewID::ORDER_SUMMARY_LINE_ITEM_3}; 110 DialogViewID::ORDER_SUMMARY_LINE_ITEM_3};
115 for (size_t i = 0; i < request()->details()->display_items.size(); i++) { 111 for (size_t i = 0; i < request()->details()->display_items.size(); i++) {
116 DialogViewID view_id = 112 DialogViewID view_id =
117 i < line_items.size() ? line_items[i] : DialogViewID::VIEW_ID_NONE; 113 i < line_items.size() ? line_items[i] : DialogViewID::VIEW_ID_NONE;
118 content_view->AddChildView( 114 content_view->AddChildView(
119 CreateLineItemView( 115 CreateLineItemView(
120 base::UTF8ToUTF16(request()->details()->display_items[i]->label), 116 base::UTF8ToUTF16(request()->details()->display_items[i]->label),
121 formatter->Format( 117 request()->GetFormattedCurrencyAmount(
122 request()->details()->display_items[i]->amount->value), 118 request()->details()->display_items[i]->amount->value),
123 false, view_id) 119 false, view_id)
124 .release()); 120 .release());
125 } 121 }
126 122
127 base::string16 total_label_value = l10n_util::GetStringFUTF16( 123 base::string16 total_label_value = l10n_util::GetStringFUTF16(
128 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SHEET_TOTAL_FORMAT, 124 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SHEET_TOTAL_FORMAT,
129 base::UTF8ToUTF16(request()->details()->total->amount->currency), 125 base::UTF8ToUTF16(request()->details()->total->amount->currency),
130 formatter->Format(request()->details()->total->amount->value)); 126 request()->GetFormattedCurrencyAmount(
127 request()->details()->total->amount->value));
131 128
132 content_view->AddChildView( 129 content_view->AddChildView(
133 CreateLineItemView(base::UTF8ToUTF16(request()->details()->total->label), 130 CreateLineItemView(base::UTF8ToUTF16(request()->details()->total->label),
134 total_label_value, true, 131 total_label_value, true,
135 DialogViewID::ORDER_SUMMARY_TOTAL_AMOUNT_LABEL) 132 DialogViewID::ORDER_SUMMARY_TOTAL_AMOUNT_LABEL)
136 .release()); 133 .release());
137 134
138 return CreatePaymentView( 135 return CreatePaymentView(
139 CreateSheetHeaderView( 136 CreateSheetHeaderView(
140 true, 137 true,
(...skipping 16 matching lines...) Expand all
157 154
158 void OrderSummaryViewController::OnSelectedInformationChanged() { 155 void OrderSummaryViewController::OnSelectedInformationChanged() {
159 UpdatePayButtonState(request()->is_ready_to_pay()); 156 UpdatePayButtonState(request()->is_ready_to_pay());
160 } 157 }
161 158
162 void OrderSummaryViewController::UpdatePayButtonState(bool enabled) { 159 void OrderSummaryViewController::UpdatePayButtonState(bool enabled) {
163 pay_button_->SetEnabled(enabled); 160 pay_button_->SetEnabled(enabled);
164 } 161 }
165 162
166 } // namespace payments 163 } // namespace payments
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/payment_request_views_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698