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

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

Issue 2830053002: [Web Payments] Correctly use UTF8ToUTF16 on strings from website. (Closed)
Patch Set: 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
« no previous file with comments | « chrome/browser/ui/views/payments/payment_request_views_util.cc ('k') | no next file » | 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/payment_sheet_view_controller.h" 5 #include "chrome/browser/ui/views/payments/payment_sheet_view_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 const std::vector<mojom::PaymentItemPtr>& items = 422 const std::vector<mojom::PaymentItemPtr>& items =
423 spec()->details().display_items; 423 spec()->details().display_items;
424 // The inline items section contains the first 2 display items of the 424 // The inline items section contains the first 2 display items of the
425 // request's details, followed by a label indicating "N more items..." if 425 // request's details, followed by a label indicating "N more items..." if
426 // there are more than 2 items in the details. The total label and amount 426 // there are more than 2 items in the details. The total label and amount
427 // always follow. 427 // always follow.
428 constexpr int kMaxNumberOfItemsShown = 2; 428 constexpr int kMaxNumberOfItemsShown = 2;
429 for (size_t i = 0; i < items.size() && i < kMaxNumberOfItemsShown; ++i) { 429 for (size_t i = 0; i < items.size() && i < kMaxNumberOfItemsShown; ++i) {
430 item_summaries_layout->StartRow(0, 0); 430 item_summaries_layout->StartRow(0, 0);
431 item_summaries_layout->AddView( 431 item_summaries_layout->AddView(
432 new views::Label(base::ASCIIToUTF16(items[i]->label))); 432 new views::Label(base::UTF8ToUTF16(items[i]->label)));
433 433
434 item_amounts_layout->StartRow(0, 0); 434 item_amounts_layout->StartRow(0, 0);
435 item_amounts_layout->AddView(new views::Label( 435 item_amounts_layout->AddView(new views::Label(
436 spec()->GetFormattedCurrencyAmount(items[i]->amount->value))); 436 spec()->GetFormattedCurrencyAmount(items[i]->amount->value)));
437 } 437 }
438 438
439 int hidden_item_count = items.size() - kMaxNumberOfItemsShown; 439 int hidden_item_count = items.size() - kMaxNumberOfItemsShown;
440 if (hidden_item_count > 0) { 440 if (hidden_item_count > 0) {
441 item_summaries_layout->StartRow(0, 0); 441 item_summaries_layout->StartRow(0, 0);
442 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>( 442 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>(
443 l10n_util::GetStringFUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_MORE_ITEMS, 443 l10n_util::GetStringFUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_MORE_ITEMS,
444 base::IntToString16(hidden_item_count))); 444 base::IntToString16(hidden_item_count)));
445 label->SetDisabledColor(label->GetNativeTheme()->GetSystemColor( 445 label->SetDisabledColor(label->GetNativeTheme()->GetSystemColor(
446 ui::NativeTheme::kColorId_LabelDisabledColor)); 446 ui::NativeTheme::kColorId_LabelDisabledColor));
447 label->SetEnabled(false); 447 label->SetEnabled(false);
448 item_summaries_layout->AddView(label.release()); 448 item_summaries_layout->AddView(label.release());
449 449
450 item_amounts_layout->StartRow(0, 0); 450 item_amounts_layout->StartRow(0, 0);
451 item_amounts_layout->AddView(new views::Label(base::ASCIIToUTF16(""))); 451 item_amounts_layout->AddView(new views::Label(base::ASCIIToUTF16("")));
452 } 452 }
453 453
454 item_summaries_layout->StartRow(0, 0); 454 item_summaries_layout->StartRow(0, 0);
455 item_summaries_layout->AddView( 455 item_summaries_layout->AddView(
456 CreateBoldLabel(base::ASCIIToUTF16(spec()->details().total->label)) 456 CreateBoldLabel(base::UTF8ToUTF16(spec()->details().total->label))
457 .release()); 457 .release());
458 458
459 item_amounts_layout->StartRow(0, 0); 459 item_amounts_layout->StartRow(0, 0);
460 item_amounts_layout->AddView( 460 item_amounts_layout->AddView(
461 CreateBoldLabel(l10n_util::GetStringFUTF16( 461 CreateBoldLabel(l10n_util::GetStringFUTF16(
462 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SHEET_TOTAL_FORMAT, 462 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SHEET_TOTAL_FORMAT,
463 base::UTF8ToUTF16(spec()->GetFormattedCurrencyCode()), 463 base::UTF8ToUTF16(spec()->GetFormattedCurrencyCode()),
464 spec()->GetFormattedCurrencyAmount( 464 spec()->GetFormattedCurrencyAmount(
465 spec()->details().total->amount->value))) 465 spec()->details().total->amount->value)))
466 .release()); 466 .release());
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON), 680 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON),
681 static_cast<int>( 681 static_cast<int>(
682 DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON), 682 DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON),
683 widest_name_column_view_width_); 683 widest_name_column_view_width_);
684 } 684 }
685 685
686 return section; 686 return section;
687 } 687 }
688 688
689 } // namespace payments 689 } // namespace payments
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/payments/payment_request_views_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698