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

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

Issue 2774233005: Creating PaymentOptionsProvider interface (Closed)
Patch Set: rouslan comments 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
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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 412
413 // Creates the Shipping row, which contains a "Shipping address" label, the 413 // Creates the Shipping row, which contains a "Shipping address" label, the
414 // user's selected shipping address, and a chevron. 414 // user's selected shipping address, and a chevron.
415 // +----------------------------------------------+ 415 // +----------------------------------------------+
416 // | Shipping Address Barack Obama | 416 // | Shipping Address Barack Obama |
417 // | 1600 Pennsylvania Ave. > | 417 // | 1600 Pennsylvania Ave. > |
418 // | 1800MYPOTUS | 418 // | 1800MYPOTUS |
419 // +----------------------------------------------+ 419 // +----------------------------------------------+
420 std::unique_ptr<views::Button> PaymentSheetViewController::CreateShippingRow() { 420 std::unique_ptr<views::Button> PaymentSheetViewController::CreateShippingRow() {
421 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( 421 std::unique_ptr<views::Button> section = CreatePaymentSheetRow(
422 this, GetShippingAddressSectionString(spec()->options().shipping_type), 422 this, GetShippingAddressSectionString(spec()->shipping_type()),
423 CreateShippingSectionContent(), std::unique_ptr<views::View>(nullptr), 423 CreateShippingSectionContent(), std::unique_ptr<views::View>(nullptr),
424 widest_name_column_view_width_); 424 widest_name_column_view_width_);
425 section->set_tag( 425 section->set_tag(
426 static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON)); 426 static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON));
427 section->set_id( 427 section->set_id(
428 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_SECTION)); 428 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_SECTION));
429 return section; 429 return section;
430 } 430 }
431 431
432 // Creates the Payment Method row, which contains a "Payment" label, the user's 432 // Creates the Payment Method row, which contains a "Payment" label, the user's
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 section->set_tag(static_cast<int>( 471 section->set_tag(static_cast<int>(
472 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON)); 472 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON));
473 section->set_id( 473 section->set_id(
474 static_cast<int>(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION)); 474 static_cast<int>(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION));
475 return section; 475 return section;
476 } 476 }
477 477
478 std::unique_ptr<views::View> 478 std::unique_ptr<views::View>
479 PaymentSheetViewController::CreateContactInfoSectionContent() { 479 PaymentSheetViewController::CreateContactInfoSectionContent() {
480 autofill::AutofillProfile* profile = state()->selected_contact_profile(); 480 autofill::AutofillProfile* profile = state()->selected_contact_profile();
481 return profile 481 return profile ? payments::GetContactInfoLabel(
482 ? payments::GetContactInfoLabel( 482 AddressStyleType::SUMMARY,
483 AddressStyleType::SUMMARY, state()->GetApplicationLocale(), 483 state()->GetApplicationLocale(), *profile, *spec())
484 *profile, spec()->request_payer_name(), 484 : base::MakeUnique<views::Label>(base::string16());
485 spec()->request_payer_phone(), spec()->request_payer_email())
486 : base::MakeUnique<views::Label>(base::string16());
487 } 485 }
488 486
489 // Creates the Contact Info row, which contains a "Contact info" label; the 487 // Creates the Contact Info row, which contains a "Contact info" label; the
490 // name, email address, and/or phone number; and a chevron. 488 // name, email address, and/or phone number; and a chevron.
491 // +----------------------------------------------+ 489 // +----------------------------------------------+
492 // | Contact info Barack Obama | 490 // | Contact info Barack Obama |
493 // | 1800MYPOTUS > | 491 // | 1800MYPOTUS > |
494 // | potus@whitehouse.gov | 492 // | potus@whitehouse.gov |
495 // +----------------------------------------------+ 493 // +----------------------------------------------+
496 std::unique_ptr<views::Button> 494 std::unique_ptr<views::Button>
(...skipping 12 matching lines...) Expand all
509 507
510 std::unique_ptr<views::Button> 508 std::unique_ptr<views::Button>
511 PaymentSheetViewController::CreateShippingOptionRow() { 509 PaymentSheetViewController::CreateShippingOptionRow() {
512 payments::mojom::PaymentShippingOption* selected_option = 510 payments::mojom::PaymentShippingOption* selected_option =
513 state()->selected_shipping_option(); 511 state()->selected_shipping_option();
514 std::unique_ptr<views::View> option_label = CreateShippingOptionLabel( 512 std::unique_ptr<views::View> option_label = CreateShippingOptionLabel(
515 selected_option, selected_option ? spec()->GetFormattedCurrencyAmount( 513 selected_option, selected_option ? spec()->GetFormattedCurrencyAmount(
516 selected_option->amount->value) 514 selected_option->amount->value)
517 : base::ASCIIToUTF16("")); 515 : base::ASCIIToUTF16(""));
518 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( 516 std::unique_ptr<views::Button> section = CreatePaymentSheetRow(
519 this, GetShippingOptionSectionString(spec()->options().shipping_type), 517 this, GetShippingOptionSectionString(spec()->shipping_type()),
520 std::move(option_label), std::unique_ptr<views::View>(nullptr), 518 std::move(option_label), std::unique_ptr<views::View>(nullptr),
521 widest_name_column_view_width_); 519 widest_name_column_view_width_);
522 section->set_tag(static_cast<int>( 520 section->set_tag(static_cast<int>(
523 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON)); 521 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON));
524 section->set_id( 522 section->set_id(
525 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION)); 523 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION));
526 return section; 524 return section;
527 } 525 }
528 526
529 } // namespace payments 527 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698