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

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

Issue 2747943004: [Web Payments] Add the shipping options sheet. (Closed)
Patch Set: Address comments. Created 3 years, 9 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 case static_cast<int>( 294 case static_cast<int>(
295 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON): 295 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON):
296 dialog()->ShowPaymentMethodSheet(); 296 dialog()->ShowPaymentMethodSheet();
297 break; 297 break;
298 298
299 case static_cast<int>( 299 case static_cast<int>(
300 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON): 300 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON):
301 dialog()->ShowContactProfileSheet(); 301 dialog()->ShowContactProfileSheet();
302 break; 302 break;
303 303
304 case static_cast<int>(
305 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON):
306 dialog()->ShowShippingOptionSheet();
307 break;
308
304 default: 309 default:
305 PaymentRequestSheetController::ButtonPressed(sender, event); 310 PaymentRequestSheetController::ButtonPressed(sender, event);
306 break; 311 break;
307 } 312 }
308 } 313 }
309 314
310 void PaymentSheetViewController::UpdatePayButtonState(bool enabled) { 315 void PaymentSheetViewController::UpdatePayButtonState(bool enabled) {
311 pay_button_->SetEnabled(enabled); 316 pay_button_->SetEnabled(enabled);
312 } 317 }
313 318
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CONTACT_INFO_SECTION_NAME), 501 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CONTACT_INFO_SECTION_NAME),
497 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr), 502 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr),
498 widest_name_column_view_width_); 503 widest_name_column_view_width_);
499 section->set_tag(static_cast<int>( 504 section->set_tag(static_cast<int>(
500 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON)); 505 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON));
501 section->set_id( 506 section->set_id(
502 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION)); 507 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION));
503 return section; 508 return section;
504 } 509 }
505 510
506 std::unique_ptr<views::View>
507 PaymentSheetViewController::CreateShippingOptionContent() {
508 std::unique_ptr<views::View> container = base::MakeUnique<views::View>();
509
510 std::unique_ptr<views::BoxLayout> layout =
511 base::MakeUnique<views::BoxLayout>(views::BoxLayout::kVertical, 0, 0, 0);
512 layout->set_cross_axis_alignment(
513 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
514 container->SetLayoutManager(layout.release());
515
516 payments::mojom::PaymentShippingOption* selected_shipping_option =
517 request()->selected_shipping_option();
518 if (selected_shipping_option) {
519 container->AddChildView(
520 new views::Label(base::ASCIIToUTF16(selected_shipping_option->label)));
521 container->AddChildView(
522 new views::Label(request()->GetFormattedCurrencyAmount(
523 selected_shipping_option->amount->value)));
524 }
525
526 return container;
527 }
528
529 std::unique_ptr<views::Button> 511 std::unique_ptr<views::Button>
530 PaymentSheetViewController::CreateShippingOptionRow() { 512 PaymentSheetViewController::CreateShippingOptionRow() {
513 payments::mojom::PaymentShippingOption* selected_option =
514 request()->selected_shipping_option();
515 std::unique_ptr<views::View> option_label = CreateShippingOptionLabel(
516 selected_option, selected_option ? request()->GetFormattedCurrencyAmount(
517 selected_option->amount->value)
518 : base::ASCIIToUTF16(""));
531 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( 519 std::unique_ptr<views::Button> section = CreatePaymentSheetRow(
532 this, GetShippingOptionSectionString(request()->options()->shipping_type), 520 this, GetShippingOptionSectionString(request()->options()->shipping_type),
533 CreateShippingOptionContent(), std::unique_ptr<views::View>(nullptr), 521 std::move(option_label), std::unique_ptr<views::View>(nullptr),
534 widest_name_column_view_width_); 522 widest_name_column_view_width_);
535 section->set_tag(static_cast<int>( 523 section->set_tag(static_cast<int>(
536 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON)); 524 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON));
537 section->set_id( 525 section->set_id(
538 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION)); 526 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION));
539 return section; 527 return section;
540 } 528 }
541 529
542 } // namespace payments 530 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698