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 | |
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(); | 110 virtual std::unique_ptr<views::View> CreateHeaderView(); |
115 virtual std::unique_ptr<views::View> CreateCustomFieldView( | 111 virtual std::unique_ptr<views::View> CreateCustomFieldView( |
116 autofill::ServerFieldType type); | 112 autofill::ServerFieldType type); |
113 virtual std::unique_ptr<views::View> CreateExtraViewForField( | |
anthonyvd
2017/05/11 00:32:14
nit: add comment
Mathieu
2017/05/11 01:16:24
Done.
| |
114 autofill::ServerFieldType type); | |
115 | |
117 // Returns the field definitions used to build the UI. | 116 // Returns the field definitions used to build the UI. |
118 virtual std::vector<EditorField> GetFieldDefinitions() = 0; | 117 virtual std::vector<EditorField> GetFieldDefinitions() = 0; |
119 virtual base::string16 GetInitialValueForType( | 118 virtual base::string16 GetInitialValueForType( |
120 autofill::ServerFieldType type) = 0; | 119 autofill::ServerFieldType type) = 0; |
121 // Validates the data entered and attempts to save; returns true on success. | 120 // Validates the data entered and attempts to save; returns true on success. |
122 virtual bool ValidateModelAndSave() = 0; | 121 virtual bool ValidateModelAndSave() = 0; |
123 // Creates a ValidationDelegate which knows how to validate for a given | 122 // Creates a ValidationDelegate which knows how to validate for a given |
124 // |field| definition. | 123 // |field| definition. |
125 virtual std::unique_ptr<ValidationDelegate> CreateValidationDelegate( | 124 virtual std::unique_ptr<ValidationDelegate> CreateValidationDelegate( |
126 const EditorField& field) = 0; | 125 const EditorField& field) = 0; |
(...skipping 26 matching lines...) Expand all Loading... | |
153 // Creates the whole editor view to go within the editor dialog. It | 152 // Creates the whole editor view to go within the editor dialog. It |
154 // encompasses all the input fields created by CreateInputField(). | 153 // encompasses all the input fields created by CreateInputField(). |
155 std::unique_ptr<views::View> CreateEditorView(); | 154 std::unique_ptr<views::View> CreateEditorView(); |
156 | 155 |
157 // Adds some views to |layout|, to represent an input field and its labels. | 156 // 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 | 157 // |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 | 158 // about the length of the input field. A placeholder error label is also |
160 // added (see implementation). | 159 // added (see implementation). |
161 void CreateInputField(views::GridLayout* layout, const EditorField& field); | 160 void CreateInputField(views::GridLayout* layout, const EditorField& field); |
162 | 161 |
162 // Returns the widest column width of across all extra views of a certain | |
163 // |size| type. | |
164 int ComputeWidestExtraViewWidth(EditorField::LengthHint size); | |
165 | |
163 // Used to remember the association between the input field UI element and the | 166 // Used to remember the association between the input field UI element and the |
164 // original field definition. The ValidatingTextfield* and ValidatingCombobox* | 167 // original field definition. The ValidatingTextfield* and ValidatingCombobox* |
165 // are owned by their parent view, this only keeps a reference that is good as | 168 // are owned by their parent view, this only keeps a reference that is good as |
166 // long as the input field is visible. | 169 // long as the input field is visible. |
167 TextFieldsMap text_fields_; | 170 TextFieldsMap text_fields_; |
168 ComboboxMap comboboxes_; | 171 ComboboxMap comboboxes_; |
169 // Tracks the relationship between a field and its error label. | 172 // Tracks the relationship between a field and its error label. |
170 ErrorLabelMap error_labels_; | 173 ErrorLabelMap error_labels_; |
171 | 174 |
172 // The first label in the editor, used to set the initial focus. | 175 // The first label in the editor, used to set the initial focus. |
173 views::View* first_field_view_; | 176 views::View* first_field_view_; |
174 | 177 |
175 // Identifies where to go back when the editing completes successfully. | 178 // Identifies where to go back when the editing completes successfully. |
176 BackNavigationType back_navigation_type_; | 179 BackNavigationType back_navigation_type_; |
177 | 180 |
178 DISALLOW_COPY_AND_ASSIGN(EditorViewController); | 181 DISALLOW_COPY_AND_ASSIGN(EditorViewController); |
179 }; | 182 }; |
180 | 183 |
181 } // namespace payments | 184 } // namespace payments |
182 | 185 |
183 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ | 186 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ |
OLD | NEW |