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

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

Issue 2735803003: [WebPayments] Extracting common code from Shipping + Contact Info views. (Closed)
Patch Set: monday rebase 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 void PaymentSheetViewController::ButtonPressed( 282 void PaymentSheetViewController::ButtonPressed(
283 views::Button* sender, const ui::Event& event) { 283 views::Button* sender, const ui::Event& event) {
284 switch (sender->tag()) { 284 switch (sender->tag()) {
285 case static_cast<int>( 285 case static_cast<int>(
286 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON): 286 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON):
287 dialog()->ShowOrderSummary(); 287 dialog()->ShowOrderSummary();
288 break; 288 break;
289 289
290 case static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON): 290 case static_cast<int>(PaymentSheetViewControllerTags::SHOW_SHIPPING_BUTTON):
291 dialog()->ShowShippingListSheet(); 291 dialog()->ShowShippingProfileSheet();
292 break; 292 break;
293 293
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()->ShowContactInfoSheet(); 301 dialog()->ShowContactProfileSheet();
302 break; 302 break;
303 303
304 default: 304 default:
305 PaymentRequestSheetController::ButtonPressed(sender, event); 305 PaymentRequestSheetController::ButtonPressed(sender, event);
306 break; 306 break;
307 } 307 }
308 } 308 }
309 309
310 void PaymentSheetViewController::UpdatePayButtonState(bool enabled) { 310 void PaymentSheetViewController::UpdatePayButtonState(bool enabled) {
311 pay_button_->SetEnabled(enabled); 311 pay_button_->SetEnabled(enabled);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON)); 390 PaymentSheetViewControllerTags::SHOW_ORDER_SUMMARY_BUTTON));
391 section->set_id( 391 section->set_id(
392 static_cast<int>(DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION)); 392 static_cast<int>(DialogViewID::PAYMENT_SHEET_SUMMARY_SECTION));
393 return section; 393 return section;
394 } 394 }
395 395
396 std::unique_ptr<views::View> 396 std::unique_ptr<views::View>
397 PaymentSheetViewController::CreateShippingSectionContent() { 397 PaymentSheetViewController::CreateShippingSectionContent() {
398 auto* profile = request()->selected_shipping_profile(); 398 auto* profile = request()->selected_shipping_profile();
399 399
400 // TODO(tmartino): Empty string param is app locale; this should be passed 400 return profile ? payments::GetShippingAddressLabel(
401 // at construct-time and stored as a member in a future CL. 401 AddressStyleType::SUMMARY, request()->locale(), *profile)
402 return profile ? payments::GetShippingAddressLabel(AddressStyleType::SUMMARY,
403 std::string(), *profile)
404 : base::MakeUnique<views::Label>(base::string16()); 402 : base::MakeUnique<views::Label>(base::string16());
405 } 403 }
406 404
407 // Creates the Shipping row, which contains a "Shipping address" label, the 405 // Creates the Shipping row, which contains a "Shipping address" label, the
408 // user's selected shipping address, and a chevron. 406 // user's selected shipping address, and a chevron.
409 // +----------------------------------------------+ 407 // +----------------------------------------------+
410 // | Shipping Address Barack Obama | 408 // | Shipping Address Barack Obama |
411 // | 1600 Pennsylvania Ave. > | 409 // | 1600 Pennsylvania Ave. > |
412 // | 1800MYPOTUS | 410 // | 1800MYPOTUS |
413 // +----------------------------------------------+ 411 // +----------------------------------------------+
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 section->set_tag(static_cast<int>( 466 section->set_tag(static_cast<int>(
469 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON)); 467 PaymentSheetViewControllerTags::SHOW_PAYMENT_METHOD_BUTTON));
470 section->set_id( 468 section->set_id(
471 static_cast<int>(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION)); 469 static_cast<int>(DialogViewID::PAYMENT_SHEET_PAYMENT_METHOD_SECTION));
472 return section; 470 return section;
473 } 471 }
474 472
475 std::unique_ptr<views::View> 473 std::unique_ptr<views::View>
476 PaymentSheetViewController::CreateContactInfoSectionContent() { 474 PaymentSheetViewController::CreateContactInfoSectionContent() {
477 auto* profile = request()->selected_contact_profile(); 475 auto* profile = request()->selected_contact_profile();
478 // TODO(tmartino): Replace empty string with app locale. 476
479 return profile ? payments::GetContactInfoLabel(AddressStyleType::SUMMARY, 477 return profile ? payments::GetContactInfoLabel(
480 std::string(), *profile, true, 478 AddressStyleType::SUMMARY, request()->locale(), *profile,
481 true, true) 479 request()->request_payer_name(),
480 request()->request_payer_phone(),
481 request()->request_payer_email())
482 : base::MakeUnique<views::Label>(base::string16()); 482 : base::MakeUnique<views::Label>(base::string16());
483 } 483 }
484 484
485 // Creates the Contact Info row, which contains a "Contact info" label; the 485 // Creates the Contact Info row, which contains a "Contact info" label; the
486 // name, email address, and/or phone number; and a chevron. 486 // name, email address, and/or phone number; and a chevron.
487 // +----------------------------------------------+ 487 // +----------------------------------------------+
488 // | Contact info Barack Obama | 488 // | Contact info Barack Obama |
489 // | 1800MYPOTUS > | 489 // | 1800MYPOTUS > |
490 // | potus@whitehouse.gov | 490 // | potus@whitehouse.gov |
491 // +----------------------------------------------+ 491 // +----------------------------------------------+
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 CreateShippingOptionContent(), std::unique_ptr<views::View>(nullptr), 533 CreateShippingOptionContent(), std::unique_ptr<views::View>(nullptr),
534 widest_name_column_view_width_); 534 widest_name_column_view_width_);
535 section->set_tag(static_cast<int>( 535 section->set_tag(static_cast<int>(
536 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON)); 536 PaymentSheetViewControllerTags::SHOW_SHIPPING_OPTION_BUTTON));
537 section->set_id( 537 section->set_id(
538 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION)); 538 static_cast<int>(DialogViewID::PAYMENT_SHEET_SHIPPING_OPTION_SECTION));
539 return section; 539 return section;
540 } 540 }
541 541
542 } // namespace payments 542 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698