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

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

Issue 2759253002: [Web Payments] Implement item selection in lists. (Closed)
Patch Set: 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_method_view_controller.h" 5 #include "chrome/browser/ui/views/payments/payment_method_view_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 card_info_container->AddChildView(new views::Label(instrument_->label())); 78 card_info_container->AddChildView(new views::Label(instrument_->label()));
79 card_info_container->AddChildView( 79 card_info_container->AddChildView(
80 new views::Label(instrument_->sublabel())); 80 new views::Label(instrument_->sublabel()));
81 // TODO(anthonyvd): Add the "card is incomplete" label once the 81 // TODO(anthonyvd): Add the "card is incomplete" label once the
82 // completedness logic is implemented. 82 // completedness logic is implemented.
83 return card_info_container; 83 return card_info_container;
84 } 84 }
85 85
86 void SelectedStateChanged() override { 86 void SelectedStateChanged() override {
87 state()->SetSelectedInstrument(instrument_); 87 if (selected())
88 state()->SetSelectedInstrument(instrument_);
88 } 89 }
89 90
90 bool CanBeSelected() const override { 91 bool CanBeSelected() const override {
91 // TODO(anthonyvd): Check for card completedness. 92 // TODO(anthonyvd): Check for card completedness.
92 return true; 93 return true;
93 } 94 }
94 95
95 void PerformSelectionFallback() override { 96 void PerformSelectionFallback() override {
96 // TODO(anthonyvd): Open the editor pre-populated with this card's data. 97 // TODO(anthonyvd): Open the editor pre-populated with this card's data.
97 } 98 }
98 99
99 PaymentInstrument* instrument_; 100 PaymentInstrument* instrument_;
100 std::unique_ptr<views::ImageView> checkmark_; 101 std::unique_ptr<views::ImageView> checkmark_;
101 102
102 DISALLOW_COPY_AND_ASSIGN(PaymentMethodListItem); 103 DISALLOW_COPY_AND_ASSIGN(PaymentMethodListItem);
103 }; 104 };
104 105
105 } // namespace 106 } // namespace
106 107
107 PaymentMethodViewController::PaymentMethodViewController( 108 PaymentMethodViewController::PaymentMethodViewController(
108 PaymentRequestSpec* spec, 109 PaymentRequestSpec* spec,
109 PaymentRequestState* state, 110 PaymentRequestState* state,
110 PaymentRequestDialogView* dialog) 111 PaymentRequestDialogView* dialog)
111 : PaymentRequestSheetController(spec, state, dialog) { 112 : PaymentRequestSheetController(spec, state, dialog),
113 payment_method_list_(dialog) {
112 const std::vector<std::unique_ptr<PaymentInstrument>>& available_instruments = 114 const std::vector<std::unique_ptr<PaymentInstrument>>& available_instruments =
113 state->available_instruments(); 115 state->available_instruments();
114 116
115 for (const std::unique_ptr<PaymentInstrument>& instrument : 117 for (const std::unique_ptr<PaymentInstrument>& instrument :
116 available_instruments) { 118 available_instruments) {
117 std::unique_ptr<PaymentMethodListItem> item = 119 std::unique_ptr<PaymentMethodListItem> item =
118 base::MakeUnique<PaymentMethodListItem>( 120 base::MakeUnique<PaymentMethodListItem>(
119 instrument.get(), spec, state, &payment_method_list_, 121 instrument.get(), spec, state, &payment_method_list_,
120 instrument.get() == state->selected_instrument()); 122 instrument.get() == state->selected_instrument());
121 payment_method_list_.AddItem(std::move(item)); 123 payment_method_list_.AddItem(std::move(item));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 PaymentMethodViewControllerTags::ADD_CREDIT_CARD_BUTTON): 165 PaymentMethodViewControllerTags::ADD_CREDIT_CARD_BUTTON):
164 dialog()->ShowCreditCardEditor(); 166 dialog()->ShowCreditCardEditor();
165 break; 167 break;
166 default: 168 default:
167 PaymentRequestSheetController::ButtonPressed(sender, event); 169 PaymentRequestSheetController::ButtonPressed(sender, event);
168 break; 170 break;
169 } 171 }
170 } 172 }
171 173
172 } // namespace payments 174 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698