OLD | NEW |
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_EDITOR_VIEW_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <tuple> | 10 #include <tuple> |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 // Will display |error_message| alongside the input field represented by | 101 // Will display |error_message| alongside the input field represented by |
102 // |field|. | 102 // |field|. |
103 void DisplayErrorMessageForField(const EditorField& field, | 103 void DisplayErrorMessageForField(const EditorField& field, |
104 const base::string16& error_message); | 104 const base::string16& error_message); |
105 | 105 |
106 const ComboboxMap& comboboxes() const { return comboboxes_; } | 106 const ComboboxMap& comboboxes() const { return comboboxes_; } |
107 const TextFieldsMap& text_fields() const { return text_fields_; } | 107 const TextFieldsMap& text_fields() const { return text_fields_; } |
108 | 108 |
109 protected: | 109 protected: |
110 // A very long label will wrap. Value picked so that left + right label | 110 // Create a header view to be inserted before all fields. |
111 // padding bring the label to half-way in the dialog (~225). | |
112 static constexpr int kMaximumLabelWidth = 192; | |
113 | |
114 virtual std::unique_ptr<views::View> CreateHeaderView(); | 111 virtual std::unique_ptr<views::View> CreateHeaderView(); |
| 112 // Create a custom view for the specified |type|. |
115 virtual std::unique_ptr<views::View> CreateCustomFieldView( | 113 virtual std::unique_ptr<views::View> CreateCustomFieldView( |
116 autofill::ServerFieldType type); | 114 autofill::ServerFieldType type); |
| 115 // Create an extra view to go to the right of the field with |type|, which |
| 116 // can either be a textfield, combobox, or custom view. |
| 117 virtual std::unique_ptr<views::View> CreateExtraViewForField( |
| 118 autofill::ServerFieldType type); |
| 119 |
117 // Returns the field definitions used to build the UI. | 120 // Returns the field definitions used to build the UI. |
118 virtual std::vector<EditorField> GetFieldDefinitions() = 0; | 121 virtual std::vector<EditorField> GetFieldDefinitions() = 0; |
119 virtual base::string16 GetInitialValueForType( | 122 virtual base::string16 GetInitialValueForType( |
120 autofill::ServerFieldType type) = 0; | 123 autofill::ServerFieldType type) = 0; |
121 // Validates the data entered and attempts to save; returns true on success. | 124 // Validates the data entered and attempts to save; returns true on success. |
122 virtual bool ValidateModelAndSave() = 0; | 125 virtual bool ValidateModelAndSave() = 0; |
123 // Creates a ValidationDelegate which knows how to validate for a given | 126 // Creates a ValidationDelegate which knows how to validate for a given |
124 // |field| definition. | 127 // |field| definition. |
125 virtual std::unique_ptr<ValidationDelegate> CreateValidationDelegate( | 128 virtual std::unique_ptr<ValidationDelegate> CreateValidationDelegate( |
126 const EditorField& field) = 0; | 129 const EditorField& field) = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
153 // Creates the whole editor view to go within the editor dialog. It | 156 // Creates the whole editor view to go within the editor dialog. It |
154 // encompasses all the input fields created by CreateInputField(). | 157 // encompasses all the input fields created by CreateInputField(). |
155 std::unique_ptr<views::View> CreateEditorView(); | 158 std::unique_ptr<views::View> CreateEditorView(); |
156 | 159 |
157 // Adds some views to |layout|, to represent an input field and its labels. | 160 // Adds some views to |layout|, to represent an input field and its labels. |
158 // |field| is the field definition, which contains the label and the hint | 161 // |field| is the field definition, which contains the label and the hint |
159 // about the length of the input field. A placeholder error label is also | 162 // about the length of the input field. A placeholder error label is also |
160 // added (see implementation). | 163 // added (see implementation). |
161 void CreateInputField(views::GridLayout* layout, const EditorField& field); | 164 void CreateInputField(views::GridLayout* layout, const EditorField& field); |
162 | 165 |
| 166 // Returns the widest column width of across all extra views of a certain |
| 167 // |size| type. |
| 168 int ComputeWidestExtraViewWidth(EditorField::LengthHint size); |
| 169 |
163 // Used to remember the association between the input field UI element and the | 170 // Used to remember the association between the input field UI element and the |
164 // original field definition. The ValidatingTextfield* and ValidatingCombobox* | 171 // original field definition. The ValidatingTextfield* and ValidatingCombobox* |
165 // are owned by their parent view, this only keeps a reference that is good as | 172 // are owned by their parent view, this only keeps a reference that is good as |
166 // long as the input field is visible. | 173 // long as the input field is visible. |
167 TextFieldsMap text_fields_; | 174 TextFieldsMap text_fields_; |
168 ComboboxMap comboboxes_; | 175 ComboboxMap comboboxes_; |
169 // Tracks the relationship between a field and its error label. | 176 // Tracks the relationship between a field and its error label. |
170 ErrorLabelMap error_labels_; | 177 ErrorLabelMap error_labels_; |
171 | 178 |
172 // The first label in the editor, used to set the initial focus. | 179 // The first label in the editor, used to set the initial focus. |
173 views::View* first_field_view_; | 180 views::View* first_field_view_; |
174 | 181 |
175 // Identifies where to go back when the editing completes successfully. | 182 // Identifies where to go back when the editing completes successfully. |
176 BackNavigationType back_navigation_type_; | 183 BackNavigationType back_navigation_type_; |
177 | 184 |
178 DISALLOW_COPY_AND_ASSIGN(EditorViewController); | 185 DISALLOW_COPY_AND_ASSIGN(EditorViewController); |
179 }; | 186 }; |
180 | 187 |
181 } // namespace payments | 188 } // namespace payments |
182 | 189 |
183 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ | 190 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ |
OLD | NEW |