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

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

Issue 2621033003: [Payments] Currency formatter for order amounts. (Closed)
Patch Set: Addressed comments 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
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/payment_sheet_view_controller.h" 5 #include "chrome/browser/ui/views/payments/payment_sheet_view_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/ui/views/payments/payment_request_dialog.h" 13 #include "chrome/browser/ui/views/payments/payment_request_dialog.h"
13 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 14 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
14 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
16 #include "components/payments/currency_formatter.h"
15 #include "components/payments/payment_request.h" 17 #include "components/payments/payment_request.h"
16 #include "components/strings/grit/components_strings.h" 18 #include "components/strings/grit/components_strings.h"
17 #include "third_party/skia/include/core/SkColor.h" 19 #include "third_party/skia/include/core/SkColor.h"
18 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/gfx/color_utils.h" 21 #include "ui/gfx/color_utils.h"
20 #include "ui/gfx/font.h" 22 #include "ui/gfx/font.h"
21 #include "ui/gfx/geometry/insets.h" 23 #include "ui/gfx/geometry/insets.h"
22 #include "ui/gfx/paint_vector_icon.h" 24 #include "ui/gfx/paint_vector_icon.h"
23 #include "ui/gfx/range/range.h" 25 #include "ui/gfx/range/range.h"
24 #include "ui/gfx/vector_icons_public.h" 26 #include "ui/gfx/vector_icons_public.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON): 152 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON):
151 dialog()->ShowOrderSummary(); 153 dialog()->ShowOrderSummary();
152 break; 154 break;
153 default: 155 default:
154 NOTREACHED(); 156 NOTREACHED();
155 } 157 }
156 } 158 }
157 159
158 std::unique_ptr<views::View> 160 std::unique_ptr<views::View>
159 PaymentSheetViewController::CreateOrderSummarySectionContent() { 161 PaymentSheetViewController::CreateOrderSummarySectionContent() {
162 CurrencyFormatter* formatter = request()->GetOrCreateCurrencyFormatter(
163 request()->details()->total->amount->currency,
164 request()->details()->total->amount->currencySystem,
sky 2017/01/12 23:49:02 How come this isn't currency_sytem?
Mathieu 2017/01/13 00:37:35 Aha, good catch! Someone had been coding in Java t
165 g_browser_process->GetApplicationLocale());
160 base::string16 label_value = l10n_util::GetStringFUTF16( 166 base::string16 label_value = l10n_util::GetStringFUTF16(
161 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_TOTAL_FORMAT, 167 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_TOTAL_FORMAT,
162 base::ASCIIToUTF16(request()->details()->total->label), 168 base::UTF8ToUTF16(request()->details()->total->label),
163 base::ASCIIToUTF16(request()->details()->total->amount->currency), 169 base::UTF8ToUTF16(request()->details()->total->amount->currency),
164 base::ASCIIToUTF16(request()->details()->total->amount->value)); 170 formatter->Format(request()->details()->total->amount->value));
165 171
166 return base::MakeUnique<views::Label>(label_value); 172 return base::MakeUnique<views::Label>(label_value);
167 } 173 }
168 174
169 std::unique_ptr<views::Button> 175 std::unique_ptr<views::Button>
170 PaymentSheetViewController::CreatePaymentSheetSummaryRow() { 176 PaymentSheetViewController::CreatePaymentSheetSummaryRow() {
171 std::unique_ptr<views::Button> section = base::MakeUnique<PaymentSheetRow>( 177 std::unique_ptr<views::Button> section = base::MakeUnique<PaymentSheetRow>(
172 this, 178 this,
173 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_NAME), 179 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_NAME),
174 std::unique_ptr<views::View>(nullptr), 180 std::unique_ptr<views::View>(nullptr),
175 CreateOrderSummarySectionContent()); 181 CreateOrderSummarySectionContent());
176 section->set_tag(static_cast<int>( 182 section->set_tag(static_cast<int>(
177 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON)); 183 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON));
178 return section; 184 return section;
179 } 185 }
180 186
181 } // namespace payments 187 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/order_summary_view_controller.cc ('k') | components/payments/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698