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

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

Issue 2956473002: [WebPayments] Order Summary a11y (Closed)
Patch Set: Created 3 years, 6 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 | 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 <limits> 8 #include <limits>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 const base::string16& preview_text, 320 const base::string16& preview_text,
321 const base::string16& format_string, 321 const base::string16& format_string,
322 int n, 322 int n,
323 const base::string16& button_string, 323 const base::string16& button_string,
324 bool button_enabled) { 324 bool button_enabled) {
325 DCHECK(accessible_content_.empty()); 325 DCHECK(accessible_content_.empty());
326 std::unique_ptr<PreviewEliderLabel> content_view = 326 std::unique_ptr<PreviewEliderLabel> content_view =
327 base::MakeUnique<PreviewEliderLabel>(preview_text, format_string, n, 327 base::MakeUnique<PreviewEliderLabel>(preview_text, format_string, n,
328 STYLE_HINT); 328 STYLE_HINT);
329 content_view->SetHorizontalAlignment(gfx::ALIGN_LEFT); 329 content_view->SetHorizontalAlignment(gfx::ALIGN_LEFT);
330 base::string16 accessible_content = 330 return CreateWithButton(std::move(content_view), button_string,
331 content_view->CreateElidedString(std::numeric_limits<int>::max()); 331 button_enabled);
332 return AccessibleContent(accessible_content)
333 .CreateWithButton(std::move(content_view), button_string,
334 button_enabled);
335 } 332 }
336 333
337 private: 334 private:
338 // Creates a row with a button in place of the chevron. 335 // Creates a row with a button in place of the chevron.
339 // +------------------------------------------+ 336 // +------------------------------------------+
340 // | Name | content_view | button_string | 337 // | Name | content_view | button_string |
341 // +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ 338 // +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
342 std::unique_ptr<views::Button> CreateWithButton( 339 std::unique_ptr<views::Button> CreateWithButton(
343 std::unique_ptr<views::View> content_view, 340 std::unique_ptr<views::View> content_view,
344 const base::string16& button_string, 341 const base::string16& button_string,
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 // instead of the list. 662 // instead of the list.
666 builder.Tag(PaymentSheetViewControllerTags::ADD_SHIPPING_BUTTON); 663 builder.Tag(PaymentSheetViewControllerTags::ADD_SHIPPING_BUTTON);
667 return builder.CreateWithButton(base::string16(), 664 return builder.CreateWithButton(base::string16(),
668 l10n_util::GetStringUTF16(IDS_ADD), 665 l10n_util::GetStringUTF16(IDS_ADD),
669 /*button_enabled=*/true); 666 /*button_enabled=*/true);
670 } else if (state()->shipping_profiles().size() == 1) { 667 } else if (state()->shipping_profiles().size() == 1) {
671 base::string16 truncated_content = 668 base::string16 truncated_content =
672 GetShippingAddressLabelFormAutofillProfile( 669 GetShippingAddressLabelFormAutofillProfile(
673 *state()->shipping_profiles()[0], 670 *state()->shipping_profiles()[0],
674 state()->GetApplicationLocale()); 671 state()->GetApplicationLocale());
675 return builder.AccessibleContent(truncated_content) 672 return builder.CreateWithButton(truncated_content,
676 .CreateWithButton(truncated_content, 673 l10n_util::GetStringUTF16(IDS_CHOOSE),
677 l10n_util::GetStringUTF16(IDS_CHOOSE), 674 /*button_enabled=*/true);
678 /*button_enabled=*/true);
679 } else { 675 } else {
680 base::string16 format = l10n_util::GetPluralStringFUTF16( 676 base::string16 format = l10n_util::GetPluralStringFUTF16(
681 IDS_PAYMENT_REQUEST_SHIPPING_ADDRESSES_PREVIEW, 677 IDS_PAYMENT_REQUEST_SHIPPING_ADDRESSES_PREVIEW,
682 state()->shipping_profiles().size() - 1); 678 state()->shipping_profiles().size() - 1);
683 base::string16 label = GetShippingAddressLabelFormAutofillProfile( 679 base::string16 label = GetShippingAddressLabelFormAutofillProfile(
684 *state()->shipping_profiles()[0], state()->GetApplicationLocale()); 680 *state()->shipping_profiles()[0], state()->GetApplicationLocale());
685 return builder.CreateWithButton(label, format, 681 return builder.CreateWithButton(label, format,
686 state()->shipping_profiles().size() - 1, 682 state()->shipping_profiles().size() - 1,
687 l10n_util::GetStringUTF16(IDS_CHOOSE), 683 l10n_util::GetStringUTF16(IDS_CHOOSE),
688 /*button_enabled=*/true); 684 /*button_enabled=*/true);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 std::unique_ptr<views::Label> selected_instrument_sublabel = 723 std::unique_ptr<views::Label> selected_instrument_sublabel =
728 base::MakeUnique<views::Label>(selected_instrument->GetSublabel()); 724 base::MakeUnique<views::Label>(selected_instrument->GetSublabel());
729 selected_instrument_sublabel->SetHorizontalAlignment(gfx::ALIGN_LEFT); 725 selected_instrument_sublabel->SetHorizontalAlignment(gfx::ALIGN_LEFT);
730 layout->AddView(selected_instrument_sublabel.release()); 726 layout->AddView(selected_instrument_sublabel.release());
731 727
732 std::unique_ptr<views::ImageView> card_icon_view = 728 std::unique_ptr<views::ImageView> card_icon_view =
733 CreateInstrumentIconView(selected_instrument->icon_resource_id(), 729 CreateInstrumentIconView(selected_instrument->icon_resource_id(),
734 selected_instrument->GetLabel()); 730 selected_instrument->GetLabel());
735 card_icon_view->SetImageSize(gfx::Size(32, 20)); 731 card_icon_view->SetImageSize(gfx::Size(32, 20));
736 732
737 return builder.Id(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION) 733 return builder.AccessibleContent(selected_instrument->GetLabel())
734 .Id(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION)
738 .CreateWithChevron(std::move(content_view), std::move(card_icon_view)); 735 .CreateWithChevron(std::move(content_view), std::move(card_icon_view));
739 } else { 736 } else {
740 builder.Id(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION_BUTTON); 737 builder.Id(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION_BUTTON);
741 if (state()->available_instruments().empty()) { 738 if (state()->available_instruments().empty()) {
742 // If the button is "Add", navigate to the editor directly. 739 // If the button is "Add", navigate to the editor directly.
743 builder.Tag(PaymentSheetViewControllerTags::ADD_PAYMENT_METHOD_BUTTON); 740 builder.Tag(PaymentSheetViewControllerTags::ADD_PAYMENT_METHOD_BUTTON);
744 return builder.CreateWithButton(base::string16(), 741 return builder.CreateWithButton(base::string16(),
745 l10n_util::GetStringUTF16(IDS_ADD), 742 l10n_util::GetStringUTF16(IDS_ADD),
746 /*button_enabled=*/true); 743 /*button_enabled=*/true);
747 } else if (state()->available_instruments().size() == 1) { 744 } else if (state()->available_instruments().size() == 1) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 builder.Tag(PaymentSheetViewControllerTags::ADD_CONTACT_INFO_BUTTON); 799 builder.Tag(PaymentSheetViewControllerTags::ADD_CONTACT_INFO_BUTTON);
803 return builder.CreateWithButton(base::string16(), 800 return builder.CreateWithButton(base::string16(),
804 l10n_util::GetStringUTF16(IDS_ADD), 801 l10n_util::GetStringUTF16(IDS_ADD),
805 /*button_enabled=*/true); 802 /*button_enabled=*/true);
806 } else if (state()->contact_profiles().size() == 1) { 803 } else if (state()->contact_profiles().size() == 1) {
807 base::string16 truncated_content = 804 base::string16 truncated_content =
808 state()->contact_profiles()[0]->ConstructInferredLabel( 805 state()->contact_profiles()[0]->ConstructInferredLabel(
809 {autofill::NAME_FULL, autofill::PHONE_HOME_WHOLE_NUMBER, 806 {autofill::NAME_FULL, autofill::PHONE_HOME_WHOLE_NUMBER,
810 autofill::EMAIL_ADDRESS}, 807 autofill::EMAIL_ADDRESS},
811 3, state()->GetApplicationLocale()); 808 3, state()->GetApplicationLocale());
812 return builder.AccessibleContent(truncated_content) 809 return builder.CreateWithButton(truncated_content,
813 .CreateWithButton(truncated_content, 810 l10n_util::GetStringUTF16(IDS_CHOOSE),
814 l10n_util::GetStringUTF16(IDS_CHOOSE), 811 /*button_enabled=*/true);
815 /*button_enabled=*/true);
816 } else { 812 } else {
817 base::string16 preview = 813 base::string16 preview =
818 state()->contact_profiles()[0]->ConstructInferredLabel( 814 state()->contact_profiles()[0]->ConstructInferredLabel(
819 {autofill::NAME_FULL, autofill::PHONE_HOME_WHOLE_NUMBER, 815 {autofill::NAME_FULL, autofill::PHONE_HOME_WHOLE_NUMBER,
820 autofill::EMAIL_ADDRESS}, 816 autofill::EMAIL_ADDRESS},
821 6, state()->GetApplicationLocale()); 817 6, state()->GetApplicationLocale());
822 base::string16 format = l10n_util::GetPluralStringFUTF16( 818 base::string16 format = l10n_util::GetPluralStringFUTF16(
823 IDS_PAYMENT_REQUEST_CONTACTS_PREVIEW, 819 IDS_PAYMENT_REQUEST_CONTACTS_PREVIEW,
824 state()->contact_profiles().size() - 1); 820 state()->contact_profiles().size() - 1);
825 return builder.CreateWithButton( 821 return builder.CreateWithButton(
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 data_source_label->SetDefaultStyle(default_style); 943 data_source_label->SetDefaultStyle(default_style);
948 data_source_label->AddStyleRange( 944 data_source_label->AddStyleRange(
949 gfx::Range(link_begin, link_begin + link_length), 945 gfx::Range(link_begin, link_begin + link_length),
950 views::StyledLabel::RangeStyleInfo::CreateForLink()); 946 views::StyledLabel::RangeStyleInfo::CreateForLink());
951 data_source_label->SizeToFit(0); 947 data_source_label->SizeToFit(0);
952 content_view->AddChildView(data_source_label.release()); 948 content_view->AddChildView(data_source_label.release());
953 return content_view; 949 return content_view;
954 } 950 }
955 951
956 } // namespace payments 952 } // namespace payments
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698