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