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

Side by Side Diff: chrome/browser/ui/views/payments/credit_card_editor_view_controller.h

Issue 2849523003: Add billing address as a mandatory field of Payments credit cards. (Closed)
Patch Set: Components Unittests fix 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 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "chrome/browser/ui/views/payments/editor_view_controller.h" 15 #include "chrome/browser/ui/views/payments/editor_view_controller.h"
16 #include "chrome/browser/ui/views/payments/validation_delegate.h" 16 #include "chrome/browser/ui/views/payments/validation_delegate.h"
17 #include "ui/base/models/simple_combobox_model.h" 17 #include "ui/base/models/simple_combobox_model.h"
18 18
19 namespace autofill { 19 namespace autofill {
20 class AutofillProfile;
20 class CreditCard; 21 class CreditCard;
21 } // namespace autofill 22 } // namespace autofill
22 23
23 namespace payments { 24 namespace payments {
24 25
25 class PaymentRequestSpec; 26 class PaymentRequestSpec;
26 class PaymentRequestState; 27 class PaymentRequestState;
27 class PaymentRequestDialogView; 28 class PaymentRequestDialogView;
28 29
29 // Credit card editor screen of the Payment Request flow. 30 // Credit card editor screen of the Payment Request flow.
30 class CreditCardEditorViewController : public EditorViewController { 31 class CreditCardEditorViewController : public EditorViewController {
31 public: 32 public:
32 // Does not take ownership of the arguments (except for the |on_edited| and 33 // Does not take ownership of the arguments (except for the |on_edited| and
33 // |on_added| callbacks), which should outlive this object. Additionally, 34 // |on_added| callbacks), which should outlive this object. Additionally,
34 // |credit_card| could be nullptr if we are adding a card. Else, it's a valid 35 // |credit_card| could be nullptr if we are adding a card. Else, it's a valid
35 // pointer to a card that needs to be updated, and which will outlive this 36 // pointer to a card that needs to be updated, and which will outlive this
36 // controller. 37 // controller.
37 CreditCardEditorViewController( 38 CreditCardEditorViewController(
38 PaymentRequestSpec* spec, 39 PaymentRequestSpec* spec,
39 PaymentRequestState* state, 40 PaymentRequestState* state,
40 PaymentRequestDialogView* dialog, 41 PaymentRequestDialogView* dialog,
42 BackNavigationType back_navigation,
43 int next_ui_tag,
41 base::OnceClosure on_edited, 44 base::OnceClosure on_edited,
42 base::OnceCallback<void(const autofill::CreditCard&)> on_added, 45 base::OnceCallback<void(const autofill::CreditCard&)> on_added,
43 autofill::CreditCard* credit_card); 46 autofill::CreditCard* credit_card);
44 ~CreditCardEditorViewController() override; 47 ~CreditCardEditorViewController() override;
45 48
46 // EditorViewController: 49 // EditorViewController:
47 std::unique_ptr<views::View> CreateHeaderView() override; 50 std::unique_ptr<views::View> CreateHeaderView() override;
51 std::unique_ptr<views::View> CreateCustomFieldsView() override;
48 std::vector<EditorField> GetFieldDefinitions() override; 52 std::vector<EditorField> GetFieldDefinitions() override;
49 base::string16 GetInitialValueForType( 53 base::string16 GetInitialValueForType(
50 autofill::ServerFieldType type) override; 54 autofill::ServerFieldType type) override;
51 bool ValidateModelAndSave() override; 55 bool ValidateModelAndSave() override;
52 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( 56 std::unique_ptr<ValidationDelegate> CreateValidationDelegate(
53 const EditorField& field) override; 57 const EditorField& field) override;
54 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( 58 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType(
55 const autofill::ServerFieldType& type) override; 59 const autofill::ServerFieldType& type) override;
56 60
57 protected: 61 protected:
58 // PaymentRequestSheetController: 62 // PaymentRequestSheetController:
59 base::string16 GetSheetTitle() override; 63 base::string16 GetSheetTitle() override;
64 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
60 65
61 private: 66 private:
62 class CreditCardValidationDelegate : public ValidationDelegate { 67 class CreditCardValidationDelegate : public ValidationDelegate {
63 public: 68 public:
64 // Used to validate |field| type. A reference to the |controller| should 69 // Used to validate |field| type. A reference to the |controller| should
65 // outlive this delegate, and a list of |supported_card_networks| can be 70 // outlive this delegate, and a list of |supported_card_networks| can be
66 // passed in to validate |field| (the data will be copied to the delegate). 71 // passed in to validate |field| (the data will be copied to the delegate).
67 CreditCardValidationDelegate( 72 CreditCardValidationDelegate(
68 const EditorField& field, 73 const EditorField& field,
69 EditorViewController* controller, 74 EditorViewController* controller,
(...skipping 11 matching lines...) Expand all
81 86
82 EditorField field_; 87 EditorField field_;
83 // Outlives this class. 88 // Outlives this class.
84 EditorViewController* controller_; 89 EditorViewController* controller_;
85 // The list of supported basic card networks. 90 // The list of supported basic card networks.
86 std::set<std::string> supported_card_networks_; 91 std::set<std::string> supported_card_networks_;
87 92
88 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate); 93 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate);
89 }; 94 };
90 95
96 // Called when a new address was created to be used as the billing address.
Mathieu 2017/05/04 20:29:19 mention the lifetime of |profile|?
MAD 2017/05/05 00:50:07 Why? It's a const ref that shouldn't be kept beyon
Mathieu 2017/05/05 13:51:33 I haven't double-checked but I think |profile| is
MAD 2017/05/05 18:32:34 Yes, the lifespan of the passed in profile is unkn
97 void AddAndSelectNewBillingAddress(const autofill::AutofillProfile& profile);
98
91 // Called when |credit_card_to_edit_| was successfully edited. 99 // Called when |credit_card_to_edit_| was successfully edited.
92 base::OnceClosure on_edited_; 100 base::OnceClosure on_edited_;
93 // Called when a new card was added. The const reference is short-lived, and 101 // Called when a new card was added. The const reference is short-lived, and
94 // the callee should make a copy. 102 // the callee should make a copy.
95 base::OnceCallback<void(const autofill::CreditCard&)> on_added_; 103 base::OnceCallback<void(const autofill::CreditCard&)> on_added_;
96 104
97 // If non-nullptr, a pointer to an object to be edited. Must outlive this 105 // If non-nullptr, a pointer to an object to be edited. Must outlive this
98 // controller. 106 // controller.
99 autofill::CreditCard* credit_card_to_edit_; 107 autofill::CreditCard* credit_card_to_edit_;
100 108
109 // The value to use for the add billing address button tag.
110 int add_billing_address_button_tag_;
111
101 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController); 112 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController);
102 }; 113 };
103 114
104 } // namespace payments 115 } // namespace payments
105 116
106 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H _ 117 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698