| OLD | NEW |
| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 columns->AddColumn( | 183 columns->AddColumn( |
| 184 trailing ? views::GridLayout::TRAILING : views::GridLayout::LEADING, | 184 trailing ? views::GridLayout::TRAILING : views::GridLayout::LEADING, |
| 185 views::GridLayout::LEADING, 1, views::GridLayout::USE_PREF, 0, 0); | 185 views::GridLayout::LEADING, 1, views::GridLayout::USE_PREF, 0, 0); |
| 186 | 186 |
| 187 return layout; | 187 return layout; |
| 188 } | 188 } |
| 189 | 189 |
| 190 } // namespace | 190 } // namespace |
| 191 | 191 |
| 192 PaymentSheetViewController::PaymentSheetViewController( | 192 PaymentSheetViewController::PaymentSheetViewController( |
| 193 PaymentRequest* request, | 193 PaymentRequestSpec* spec, |
| 194 PaymentRequestState* state, |
| 194 PaymentRequestDialogView* dialog) | 195 PaymentRequestDialogView* dialog) |
| 195 : PaymentRequestSheetController(request, dialog), | 196 : PaymentRequestSheetController(spec, state, dialog), |
| 196 pay_button_(nullptr), | 197 pay_button_(nullptr), |
| 197 widest_name_column_view_width_(ComputeWidestNameColumnViewWidth()) { | 198 widest_name_column_view_width_(ComputeWidestNameColumnViewWidth()) { |
| 198 request->state()->AddObserver(this); | 199 state->AddObserver(this); |
| 199 } | 200 } |
| 200 | 201 |
| 201 PaymentSheetViewController::~PaymentSheetViewController() { | 202 PaymentSheetViewController::~PaymentSheetViewController() { |
| 202 request()->state()->RemoveObserver(this); | 203 state()->RemoveObserver(this); |
| 203 } | 204 } |
| 204 | 205 |
| 205 std::unique_ptr<views::View> PaymentSheetViewController::CreateView() { | 206 std::unique_ptr<views::View> PaymentSheetViewController::CreateView() { |
| 206 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); | 207 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); |
| 207 | 208 |
| 208 views::GridLayout* layout = new views::GridLayout(content_view.get()); | 209 views::GridLayout* layout = new views::GridLayout(content_view.get()); |
| 209 content_view->SetLayoutManager(layout); | 210 content_view->SetLayoutManager(layout); |
| 210 views::ColumnSet* columns = layout->AddColumnSet(0); | 211 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 211 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, | 212 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, |
| 212 1, views::GridLayout::USE_PREF, 0, 0); | 213 1, views::GridLayout::USE_PREF, 0, 0); |
| 213 | 214 |
| 214 // The shipping address and contact info rows are optional. | 215 // The shipping address and contact info rows are optional. |
| 215 layout->StartRow(0, 0); | 216 layout->StartRow(0, 0); |
| 216 layout->AddView(CreatePaymentSheetSummaryRow().release()); | 217 layout->AddView(CreatePaymentSheetSummaryRow().release()); |
| 217 | 218 |
| 218 if (request()->spec()->request_shipping()) { | 219 if (spec()->request_shipping()) { |
| 219 layout->StartRow(0, 0); | 220 layout->StartRow(0, 0); |
| 220 layout->AddView(CreateShippingRow().release()); | 221 layout->AddView(CreateShippingRow().release()); |
| 221 layout->StartRow(0, 0); | 222 layout->StartRow(0, 0); |
| 222 layout->AddView(CreateShippingOptionRow().release()); | 223 layout->AddView(CreateShippingOptionRow().release()); |
| 223 } | 224 } |
| 224 layout->StartRow(0, 0); | 225 layout->StartRow(0, 0); |
| 225 layout->AddView(CreatePaymentMethodRow().release()); | 226 layout->AddView(CreatePaymentMethodRow().release()); |
| 226 if (request()->spec()->request_payer_name() || | 227 if (spec()->request_payer_name() || spec()->request_payer_email() || |
| 227 request()->spec()->request_payer_email() || | 228 spec()->request_payer_phone()) { |
| 228 request()->spec()->request_payer_phone()) { | |
| 229 layout->StartRow(0, 0); | 229 layout->StartRow(0, 0); |
| 230 layout->AddView(CreateContactInfoRow().release()); | 230 layout->AddView(CreateContactInfoRow().release()); |
| 231 } | 231 } |
| 232 | 232 |
| 233 return CreatePaymentView( | 233 return CreatePaymentView( |
| 234 CreateSheetHeaderView( | 234 CreateSheetHeaderView( |
| 235 false, | 235 false, |
| 236 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_PAYMENT_SHEET_TITLE), | 236 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_PAYMENT_SHEET_TITLE), |
| 237 this), | 237 this), |
| 238 std::move(content_view)); | 238 std::move(content_view)); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void PaymentSheetViewController::OnSelectedInformationChanged() { | 241 void PaymentSheetViewController::OnSelectedInformationChanged() { |
| 242 UpdatePayButtonState(request()->state()->is_ready_to_pay()); | 242 UpdatePayButtonState(state()->is_ready_to_pay()); |
| 243 } | 243 } |
| 244 | 244 |
| 245 std::unique_ptr<views::Button> | 245 std::unique_ptr<views::Button> |
| 246 PaymentSheetViewController::CreatePrimaryButton() { | 246 PaymentSheetViewController::CreatePrimaryButton() { |
| 247 std::unique_ptr<views::Button> button( | 247 std::unique_ptr<views::Button> button( |
| 248 views::MdTextButton::CreateSecondaryUiBlueButton( | 248 views::MdTextButton::CreateSecondaryUiBlueButton( |
| 249 this, l10n_util::GetStringUTF16(IDS_PAYMENTS_PAY_BUTTON))); | 249 this, l10n_util::GetStringUTF16(IDS_PAYMENTS_PAY_BUTTON))); |
| 250 button->set_tag(static_cast<int>(PaymentRequestCommonTags::PAY_BUTTON_TAG)); | 250 button->set_tag(static_cast<int>(PaymentRequestCommonTags::PAY_BUTTON_TAG)); |
| 251 button->set_id(static_cast<int>(DialogViewID::PAY_BUTTON)); | 251 button->set_id(static_cast<int>(DialogViewID::PAY_BUTTON)); |
| 252 pay_button_ = button.get(); | 252 pay_button_ = button.get(); |
| 253 UpdatePayButtonState(request()->state()->is_ready_to_pay()); | 253 UpdatePayButtonState(state()->is_ready_to_pay()); |
| 254 return button; | 254 return button; |
| 255 } | 255 } |
| 256 | 256 |
| 257 // Adds the product logo to the footer. | 257 // Adds the product logo to the footer. |
| 258 // +---------------------------------------------------------+ | 258 // +---------------------------------------------------------+ |
| 259 // | (•) chrome | PAY | CANCEL | | 259 // | (•) chrome | PAY | CANCEL | |
| 260 // +---------------------------------------------------------+ | 260 // +---------------------------------------------------------+ |
| 261 std::unique_ptr<views::View> | 261 std::unique_ptr<views::View> |
| 262 PaymentSheetViewController::CreateExtraFooterView() { | 262 PaymentSheetViewController::CreateExtraFooterView() { |
| 263 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); | 263 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 std::unique_ptr<views::GridLayout> item_summaries_layout = | 333 std::unique_ptr<views::GridLayout> item_summaries_layout = |
| 334 CreateOrderSummarySectionContainerLayout(item_summaries.get(), | 334 CreateOrderSummarySectionContainerLayout(item_summaries.get(), |
| 335 /* trailing =*/false); | 335 /* trailing =*/false); |
| 336 | 336 |
| 337 std::unique_ptr<views::View> item_amounts = base::MakeUnique<views::View>(); | 337 std::unique_ptr<views::View> item_amounts = base::MakeUnique<views::View>(); |
| 338 std::unique_ptr<views::GridLayout> item_amounts_layout = | 338 std::unique_ptr<views::GridLayout> item_amounts_layout = |
| 339 CreateOrderSummarySectionContainerLayout(item_amounts.get(), | 339 CreateOrderSummarySectionContainerLayout(item_amounts.get(), |
| 340 /* trailing =*/true); | 340 /* trailing =*/true); |
| 341 | 341 |
| 342 const std::vector<mojom::PaymentItemPtr>& items = | 342 const std::vector<mojom::PaymentItemPtr>& items = |
| 343 request()->spec()->details().display_items; | 343 spec()->details().display_items; |
| 344 // The inline items section contains the first 2 display items of the | 344 // The inline items section contains the first 2 display items of the |
| 345 // request's details, followed by a label indicating "N more items..." if | 345 // request's details, followed by a label indicating "N more items..." if |
| 346 // there are more than 2 items in the details. The total label and amount | 346 // there are more than 2 items in the details. The total label and amount |
| 347 // always follow. | 347 // always follow. |
| 348 constexpr int kMaxNumberOfItemsShown = 2; | 348 constexpr int kMaxNumberOfItemsShown = 2; |
| 349 for (size_t i = 0; i < items.size() && i < kMaxNumberOfItemsShown; ++i) { | 349 for (size_t i = 0; i < items.size() && i < kMaxNumberOfItemsShown; ++i) { |
| 350 item_summaries_layout->StartRow(0, 0); | 350 item_summaries_layout->StartRow(0, 0); |
| 351 item_summaries_layout->AddView( | 351 item_summaries_layout->AddView( |
| 352 new views::Label(base::ASCIIToUTF16(items[i]->label))); | 352 new views::Label(base::ASCIIToUTF16(items[i]->label))); |
| 353 | 353 |
| 354 item_amounts_layout->StartRow(0, 0); | 354 item_amounts_layout->StartRow(0, 0); |
| 355 item_amounts_layout->AddView( | 355 item_amounts_layout->AddView(new views::Label( |
| 356 new views::Label(request()->spec()->GetFormattedCurrencyAmount( | 356 spec()->GetFormattedCurrencyAmount(items[i]->amount->value))); |
| 357 items[i]->amount->value))); | |
| 358 } | 357 } |
| 359 | 358 |
| 360 int hidden_item_count = items.size() - kMaxNumberOfItemsShown; | 359 int hidden_item_count = items.size() - kMaxNumberOfItemsShown; |
| 361 if (hidden_item_count > 0) { | 360 if (hidden_item_count > 0) { |
| 362 item_summaries_layout->StartRow(0, 0); | 361 item_summaries_layout->StartRow(0, 0); |
| 363 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>( | 362 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>( |
| 364 l10n_util::GetStringFUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_MORE_ITEMS, | 363 l10n_util::GetStringFUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_MORE_ITEMS, |
| 365 base::IntToString16(hidden_item_count))); | 364 base::IntToString16(hidden_item_count))); |
| 366 label->SetDisabledColor(label->GetNativeTheme()->GetSystemColor( | 365 label->SetDisabledColor(label->GetNativeTheme()->GetSystemColor( |
| 367 ui::NativeTheme::kColorId_LabelDisabledColor)); | 366 ui::NativeTheme::kColorId_LabelDisabledColor)); |
| 368 label->SetEnabled(false); | 367 label->SetEnabled(false); |
| 369 item_summaries_layout->AddView(label.release()); | 368 item_summaries_layout->AddView(label.release()); |
| 370 | 369 |
| 371 item_amounts_layout->StartRow(0, 0); | 370 item_amounts_layout->StartRow(0, 0); |
| 372 item_amounts_layout->AddView(new views::Label(base::ASCIIToUTF16(""))); | 371 item_amounts_layout->AddView(new views::Label(base::ASCIIToUTF16(""))); |
| 373 } | 372 } |
| 374 | 373 |
| 375 item_summaries_layout->StartRow(0, 0); | 374 item_summaries_layout->StartRow(0, 0); |
| 376 item_summaries_layout->AddView( | 375 item_summaries_layout->AddView( |
| 377 CreateBoldLabel( | 376 CreateBoldLabel(base::ASCIIToUTF16(spec()->details().total->label)) |
| 378 base::ASCIIToUTF16(request()->spec()->details().total->label)) | |
| 379 .release()); | 377 .release()); |
| 380 | 378 |
| 381 item_amounts_layout->StartRow(0, 0); | 379 item_amounts_layout->StartRow(0, 0); |
| 382 item_amounts_layout->AddView( | 380 item_amounts_layout->AddView( |
| 383 CreateBoldLabel( | 381 CreateBoldLabel(l10n_util::GetStringFUTF16( |
| 384 l10n_util::GetStringFUTF16( | 382 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SHEET_TOTAL_FORMAT, |
| 385 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SHEET_TOTAL_FORMAT, | 383 base::UTF8ToUTF16(spec()->GetFormattedCurrencyCode()), |
| 386 base::UTF8ToUTF16(request()->spec()->GetFormattedCurrencyCode()), | 384 spec()->GetFormattedCurrencyAmount( |
| 387 request()->spec()->GetFormattedCurrencyAmount( | 385 spec()->details().total->amount->value))) |
| 388 request()->spec()->details().total->amount->value))) | |
| 389 .release()); | 386 .release()); |
| 390 | 387 |
| 391 item_summaries->SetLayoutManager(item_summaries_layout.release()); | 388 item_summaries->SetLayoutManager(item_summaries_layout.release()); |
| 392 item_amounts->SetLayoutManager(item_amounts_layout.release()); | 389 item_amounts->SetLayoutManager(item_amounts_layout.release()); |
| 393 | 390 |
| 394 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( | 391 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( |
| 395 this, | 392 this, |
| 396 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_NAME), | 393 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_NAME), |
| 397 std::move(item_summaries), std::move(item_amounts), | 394 std::move(item_summaries), std::move(item_amounts), |
| 398 widest_name_column_view_width_); | 395 widest_name_column_view_width_); |
| 399 section->set_tag(static_cast<int>( | 396 section->set_tag(static_cast<int>( |
| 400 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON)); | 397 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON)); |
| 401 section->set_id( | 398 section->set_id( |
| 402 static_cast<int>(DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION)); | 399 static_cast<int>(DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION)); |
| 403 return section; | 400 return section; |
| 404 } | 401 } |
| 405 | 402 |
| 406 std::unique_ptr<views::View> | 403 std::unique_ptr<views::View> |
| 407 PaymentSheetViewController::CreateShippingSectionContent() { | 404 PaymentSheetViewController::CreateShippingSectionContent() { |
| 408 auto* profile = request()->state()->selected_shipping_profile(); | 405 auto* profile = state()->selected_shipping_profile(); |
| 409 | 406 |
| 410 return profile ? payments::GetShippingAddressLabel( | 407 return profile ? payments::GetShippingAddressLabel( |
| 411 AddressStyleType::SUMMARY, | 408 AddressStyleType::SUMMARY, |
| 412 request()->state()->GetApplicationLocale(), *profile) | 409 state()->GetApplicationLocale(), *profile) |
| 413 : base::MakeUnique<views::Label>(base::string16()); | 410 : base::MakeUnique<views::Label>(base::string16()); |
| 414 } | 411 } |
| 415 | 412 |
| 416 // Creates the Shipping row, which contains a "Shipping address" label, the | 413 // Creates the Shipping row, which contains a "Shipping address" label, the |
| 417 // user's selected shipping address, and a chevron. | 414 // user's selected shipping address, and a chevron. |
| 418 // +----------------------------------------------+ | 415 // +----------------------------------------------+ |
| 419 // | Shipping Address Barack Obama | | 416 // | Shipping Address Barack Obama | |
| 420 // | 1600 Pennsylvania Ave. > | | 417 // | 1600 Pennsylvania Ave. > | |
| 421 // | 1800MYPOTUS | | 418 // | 1800MYPOTUS | |
| 422 // +----------------------------------------------+ | 419 // +----------------------------------------------+ |
| 423 std::unique_ptr<views::Button> PaymentSheetViewController::CreateShippingRow() { | 420 std::unique_ptr<views::Button> PaymentSheetViewController::CreateShippingRow() { |
| 424 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( | 421 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( |
| 425 this, | 422 this, GetShippingAddressSectionString(spec()->options().shipping_type), |
| 426 GetShippingAddressSectionString( | |
| 427 request()->spec()->options().shipping_type), | |
| 428 CreateShippingSectionContent(), std::unique_ptr<views::View>(nullptr), | 423 CreateShippingSectionContent(), std::unique_ptr<views::View>(nullptr), |
| 429 widest_name_column_view_width_); | 424 widest_name_column_view_width_); |
| 430 section->set_tag( | 425 section->set_tag( |
| 431 static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON)); | 426 static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON)); |
| 432 section->set_id( | 427 section->set_id( |
| 433 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_SECTION)); | 428 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_SECTION)); |
| 434 return section; | 429 return section; |
| 435 } | 430 } |
| 436 | 431 |
| 437 // 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 |
| 438 // masked Credit Card details, the icon for the selected card, and a chevron. | 433 // masked Credit Card details, the icon for the selected card, and a chevron. |
| 439 // +----------------------------------------------+ | 434 // +----------------------------------------------+ |
| 440 // | Payment Visa ****0000 | | 435 // | Payment Visa ****0000 | |
| 441 // | John Smith | VISA | > | | 436 // | John Smith | VISA | > | |
| 442 // | | | 437 // | | |
| 443 // +----------------------------------------------+ | 438 // +----------------------------------------------+ |
| 444 std::unique_ptr<views::Button> | 439 std::unique_ptr<views::Button> |
| 445 PaymentSheetViewController::CreatePaymentMethodRow() { | 440 PaymentSheetViewController::CreatePaymentMethodRow() { |
| 446 autofill::CreditCard* selected_card = | 441 autofill::CreditCard* selected_card = state()->selected_credit_card(); |
| 447 request()->state()->selected_credit_card(); | |
| 448 | 442 |
| 449 std::unique_ptr<views::View> content_view; | 443 std::unique_ptr<views::View> content_view; |
| 450 std::unique_ptr<views::ImageView> card_icon_view; | 444 std::unique_ptr<views::ImageView> card_icon_view; |
| 451 if (selected_card) { | 445 if (selected_card) { |
| 452 content_view = base::MakeUnique<views::View>(); | 446 content_view = base::MakeUnique<views::View>(); |
| 453 | 447 |
| 454 views::GridLayout* layout = new views::GridLayout(content_view.get()); | 448 views::GridLayout* layout = new views::GridLayout(content_view.get()); |
| 455 content_view->SetLayoutManager(layout); | 449 content_view->SetLayoutManager(layout); |
| 456 views::ColumnSet* columns = layout->AddColumnSet(0); | 450 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 457 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, | 451 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 478 widest_name_column_view_width_); | 472 widest_name_column_view_width_); |
| 479 section->set_tag(static_cast<int>( | 473 section->set_tag(static_cast<int>( |
| 480 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON)); | 474 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON)); |
| 481 section->set_id( | 475 section->set_id( |
| 482 static_cast<int>(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION)); | 476 static_cast<int>(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION)); |
| 483 return section; | 477 return section; |
| 484 } | 478 } |
| 485 | 479 |
| 486 std::unique_ptr<views::View> | 480 std::unique_ptr<views::View> |
| 487 PaymentSheetViewController::CreateContactInfoSectionContent() { | 481 PaymentSheetViewController::CreateContactInfoSectionContent() { |
| 488 autofill::AutofillProfile* profile = | 482 autofill::AutofillProfile* profile = state()->selected_contact_profile(); |
| 489 request()->state()->selected_contact_profile(); | 483 return profile |
| 490 return profile ? payments::GetContactInfoLabel( | 484 ? payments::GetContactInfoLabel( |
| 491 AddressStyleType::SUMMARY, | 485 AddressStyleType::SUMMARY, state()->GetApplicationLocale(), |
| 492 request()->state()->GetApplicationLocale(), *profile, | 486 *profile, spec()->request_payer_name(), |
| 493 request()->spec()->request_payer_name(), | 487 spec()->request_payer_phone(), spec()->request_payer_email()) |
| 494 request()->spec()->request_payer_phone(), | 488 : base::MakeUnique<views::Label>(base::string16()); |
| 495 request()->spec()->request_payer_email()) | |
| 496 : base::MakeUnique<views::Label>(base::string16()); | |
| 497 } | 489 } |
| 498 | 490 |
| 499 // Creates the Contact Info row, which contains a "Contact info" label; the | 491 // Creates the Contact Info row, which contains a "Contact info" label; the |
| 500 // name, email address, and/or phone number; and a chevron. | 492 // name, email address, and/or phone number; and a chevron. |
| 501 // +----------------------------------------------+ | 493 // +----------------------------------------------+ |
| 502 // | Contact info Barack Obama | | 494 // | Contact info Barack Obama | |
| 503 // | 1800MYPOTUS > | | 495 // | 1800MYPOTUS > | |
| 504 // | potus@whitehouse.gov | | 496 // | potus@whitehouse.gov | |
| 505 // +----------------------------------------------+ | 497 // +----------------------------------------------+ |
| 506 std::unique_ptr<views::Button> | 498 std::unique_ptr<views::Button> |
| 507 PaymentSheetViewController::CreateContactInfoRow() { | 499 PaymentSheetViewController::CreateContactInfoRow() { |
| 508 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( | 500 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( |
| 509 this, | 501 this, |
| 510 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CONTACT_INFO_SECTION_NAME), | 502 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_CONTACT_INFO_SECTION_NAME), |
| 511 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr), | 503 CreateContactInfoSectionContent(), std::unique_ptr<views::View>(nullptr), |
| 512 widest_name_column_view_width_); | 504 widest_name_column_view_width_); |
| 513 section->set_tag(static_cast<int>( | 505 section->set_tag(static_cast<int>( |
| 514 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON)); | 506 PaymentSheetViewControllerTags::SHOW_CONTACT_INFO_BUTTON)); |
| 515 section->set_id( | 507 section->set_id( |
| 516 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION)); | 508 static_cast<int>(DialogViewID::PAYMENT_SHEET_CONTACT_INFO_SECTION)); |
| 517 return section; | 509 return section; |
| 518 } | 510 } |
| 519 | 511 |
| 520 std::unique_ptr<views::Button> | 512 std::unique_ptr<views::Button> |
| 521 PaymentSheetViewController::CreateShippingOptionRow() { | 513 PaymentSheetViewController::CreateShippingOptionRow() { |
| 522 payments::mojom::PaymentShippingOption* selected_option = | 514 payments::mojom::PaymentShippingOption* selected_option = |
| 523 request()->state()->selected_shipping_option(); | 515 state()->selected_shipping_option(); |
| 524 std::unique_ptr<views::View> option_label = CreateShippingOptionLabel( | 516 std::unique_ptr<views::View> option_label = CreateShippingOptionLabel( |
| 525 selected_option, selected_option | 517 selected_option, selected_option ? spec()->GetFormattedCurrencyAmount( |
| 526 ? request()->spec()->GetFormattedCurrencyAmount( | 518 selected_option->amount->value) |
| 527 selected_option->amount->value) | 519 : base::ASCIIToUTF16("")); |
| 528 : base::ASCIIToUTF16("")); | |
| 529 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( | 520 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( |
| 530 this, | 521 this, GetShippingOptionSectionString(spec()->options().shipping_type), |
| 531 GetShippingOptionSectionString( | |
| 532 request()->spec()->options().shipping_type), | |
| 533 std::move(option_label), std::unique_ptr<views::View>(nullptr), | 522 std::move(option_label), std::unique_ptr<views::View>(nullptr), |
| 534 widest_name_column_view_width_); | 523 widest_name_column_view_width_); |
| 535 section->set_tag(static_cast<int>( | 524 section->set_tag(static_cast<int>( |
| 536 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON)); | 525 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON)); |
| 537 section->set_id( | 526 section->set_id( |
| 538 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION)); | 527 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION)); |
| 539 return section; | 528 return section; |
| 540 } | 529 } |
| 541 | 530 |
| 542 } // namespace payments | 531 } // namespace payments |
| OLD | NEW |