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

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: 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 #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> CreateCustomFieldView(
52 autofill::ServerFieldType type) override;
48 std::vector<EditorField> GetFieldDefinitions() override; 53 std::vector<EditorField> GetFieldDefinitions() override;
49 base::string16 GetInitialValueForType( 54 base::string16 GetInitialValueForType(
50 autofill::ServerFieldType type) override; 55 autofill::ServerFieldType type) override;
51 bool ValidateModelAndSave() override; 56 bool ValidateModelAndSave() override;
52 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( 57 std::unique_ptr<ValidationDelegate> CreateValidationDelegate(
53 const EditorField& field) override; 58 const EditorField& field) override;
54 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( 59 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType(
55 const autofill::ServerFieldType& type) override; 60 const autofill::ServerFieldType& type) override;
56 61
57 protected: 62 protected:
58 // PaymentRequestSheetController: 63 // PaymentRequestSheetController:
59 base::string16 GetSheetTitle() override; 64 base::string16 GetSheetTitle() override;
65 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
60 66
61 private: 67 private:
62 class CreditCardValidationDelegate : public ValidationDelegate { 68 class CreditCardValidationDelegate : public ValidationDelegate {
63 public: 69 public:
64 // Used to validate |field| type. A reference to the |controller| should 70 // Used to validate |field| type. A reference to the |controller| should
65 // outlive this delegate, and a list of |supported_card_networks| can be 71 // 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). 72 // passed in to validate |field| (the data will be copied to the delegate).
67 CreditCardValidationDelegate( 73 CreditCardValidationDelegate(
68 const EditorField& field, 74 const EditorField& field,
69 EditorViewController* controller, 75 EditorViewController* controller,
(...skipping 13 matching lines...) Expand all
83 // Outlives this class. 89 // Outlives this class.
84 EditorViewController* controller_; 90 EditorViewController* controller_;
85 // The list of supported basic card networks. 91 // The list of supported basic card networks.
86 std::set<std::string> supported_card_networks_; 92 std::set<std::string> supported_card_networks_;
87 93
88 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate); 94 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate);
89 }; 95 };
90 96
91 bool GetSheetId(DialogViewID* sheet_id) override; 97 bool GetSheetId(DialogViewID* sheet_id) override;
92 98
99 // Called when a new address was created to be used as the billing address.
100 // The lifespan of |profile| beyond this call is undefined but it's OK, it's
101 // simply propagated to the address combobox model.
102 void AddAndSelectNewBillingAddress(const autofill::AutofillProfile& profile);
103
93 // Called when |credit_card_to_edit_| was successfully edited. 104 // Called when |credit_card_to_edit_| was successfully edited.
94 base::OnceClosure on_edited_; 105 base::OnceClosure on_edited_;
95 // Called when a new card was added. The const reference is short-lived, and 106 // Called when a new card was added. The const reference is short-lived, and
96 // the callee should make a copy. 107 // the callee should make a copy.
97 base::OnceCallback<void(const autofill::CreditCard&)> on_added_; 108 base::OnceCallback<void(const autofill::CreditCard&)> on_added_;
98 109
99 // If non-nullptr, a pointer to an object to be edited. Must outlive this 110 // If non-nullptr, a pointer to an object to be edited. Must outlive this
100 // controller. 111 // controller.
101 autofill::CreditCard* credit_card_to_edit_; 112 autofill::CreditCard* credit_card_to_edit_;
102 113
114 // The value to use for the add billing address button tag.
115 int add_billing_address_button_tag_;
116
103 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController); 117 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController);
104 }; 118 };
105 119
106 } // namespace payments 120 } // namespace payments
107 121
108 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H _ 122 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698