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

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

Issue 2896263002: [Payments] Changes to validation in the Credit Card editor (Closed)
Patch Set: rebase 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>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 autofill::ServerFieldType type) override; 56 autofill::ServerFieldType type) override;
57 std::vector<EditorField> GetFieldDefinitions() override; 57 std::vector<EditorField> GetFieldDefinitions() override;
58 base::string16 GetInitialValueForType( 58 base::string16 GetInitialValueForType(
59 autofill::ServerFieldType type) override; 59 autofill::ServerFieldType type) override;
60 bool ValidateModelAndSave() override; 60 bool ValidateModelAndSave() override;
61 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( 61 std::unique_ptr<ValidationDelegate> CreateValidationDelegate(
62 const EditorField& field) override; 62 const EditorField& field) override;
63 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( 63 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType(
64 const autofill::ServerFieldType& type) override; 64 const autofill::ServerFieldType& type) override;
65 65
66 // Selects the icon in the UI corresponding to |basic_card_network| with
67 // higher opacity. If empty string, selects none of them (all full opacity).
68 void SelectBasicCardNetworkIcon(const std::string& basic_card_network);
69
66 protected: 70 protected:
67 // PaymentRequestSheetController: 71 // PaymentRequestSheetController:
68 void FillContentView(views::View* content_view) override; 72 void FillContentView(views::View* content_view) override;
69 base::string16 GetSheetTitle() override; 73 base::string16 GetSheetTitle() override;
70 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 74 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
71 75
72 private: 76 private:
73 class CreditCardValidationDelegate : public ValidationDelegate { 77 class CreditCardValidationDelegate : public ValidationDelegate {
74 public: 78 public:
75 // Used to validate |field| type. A reference to the |controller| should 79 // Used to validate |field| type. A reference to the |controller| should
76 // outlive this delegate, and a list of |supported_card_networks| can be 80 // outlive this delegate, and a list of |supported_card_networks| can be
77 // passed in to validate |field| (the data will be copied to the delegate). 81 // passed in to validate |field| (the data will be copied to the delegate).
78 CreditCardValidationDelegate( 82 CreditCardValidationDelegate(
79 const EditorField& field, 83 const EditorField& field,
80 EditorViewController* controller, 84 CreditCardEditorViewController* controller,
81 const std::vector<std::string>& supported_card_networks); 85 const std::vector<std::string>& supported_card_networks);
82 ~CreditCardValidationDelegate() override; 86 ~CreditCardValidationDelegate() override;
83 87
84 // ValidationDelegate: 88 // ValidationDelegate:
85 bool IsValidTextfield(views::Textfield* textfield) override; 89 bool IsValidTextfield(views::Textfield* textfield) override;
86 bool IsValidCombobox(views::Combobox* combobox) override; 90 bool IsValidCombobox(views::Combobox* combobox) override;
87 bool TextfieldValueChanged(views::Textfield* textfield) override; 91 bool TextfieldValueChanged(views::Textfield* textfield,
92 bool was_blurred) override;
88 bool ComboboxValueChanged(views::Combobox* combobox) override; 93 bool ComboboxValueChanged(views::Combobox* combobox) override;
89 void ComboboxModelChanged(views::Combobox* combobox) override {} 94 void ComboboxModelChanged(views::Combobox* combobox) override {}
90 95
91 private: 96 private:
92 // Validates a specific |value|/|combobox|. 97 // Validates a specific |value|/|combobox|.
93 bool ValidateValue(const base::string16& value, 98 bool ValidateValue(const base::string16& value,
94 base::string16* error_message); 99 base::string16* error_message);
95 bool ValidateCombobox(views::Combobox* combobox, 100 bool ValidateCombobox(views::Combobox* combobox,
96 base::string16* error_message); 101 base::string16* error_message);
97 102
98 EditorField field_; 103 EditorField field_;
99 // Outlives this class. 104 // Outlives this class.
100 EditorViewController* controller_; 105 CreditCardEditorViewController* controller_;
101 // The list of supported basic card networks. 106 // The list of supported basic card networks.
102 std::set<std::string> supported_card_networks_; 107 std::set<std::string> supported_card_networks_;
103 108
104 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate); 109 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate);
105 }; 110 };
106 111
107 bool GetSheetId(DialogViewID* sheet_id) override; 112 bool GetSheetId(DialogViewID* sheet_id) override;
108 113
109 // Called when a new address was created to be used as the billing address. 114 // Called when a new address was created to be used as the billing address.
110 // The lifespan of |profile| beyond this call is undefined but it's OK, it's 115 // The lifespan of |profile| beyond this call is undefined but it's OK, it's
111 // simply propagated to the address combobox model. 116 // simply propagated to the address combobox model.
112 void AddAndSelectNewBillingAddress(const autofill::AutofillProfile& profile); 117 void AddAndSelectNewBillingAddress(const autofill::AutofillProfile& profile);
113 118
114 // Called when |credit_card_to_edit_| was successfully edited. 119 // Called when |credit_card_to_edit_| was successfully edited.
115 base::OnceClosure on_edited_; 120 base::OnceClosure on_edited_;
116 // Called when a new card was added. The const reference is short-lived, and 121 // Called when a new card was added. The const reference is short-lived, and
117 // the callee should make a copy. 122 // the callee should make a copy.
118 base::OnceCallback<void(const autofill::CreditCard&)> on_added_; 123 base::OnceCallback<void(const autofill::CreditCard&)> on_added_;
119 124
120 // If non-nullptr, a pointer to an object to be edited. Must outlive this 125 // If non-nullptr, a pointer to an object to be edited. Must outlive this
121 // controller. 126 // controller.
122 autofill::CreditCard* credit_card_to_edit_; 127 autofill::CreditCard* credit_card_to_edit_;
123 128
129 // Keeps track of the card icons currently visible, keyed by basic card
130 // network.
131 std::map<std::string, views::View*> card_icons_;
132
124 // The value to use for the add billing address button tag. 133 // The value to use for the add billing address button tag.
125 int add_billing_address_button_tag_; 134 int add_billing_address_button_tag_;
126 135
127 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController); 136 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController);
128 }; 137 };
129 138
130 } // namespace payments 139 } // namespace payments
131 140
132 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H _ 141 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698