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

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

Issue 2849523003: Add billing address as a mandatory field of Payments credit cards. (Closed)
Patch Set: Merge branch 'master' into billing 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 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 26 matching lines...) Expand all
37 37
38 namespace { 38 namespace {
39 39
40 constexpr int kFirstTagValue = static_cast<int>( 40 constexpr int kFirstTagValue = static_cast<int>(
41 payments::PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX); 41 payments::PaymentRequestCommonTags::PAYMENT_REQUEST_COMMON_TAG_MAX);
42 42
43 enum class PaymentMethodViewControllerTags : int { 43 enum class PaymentMethodViewControllerTags : int {
44 // The tag for the button that triggers the "add card" flow. Starts at 44 // The tag for the button that triggers the "add card" flow. Starts at
45 // |kFirstTagValue| not to conflict with tags common to all views. 45 // |kFirstTagValue| not to conflict with tags common to all views.
46 ADD_CREDIT_CARD_BUTTON = kFirstTagValue, 46 ADD_CREDIT_CARD_BUTTON = kFirstTagValue,
47 // This value is passed to inner views so they can use it as a starting tag.
48 MAX_TAG,
47 }; 49 };
48 50
49 class PaymentMethodListItem : public payments::PaymentRequestItemList::Item { 51 class PaymentMethodListItem : public payments::PaymentRequestItemList::Item {
50 public: 52 public:
51 // Does not take ownership of |instrument|, which should not be null and 53 // Does not take ownership of |instrument|, which should not be null and
52 // should outlive this object. |list| is the PaymentRequestItemList object 54 // should outlive this object. |list| is the PaymentRequestItemList object
53 // that will own this. 55 // that will own this.
54 PaymentMethodListItem(PaymentInstrument* instrument, 56 PaymentMethodListItem(PaymentInstrument* instrument,
55 PaymentRequestSpec* spec, 57 PaymentRequestSpec* spec,
56 PaymentRequestState* state, 58 PaymentRequestState* state,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // If an instrument can't be selected, PerformSelectionFallback is called, 121 // If an instrument can't be selected, PerformSelectionFallback is called,
120 // where the instrument can be made complete. 122 // where the instrument can be made complete.
121 return instrument_->IsCompleteForPayment(); 123 return instrument_->IsCompleteForPayment();
122 } 124 }
123 125
124 void PerformSelectionFallback() override { 126 void PerformSelectionFallback() override {
125 switch (instrument_->type()) { 127 switch (instrument_->type()) {
126 case PaymentInstrument::Type::AUTOFILL: 128 case PaymentInstrument::Type::AUTOFILL:
127 // Since we are a list item, we only care about the on_edited callback. 129 // Since we are a list item, we only care about the on_edited callback.
128 dialog_->ShowCreditCardEditor( 130 dialog_->ShowCreditCardEditor(
129 /*on_edited=*/base::BindOnce( 131 BackNavigationType::kPaymentSheet,
130 &PaymentRequestState::SetSelectedInstrument, 132 static_cast<int>(PaymentMethodViewControllerTags::MAX_TAG),
131 base::Unretained(state()), instrument_), 133 /*on_edited=*/
134 base::BindOnce(&PaymentRequestState::SetSelectedInstrument,
135 base::Unretained(state()), instrument_),
132 /*on_added=*/ 136 /*on_added=*/
133 base::OnceCallback<void(const autofill::CreditCard&)>(), 137 base::OnceCallback<void(const autofill::CreditCard&)>(),
134 static_cast<AutofillPaymentInstrument*>(instrument_) 138 static_cast<AutofillPaymentInstrument*>(instrument_)
135 ->credit_card()); 139 ->credit_card());
136 return; 140 return;
137 } 141 }
138 NOTREACHED(); 142 NOTREACHED();
139 } 143 }
140 144
141 PaymentInstrument* instrument_; 145 PaymentInstrument* instrument_;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 return extra_view; 201 return extra_view;
198 } 202 }
199 203
200 void PaymentMethodViewController::ButtonPressed(views::Button* sender, 204 void PaymentMethodViewController::ButtonPressed(views::Button* sender,
201 const ui::Event& event) { 205 const ui::Event& event) {
202 switch (sender->tag()) { 206 switch (sender->tag()) {
203 case static_cast<int>( 207 case static_cast<int>(
204 PaymentMethodViewControllerTags::ADD_CREDIT_CARD_BUTTON): 208 PaymentMethodViewControllerTags::ADD_CREDIT_CARD_BUTTON):
205 // Only provide the |on_added| callback, in response to this button. 209 // Only provide the |on_added| callback, in response to this button.
206 dialog()->ShowCreditCardEditor( 210 dialog()->ShowCreditCardEditor(
211 BackNavigationType::kPaymentSheet,
212 static_cast<int>(PaymentMethodViewControllerTags::MAX_TAG),
207 /*on_edited=*/base::OnceClosure(), 213 /*on_edited=*/base::OnceClosure(),
208 /*on_added=*/ 214 /*on_added=*/
209 base::BindOnce(&PaymentRequestState::AddAutofillPaymentInstrument, 215 base::BindOnce(&PaymentRequestState::AddAutofillPaymentInstrument,
210 base::Unretained(state()), /*selected=*/true), 216 base::Unretained(state()), /*selected=*/true),
211 /*credit_card=*/nullptr); 217 /*credit_card=*/nullptr);
212 break; 218 break;
213 default: 219 default:
214 PaymentRequestSheetController::ButtonPressed(sender, event); 220 PaymentRequestSheetController::ButtonPressed(sender, event);
215 break; 221 break;
216 } 222 }
217 } 223 }
218 224
219 } // namespace payments 225 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698