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

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

Issue 2847813003: [Web Payments] Fix alignment of certain Payment Sheet labels. (Closed)
Patch Set: Apply the same treatment to the shipping option labels Created 3 years, 7 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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 532
533 const std::vector<mojom::PaymentItemPtr>& items = 533 const std::vector<mojom::PaymentItemPtr>& items =
534 spec()->details().display_items; 534 spec()->details().display_items;
535 // The inline items section contains the first 2 display items of the 535 // The inline items section contains the first 2 display items of the
536 // request's details, followed by a label indicating "N more items..." if 536 // request's details, followed by a label indicating "N more items..." if
537 // there are more than 2 items in the details. The total label and amount 537 // there are more than 2 items in the details. The total label and amount
538 // always follow. 538 // always follow.
539 constexpr int kMaxNumberOfItemsShown = 2; 539 constexpr int kMaxNumberOfItemsShown = 2;
540 for (size_t i = 0; i < items.size() && i < kMaxNumberOfItemsShown; ++i) { 540 for (size_t i = 0; i < items.size() && i < kMaxNumberOfItemsShown; ++i) {
541 item_summaries_layout->StartRow(0, 0); 541 item_summaries_layout->StartRow(0, 0);
542 item_summaries_layout->AddView( 542 std::unique_ptr<views::Label> summary =
543 new views::Label(base::UTF8ToUTF16(items[i]->label))); 543 base::MakeUnique<views::Label>(base::UTF8ToUTF16(items[i]->label));
544 summary->SetHorizontalAlignment(gfx::ALIGN_LEFT);
545 item_summaries_layout->AddView(summary.release());
544 546
545 item_amounts_layout->StartRow(0, 0); 547 item_amounts_layout->StartRow(0, 0);
546 item_amounts_layout->AddView(new views::Label( 548 item_amounts_layout->AddView(new views::Label(
547 spec()->GetFormattedCurrencyAmount(items[i]->amount->value))); 549 spec()->GetFormattedCurrencyAmount(items[i]->amount->value)));
548 } 550 }
549 551
550 int hidden_item_count = items.size() - kMaxNumberOfItemsShown; 552 int hidden_item_count = items.size() - kMaxNumberOfItemsShown;
551 if (hidden_item_count > 0) { 553 if (hidden_item_count > 0) {
552 item_summaries_layout->StartRow(0, 0); 554 item_summaries_layout->StartRow(0, 0);
553 std::unique_ptr<views::Label> label = 555 std::unique_ptr<views::Label> label =
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 if (selected_instrument) { 684 if (selected_instrument) {
683 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); 685 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>();
684 686
685 views::GridLayout* layout = new views::GridLayout(content_view.get()); 687 views::GridLayout* layout = new views::GridLayout(content_view.get());
686 content_view->SetLayoutManager(layout); 688 content_view->SetLayoutManager(layout);
687 views::ColumnSet* columns = layout->AddColumnSet(0); 689 views::ColumnSet* columns = layout->AddColumnSet(0);
688 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, 690 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
689 1, views::GridLayout::USE_PREF, 0, 0); 691 1, views::GridLayout::USE_PREF, 0, 0);
690 692
691 layout->StartRow(0, 0); 693 layout->StartRow(0, 0);
692 layout->AddView(new views::Label(selected_instrument->label())); 694 std::unique_ptr<views::Label> selected_instrument_label =
695 base::MakeUnique<views::Label>(selected_instrument->label());
696 selected_instrument_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
697 layout->AddView(selected_instrument_label.release());
698
693 layout->StartRow(0, 0); 699 layout->StartRow(0, 0);
694 layout->AddView(new views::Label(selected_instrument->sublabel())); 700 std::unique_ptr<views::Label> selected_instrument_sublabel =
701 base::MakeUnique<views::Label>(selected_instrument->sublabel());
702 selected_instrument_sublabel->SetHorizontalAlignment(gfx::ALIGN_LEFT);
703 layout->AddView(selected_instrument_sublabel.release());
695 704
696 std::unique_ptr<views::ImageView> card_icon_view = CreateInstrumentIconView( 705 std::unique_ptr<views::ImageView> card_icon_view = CreateInstrumentIconView(
697 selected_instrument->icon_resource_id(), selected_instrument->label()); 706 selected_instrument->icon_resource_id(), selected_instrument->label());
698 card_icon_view->SetImageSize(gfx::Size(32, 20)); 707 card_icon_view->SetImageSize(gfx::Size(32, 20));
699 708
700 return builder.Id(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION) 709 return builder.Id(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION)
701 .CreateWithChevron(std::move(content_view), std::move(card_icon_view)); 710 .CreateWithChevron(std::move(content_view), std::move(card_icon_view));
702 } else { 711 } else {
703 builder.Id(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION_BUTTON); 712 builder.Id(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION_BUTTON);
704 base::string16 button_string = state()->available_instruments().size() 713 base::string16 button_string = state()->available_instruments().size()
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 } else { 854 } else {
846 return builder 855 return builder
847 .Id(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON) 856 .Id(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION_BUTTON)
848 .CreateWithButton( 857 .CreateWithButton(
849 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CHOOSE_AN_ADDRESS), 858 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CHOOSE_AN_ADDRESS),
850 l10n_util::GetStringUTF16(IDS_CHOOSE), /*button_enabled=*/false); 859 l10n_util::GetStringUTF16(IDS_CHOOSE), /*button_enabled=*/false);
851 } 860 }
852 } 861 }
853 862
854 } // namespace payments 863 } // 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