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

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: Address comments, icon changes 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
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 87c05d477a79ba551408379b266c853be81fd07b..d4d808bdb10ea46c88f096368a50783b6e0e1704 100644
--- a/chrome/browser/ui/views/payments/payment_method_view_controller.cc
+++ b/chrome/browser/ui/views/payments/payment_method_view_controller.cc
@@ -57,12 +57,33 @@ 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(
+ /*on_edited=*/base::BindOnce(
Evan Stade 2017/05/10 16:06:25 nit: is this the correct format for documenting pa
anthonyvd 2017/05/10 16:39:26 The style guide doesn't specify and there's other
+ &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(
@@ -121,22 +142,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(
- /*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_;

Powered by Google App Engine
This is Rietveld 408576698