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

Unified Diff: chrome/browser/ui/views/payments/payment_method_view_controller.cc

Issue 2872623002: [Web Payments] Add "pencil" edit button to lists. (Closed)
Patch Set: Rebase Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/payment_method_view_controller_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/payments/payment_method_view_controller.cc
diff --git a/chrome/browser/ui/views/payments/payment_method_view_controller.cc b/chrome/browser/ui/views/payments/payment_method_view_controller.cc
index 20dfc7fb63161a86cf82073d6bd9b769a0fca59e..ed9fa979e2082c5156a6ae02a4d36c101255abf8 100644
--- a/chrome/browser/ui/views/payments/payment_method_view_controller.cc
+++ b/chrome/browser/ui/views/payments/payment_method_view_controller.cc
@@ -59,12 +59,35 @@ class PaymentMethodListItem : public payments::PaymentRequestItemList::Item {
PaymentRequestItemList* list,
PaymentRequestDialogView* dialog,
bool selected)
- : payments::PaymentRequestItemList::Item(spec, state, list, selected),
+ : payments::PaymentRequestItemList::Item(spec,
+ state,
+ list,
+ selected,
+ /*show_edit_button=*/true),
instrument_(instrument),
dialog_(dialog) {}
~PaymentMethodListItem() override {}
private:
+ void ShowEditor() {
+ switch (instrument_->type()) {
+ case PaymentInstrument::Type::AUTOFILL:
+ // Since we are a list item, we only care about the on_edited callback.
+ dialog_->ShowCreditCardEditor(
+ BackNavigationType::kPaymentSheet,
+ static_cast<int>(PaymentMethodViewControllerTags::MAX_TAG),
+ /*on_edited=*/
+ base::BindOnce(&PaymentRequestState::SetSelectedInstrument,
+ base::Unretained(state()), instrument_),
+ /*on_added=*/
+ base::OnceCallback<void(const autofill::CreditCard&)>(),
+ static_cast<AutofillPaymentInstrument*>(instrument_)
+ ->credit_card());
+ return;
+ }
+ NOTREACHED();
+ }
+
// payments::PaymentRequestItemList::Item:
std::unique_ptr<views::View> CreateExtraView() override {
std::unique_ptr<views::ImageView> card_icon_view = CreateInstrumentIconView(
@@ -123,24 +146,9 @@ class PaymentMethodListItem : public payments::PaymentRequestItemList::Item {
return instrument_->IsCompleteForPayment();
}
- void PerformSelectionFallback() override {
- switch (instrument_->type()) {
- case PaymentInstrument::Type::AUTOFILL:
- // Since we are a list item, we only care about the on_edited callback.
- dialog_->ShowCreditCardEditor(
- BackNavigationType::kPaymentSheet,
- static_cast<int>(PaymentMethodViewControllerTags::MAX_TAG),
- /*on_edited=*/
- base::BindOnce(&PaymentRequestState::SetSelectedInstrument,
- base::Unretained(state()), instrument_),
- /*on_added=*/
- base::OnceCallback<void(const autofill::CreditCard&)>(),
- static_cast<AutofillPaymentInstrument*>(instrument_)
- ->credit_card());
- return;
- }
- NOTREACHED();
- }
+ void PerformSelectionFallback() override { ShowEditor(); }
+
+ void EditButtonPressed() override { ShowEditor(); }
PaymentInstrument* instrument_;
PaymentRequestDialogView* dialog_;
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/payment_method_view_controller_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698