| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" | 19 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" |
| 20 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" | 20 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
| 21 #include "chrome/browser/ui/views/payments/payment_request_row_view.h" | 21 #include "chrome/browser/ui/views/payments/payment_request_row_view.h" |
| 22 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" | 22 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" |
| 23 #include "chrome/grit/chromium_strings.h" | 23 #include "chrome/grit/chromium_strings.h" |
| 24 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
| 25 #include "chrome/grit/theme_resources.h" | 25 #include "chrome/grit/theme_resources.h" |
| 26 #include "components/autofill/core/browser/autofill_type.h" | 26 #include "components/autofill/core/browser/autofill_type.h" |
| 27 #include "components/autofill/core/browser/credit_card.h" | 27 #include "components/autofill/core/browser/credit_card.h" |
| 28 #include "components/autofill/core/browser/field_types.h" | 28 #include "components/autofill/core/browser/field_types.h" |
| 29 #include "components/autofill/core/browser/personal_data_manager.h" | 29 #include "components/autofill/core/browser/personal_data_manager.h" |
| 30 #include "components/payments/content/payment_request_spec.h" |
| 30 #include "components/payments/core/currency_formatter.h" | 31 #include "components/payments/core/currency_formatter.h" |
| 31 #include "components/strings/grit/components_strings.h" | 32 #include "components/strings/grit/components_strings.h" |
| 32 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
| 33 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 34 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
| 35 #include "ui/gfx/color_utils.h" | 36 #include "ui/gfx/color_utils.h" |
| 36 #include "ui/gfx/font.h" | 37 #include "ui/gfx/font.h" |
| 37 #include "ui/gfx/paint_vector_icon.h" | 38 #include "ui/gfx/paint_vector_icon.h" |
| 38 #include "ui/gfx/range/range.h" | 39 #include "ui/gfx/range/range.h" |
| 39 #include "ui/views/controls/button/md_text_button.h" | 40 #include "ui/views/controls/button/md_text_button.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 187 } |
| 187 | 188 |
| 188 } // namespace | 189 } // namespace |
| 189 | 190 |
| 190 PaymentSheetViewController::PaymentSheetViewController( | 191 PaymentSheetViewController::PaymentSheetViewController( |
| 191 PaymentRequest* request, | 192 PaymentRequest* request, |
| 192 PaymentRequestDialogView* dialog) | 193 PaymentRequestDialogView* dialog) |
| 193 : PaymentRequestSheetController(request, dialog), | 194 : PaymentRequestSheetController(request, dialog), |
| 194 pay_button_(nullptr), | 195 pay_button_(nullptr), |
| 195 widest_name_column_view_width_(ComputeWidestNameColumnViewWidth()) { | 196 widest_name_column_view_width_(ComputeWidestNameColumnViewWidth()) { |
| 196 request->AddObserver(this); | 197 request->state()->AddObserver(this); |
| 197 } | 198 } |
| 198 | 199 |
| 199 PaymentSheetViewController::~PaymentSheetViewController() { | 200 PaymentSheetViewController::~PaymentSheetViewController() { |
| 200 request()->RemoveObserver(this); | 201 request()->state()->RemoveObserver(this); |
| 201 } | 202 } |
| 202 | 203 |
| 203 std::unique_ptr<views::View> PaymentSheetViewController::CreateView() { | 204 std::unique_ptr<views::View> PaymentSheetViewController::CreateView() { |
| 204 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); | 205 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); |
| 205 | 206 |
| 206 views::GridLayout* layout = new views::GridLayout(content_view.get()); | 207 views::GridLayout* layout = new views::GridLayout(content_view.get()); |
| 207 content_view->SetLayoutManager(layout); | 208 content_view->SetLayoutManager(layout); |
| 208 views::ColumnSet* columns = layout->AddColumnSet(0); | 209 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 209 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, | 210 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, |
| 210 1, views::GridLayout::USE_PREF, 0, 0); | 211 1, views::GridLayout::USE_PREF, 0, 0); |
| 211 | 212 |
| 212 // The shipping address and contact info rows are optional. | 213 // The shipping address and contact info rows are optional. |
| 213 layout->StartRow(0, 0); | 214 layout->StartRow(0, 0); |
| 214 layout->AddView(CreatePaymentSheetSummaryRow().release()); | 215 layout->AddView(CreatePaymentSheetSummaryRow().release()); |
| 215 | 216 |
| 216 if (request()->request_shipping()) { | 217 if (request()->spec()->request_shipping()) { |
| 217 layout->StartRow(0, 0); | 218 layout->StartRow(0, 0); |
| 218 layout->AddView(CreateShippingRow().release()); | 219 layout->AddView(CreateShippingRow().release()); |
| 219 layout->StartRow(0, 0); | 220 layout->StartRow(0, 0); |
| 220 layout->AddView(CreateShippingOptionRow().release()); | 221 layout->AddView(CreateShippingOptionRow().release()); |
| 221 } | 222 } |
| 222 layout->StartRow(0, 0); | 223 layout->StartRow(0, 0); |
| 223 layout->AddView(CreatePaymentMethodRow().release()); | 224 layout->AddView(CreatePaymentMethodRow().release()); |
| 224 if (request()->request_payer_name() || request()->request_payer_email() || | 225 if (request()->spec()->request_payer_name() || |
| 225 request()->request_payer_phone()) { | 226 request()->spec()->request_payer_email() || |
| 227 request()->spec()->request_payer_phone()) { |
| 226 layout->StartRow(0, 0); | 228 layout->StartRow(0, 0); |
| 227 layout->AddView(CreateContactInfoRow().release()); | 229 layout->AddView(CreateContactInfoRow().release()); |
| 228 } | 230 } |
| 229 | 231 |
| 230 return CreatePaymentView( | 232 return CreatePaymentView( |
| 231 CreateSheetHeaderView( | 233 CreateSheetHeaderView( |
| 232 false, | 234 false, |
| 233 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_PAYMENT_SHEET_TITLE), | 235 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_PAYMENT_SHEET_TITLE), |
| 234 this), | 236 this), |
| 235 std::move(content_view)); | 237 std::move(content_view)); |
| 236 } | 238 } |
| 237 | 239 |
| 238 void PaymentSheetViewController::OnSelectedInformationChanged() { | 240 void PaymentSheetViewController::OnSelectedInformationChanged() { |
| 239 UpdatePayButtonState(request()->is_ready_to_pay()); | 241 UpdatePayButtonState(request()->state()->is_ready_to_pay()); |
| 240 } | 242 } |
| 241 | 243 |
| 242 std::unique_ptr<views::Button> | 244 std::unique_ptr<views::Button> |
| 243 PaymentSheetViewController::CreatePrimaryButton() { | 245 PaymentSheetViewController::CreatePrimaryButton() { |
| 244 std::unique_ptr<views::Button> button( | 246 std::unique_ptr<views::Button> button( |
| 245 views::MdTextButton::CreateSecondaryUiBlueButton( | 247 views::MdTextButton::CreateSecondaryUiBlueButton( |
| 246 this, l10n_util::GetStringUTF16(IDS_PAYMENTS_PAY_BUTTON))); | 248 this, l10n_util::GetStringUTF16(IDS_PAYMENTS_PAY_BUTTON))); |
| 247 button->set_tag(static_cast<int>(PaymentRequestCommonTags::PAY_BUTTON_TAG)); | 249 button->set_tag(static_cast<int>(PaymentRequestCommonTags::PAY_BUTTON_TAG)); |
| 248 button->set_id(static_cast<int>(DialogViewID::PAY_BUTTON)); | 250 button->set_id(static_cast<int>(DialogViewID::PAY_BUTTON)); |
| 249 pay_button_ = button.get(); | 251 pay_button_ = button.get(); |
| 250 UpdatePayButtonState(request()->is_ready_to_pay()); | 252 UpdatePayButtonState(request()->state()->is_ready_to_pay()); |
| 251 return button; | 253 return button; |
| 252 } | 254 } |
| 253 | 255 |
| 254 // Adds the product logo to the footer. | 256 // Adds the product logo to the footer. |
| 255 // +---------------------------------------------------------+ | 257 // +---------------------------------------------------------+ |
| 256 // | (•) chrome | PAY | CANCEL | | 258 // | (•) chrome | PAY | CANCEL | |
| 257 // +---------------------------------------------------------+ | 259 // +---------------------------------------------------------+ |
| 258 std::unique_ptr<views::View> | 260 std::unique_ptr<views::View> |
| 259 PaymentSheetViewController::CreateExtraFooterView() { | 261 PaymentSheetViewController::CreateExtraFooterView() { |
| 260 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); | 262 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 std::unique_ptr<views::GridLayout> item_summaries_layout = | 327 std::unique_ptr<views::GridLayout> item_summaries_layout = |
| 326 CreateOrderSummarySectionContainerLayout(item_summaries.get(), | 328 CreateOrderSummarySectionContainerLayout(item_summaries.get(), |
| 327 /* trailing =*/false); | 329 /* trailing =*/false); |
| 328 | 330 |
| 329 std::unique_ptr<views::View> item_amounts = base::MakeUnique<views::View>(); | 331 std::unique_ptr<views::View> item_amounts = base::MakeUnique<views::View>(); |
| 330 std::unique_ptr<views::GridLayout> item_amounts_layout = | 332 std::unique_ptr<views::GridLayout> item_amounts_layout = |
| 331 CreateOrderSummarySectionContainerLayout(item_amounts.get(), | 333 CreateOrderSummarySectionContainerLayout(item_amounts.get(), |
| 332 /* trailing =*/true); | 334 /* trailing =*/true); |
| 333 | 335 |
| 334 const std::vector<mojom::PaymentItemPtr>& items = | 336 const std::vector<mojom::PaymentItemPtr>& items = |
| 335 request()->details()->display_items; | 337 request()->spec()->details()->display_items; |
| 336 // The inline items section contains the first 2 display items of the | 338 // The inline items section contains the first 2 display items of the |
| 337 // request's details, followed by a label indicating "N more items..." if | 339 // request's details, followed by a label indicating "N more items..." if |
| 338 // there are more than 2 items in the details. The total label and amount | 340 // there are more than 2 items in the details. The total label and amount |
| 339 // always follow. | 341 // always follow. |
| 340 constexpr int kMaxNumberOfItemsShown = 2; | 342 constexpr int kMaxNumberOfItemsShown = 2; |
| 341 for (size_t i = 0; i < items.size() && i < kMaxNumberOfItemsShown; ++i) { | 343 for (size_t i = 0; i < items.size() && i < kMaxNumberOfItemsShown; ++i) { |
| 342 item_summaries_layout->StartRow(0, 0); | 344 item_summaries_layout->StartRow(0, 0); |
| 343 item_summaries_layout->AddView( | 345 item_summaries_layout->AddView( |
| 344 new views::Label(base::ASCIIToUTF16(items[i]->label))); | 346 new views::Label(base::ASCIIToUTF16(items[i]->label))); |
| 345 | 347 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 358 ui::NativeTheme::kColorId_LabelDisabledColor)); | 360 ui::NativeTheme::kColorId_LabelDisabledColor)); |
| 359 label->SetEnabled(false); | 361 label->SetEnabled(false); |
| 360 item_summaries_layout->AddView(label.release()); | 362 item_summaries_layout->AddView(label.release()); |
| 361 | 363 |
| 362 item_amounts_layout->StartRow(0, 0); | 364 item_amounts_layout->StartRow(0, 0); |
| 363 item_amounts_layout->AddView(new views::Label(base::ASCIIToUTF16(""))); | 365 item_amounts_layout->AddView(new views::Label(base::ASCIIToUTF16(""))); |
| 364 } | 366 } |
| 365 | 367 |
| 366 item_summaries_layout->StartRow(0, 0); | 368 item_summaries_layout->StartRow(0, 0); |
| 367 item_summaries_layout->AddView( | 369 item_summaries_layout->AddView( |
| 368 CreateBoldLabel(base::ASCIIToUTF16(request()->details()->total->label)) | 370 CreateBoldLabel( |
| 371 base::ASCIIToUTF16(request()->spec()->details()->total->label)) |
| 369 .release()); | 372 .release()); |
| 370 | 373 |
| 371 item_amounts_layout->StartRow(0, 0); | 374 item_amounts_layout->StartRow(0, 0); |
| 372 item_amounts_layout->AddView( | 375 item_amounts_layout->AddView( |
| 373 CreateBoldLabel( | 376 CreateBoldLabel( |
| 374 l10n_util::GetStringFUTF16( | 377 l10n_util::GetStringFUTF16( |
| 375 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SHEET_TOTAL_FORMAT, | 378 IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SHEET_TOTAL_FORMAT, |
| 376 base::UTF8ToUTF16(request()->GetFormattedCurrencyCode()), | 379 base::UTF8ToUTF16(request()->GetFormattedCurrencyCode()), |
| 377 request()->GetFormattedCurrencyAmount( | 380 request()->GetFormattedCurrencyAmount( |
| 378 request()->details()->total->amount->value))) | 381 request()->spec()->details()->total->amount->value))) |
| 379 .release()); | 382 .release()); |
| 380 | 383 |
| 381 item_summaries->SetLayoutManager(item_summaries_layout.release()); | 384 item_summaries->SetLayoutManager(item_summaries_layout.release()); |
| 382 item_amounts->SetLayoutManager(item_amounts_layout.release()); | 385 item_amounts->SetLayoutManager(item_amounts_layout.release()); |
| 383 | 386 |
| 384 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( | 387 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( |
| 385 this, | 388 this, |
| 386 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_NAME), | 389 l10n_util::GetStringUTF16(IDS_PAYMENT_REQUEST_ORDER_SUMMARY_SECTION_NAME), |
| 387 std::move(item_summaries), std::move(item_amounts), | 390 std::move(item_summaries), std::move(item_amounts), |
| 388 widest_name_column_view_width_); | 391 widest_name_column_view_width_); |
| 389 section->set_tag(static_cast<int>( | 392 section->set_tag(static_cast<int>( |
| 390 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON)); | 393 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON)); |
| 391 section->set_id( | 394 section->set_id( |
| 392 static_cast<int>(DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION)); | 395 static_cast<int>(DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION)); |
| 393 return section; | 396 return section; |
| 394 } | 397 } |
| 395 | 398 |
| 396 std::unique_ptr<views::View> | 399 std::unique_ptr<views::View> |
| 397 PaymentSheetViewController::CreateShippingSectionContent() { | 400 PaymentSheetViewController::CreateShippingSectionContent() { |
| 398 auto* profile = request()->selected_shipping_profile(); | 401 auto* profile = request()->state()->selected_shipping_profile(); |
| 399 | 402 |
| 400 return profile ? payments::GetShippingAddressLabel( | 403 return profile ? payments::GetShippingAddressLabel( |
| 401 AddressStyleType::SUMMARY, request()->locale(), *profile) | 404 AddressStyleType::SUMMARY, |
| 405 request()->GetApplicationLocale(), *profile) |
| 402 : base::MakeUnique<views::Label>(base::string16()); | 406 : base::MakeUnique<views::Label>(base::string16()); |
| 403 } | 407 } |
| 404 | 408 |
| 405 // Creates the Shipping row, which contains a "Shipping address" label, the | 409 // Creates the Shipping row, which contains a "Shipping address" label, the |
| 406 // user's selected shipping address, and a chevron. | 410 // user's selected shipping address, and a chevron. |
| 407 // +----------------------------------------------+ | 411 // +----------------------------------------------+ |
| 408 // | Shipping Address Barack Obama | | 412 // | Shipping Address Barack Obama | |
| 409 // | 1600 Pennsylvania Ave. > | | 413 // | 1600 Pennsylvania Ave. > | |
| 410 // | 1800MYPOTUS | | 414 // | 1800MYPOTUS | |
| 411 // +----------------------------------------------+ | 415 // +----------------------------------------------+ |
| 412 std::unique_ptr<views::Button> PaymentSheetViewController::CreateShippingRow() { | 416 std::unique_ptr<views::Button> PaymentSheetViewController::CreateShippingRow() { |
| 413 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( | 417 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( |
| 414 this, | 418 this, |
| 415 GetShippingAddressSectionString(request()->options()->shipping_type), | 419 GetShippingAddressSectionString( |
| 420 request()->spec()->options()->shipping_type), |
| 416 CreateShippingSectionContent(), std::unique_ptr<views::View>(nullptr), | 421 CreateShippingSectionContent(), std::unique_ptr<views::View>(nullptr), |
| 417 widest_name_column_view_width_); | 422 widest_name_column_view_width_); |
| 418 section->set_tag( | 423 section->set_tag( |
| 419 static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON)); | 424 static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON)); |
| 420 section->set_id( | 425 section->set_id( |
| 421 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_SECTION)); | 426 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_SECTION)); |
| 422 return section; | 427 return section; |
| 423 } | 428 } |
| 424 | 429 |
| 425 // Creates the Payment Method row, which contains a "Payment" label, the user's | 430 // Creates the Payment Method row, which contains a "Payment" label, the user's |
| 426 // masked Credit Card details, the icon for the selected card, and a chevron. | 431 // masked Credit Card details, the icon for the selected card, and a chevron. |
| 427 // +----------------------------------------------+ | 432 // +----------------------------------------------+ |
| 428 // | Payment Visa ****0000 | | 433 // | Payment Visa ****0000 | |
| 429 // | John Smith | VISA | > | | 434 // | John Smith | VISA | > | |
| 430 // | | | 435 // | | |
| 431 // +----------------------------------------------+ | 436 // +----------------------------------------------+ |
| 432 std::unique_ptr<views::Button> | 437 std::unique_ptr<views::Button> |
| 433 PaymentSheetViewController::CreatePaymentMethodRow() { | 438 PaymentSheetViewController::CreatePaymentMethodRow() { |
| 434 autofill::CreditCard* selected_card = request()->selected_credit_card(); | 439 autofill::CreditCard* selected_card = |
| 440 request()->state()->selected_credit_card(); |
| 435 | 441 |
| 436 std::unique_ptr<views::View> content_view; | 442 std::unique_ptr<views::View> content_view; |
| 437 std::unique_ptr<views::ImageView> card_icon_view; | 443 std::unique_ptr<views::ImageView> card_icon_view; |
| 438 if (selected_card) { | 444 if (selected_card) { |
| 439 content_view = base::MakeUnique<views::View>(); | 445 content_view = base::MakeUnique<views::View>(); |
| 440 | 446 |
| 441 views::GridLayout* layout = new views::GridLayout(content_view.get()); | 447 views::GridLayout* layout = new views::GridLayout(content_view.get()); |
| 442 content_view->SetLayoutManager(layout); | 448 content_view->SetLayoutManager(layout); |
| 443 views::ColumnSet* columns = layout->AddColumnSet(0); | 449 views::ColumnSet* columns = layout->AddColumnSet(0); |
| 444 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, | 450 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 465 widest_name_column_view_width_); | 471 widest_name_column_view_width_); |
| 466 section->set_tag(static_cast<int>( | 472 section->set_tag(static_cast<int>( |
| 467 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON)); | 473 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON)); |
| 468 section->set_id( | 474 section->set_id( |
| 469 static_cast<int>(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION)); | 475 static_cast<int>(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION)); |
| 470 return section; | 476 return section; |
| 471 } | 477 } |
| 472 | 478 |
| 473 std::unique_ptr<views::View> | 479 std::unique_ptr<views::View> |
| 474 PaymentSheetViewController::CreateContactInfoSectionContent() { | 480 PaymentSheetViewController::CreateContactInfoSectionContent() { |
| 475 auto* profile = request()->selected_contact_profile(); | 481 auto* profile = request()->state()->selected_contact_profile(); |
| 476 | 482 |
| 477 return profile ? payments::GetContactInfoLabel( | 483 return profile |
| 478 AddressStyleType::SUMMARY, request()->locale(), *profile, | 484 ? payments::GetContactInfoLabel( |
| 479 request()->request_payer_name(), | 485 AddressStyleType::SUMMARY, request()->GetApplicationLocale(), |
| 480 request()->request_payer_phone(), | 486 *profile, request()->spec()->request_payer_name(), |
| 481 request()->request_payer_email()) | 487 request()->spec()->request_payer_phone(), |
| 482 : base::MakeUnique<views::Label>(base::string16()); | 488 request()->spec()->request_payer_email()) |
| 489 : base::MakeUnique<views::Label>(base::string16()); |
| 483 } | 490 } |
| 484 | 491 |
| 485 // Creates the Contact Info row, which contains a "Contact info" label; the | 492 // Creates the Contact Info row, which contains a "Contact info" label; the |
| 486 // name, email address, and/or phone number; and a chevron. | 493 // name, email address, and/or phone number; and a chevron. |
| 487 // +----------------------------------------------+ | 494 // +----------------------------------------------+ |
| 488 // | Contact info Barack Obama | | 495 // | Contact info Barack Obama | |
| 489 // | 1800MYPOTUS > | | 496 // | 1800MYPOTUS > | |
| 490 // | potus@whitehouse.gov | | 497 // | potus@whitehouse.gov | |
| 491 // +----------------------------------------------+ | 498 // +----------------------------------------------+ |
| 492 std::unique_ptr<views::Button> | 499 std::unique_ptr<views::Button> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 507 PaymentSheetViewController::CreateShippingOptionContent() { | 514 PaymentSheetViewController::CreateShippingOptionContent() { |
| 508 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); | 515 std::unique_ptr<views::View> container = base::MakeUnique<views::View>(); |
| 509 | 516 |
| 510 std::unique_ptr<views::BoxLayout> layout = | 517 std::unique_ptr<views::BoxLayout> layout = |
| 511 base::MakeUnique<views::BoxLayout>(views::BoxLayout::kVertical, 0, 0, 0); | 518 base::MakeUnique<views::BoxLayout>(views::BoxLayout::kVertical, 0, 0, 0); |
| 512 layout->set_cross_axis_alignment( | 519 layout->set_cross_axis_alignment( |
| 513 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); | 520 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); |
| 514 container->SetLayoutManager(layout.release()); | 521 container->SetLayoutManager(layout.release()); |
| 515 | 522 |
| 516 payments::mojom::PaymentShippingOption* selected_shipping_option = | 523 payments::mojom::PaymentShippingOption* selected_shipping_option = |
| 517 request()->selected_shipping_option(); | 524 request()->state()->selected_shipping_option(); |
| 518 if (selected_shipping_option) { | 525 if (selected_shipping_option) { |
| 519 container->AddChildView( | 526 container->AddChildView( |
| 520 new views::Label(base::ASCIIToUTF16(selected_shipping_option->label))); | 527 new views::Label(base::ASCIIToUTF16(selected_shipping_option->label))); |
| 521 container->AddChildView( | 528 container->AddChildView( |
| 522 new views::Label(request()->GetFormattedCurrencyAmount( | 529 new views::Label(request()->GetFormattedCurrencyAmount( |
| 523 selected_shipping_option->amount->value))); | 530 selected_shipping_option->amount->value))); |
| 524 } | 531 } |
| 525 | 532 |
| 526 return container; | 533 return container; |
| 527 } | 534 } |
| 528 | 535 |
| 529 std::unique_ptr<views::Button> | 536 std::unique_ptr<views::Button> |
| 530 PaymentSheetViewController::CreateShippingOptionRow() { | 537 PaymentSheetViewController::CreateShippingOptionRow() { |
| 531 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( | 538 std::unique_ptr<views::Button> section = CreatePaymentSheetRow( |
| 532 this, GetShippingOptionSectionString(request()->options()->shipping_type), | 539 this, |
| 540 GetShippingOptionSectionString( |
| 541 request()->spec()->options()->shipping_type), |
| 533 CreateShippingOptionContent(), std::unique_ptr<views::View>(nullptr), | 542 CreateShippingOptionContent(), std::unique_ptr<views::View>(nullptr), |
| 534 widest_name_column_view_width_); | 543 widest_name_column_view_width_); |
| 535 section->set_tag(static_cast<int>( | 544 section->set_tag(static_cast<int>( |
| 536 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON)); | 545 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON)); |
| 537 section->set_id( | 546 section->set_id( |
| 538 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION)); | 547 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION)); |
| 539 return section; | 548 return section; |
| 540 } | 549 } |
| 541 | 550 |
| 542 } // namespace payments | 551 } // namespace payments |
| OLD | NEW |