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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // Create a header view to be inserted before all fields. | 110 // Create a header view to be inserted before all fields. |
111 virtual std::unique_ptr<views::View> CreateHeaderView(); | 111 virtual std::unique_ptr<views::View> CreateHeaderView(); |
112 // Create a custom view for the specified |type|. | 112 // |focusable_field| is to be set with a pointer to the view that should get |
113 // default focus without the custom view. | |
113 virtual std::unique_ptr<views::View> CreateCustomFieldView( | 114 virtual std::unique_ptr<views::View> CreateCustomFieldView( |
114 autofill::ServerFieldType type); | 115 autofill::ServerFieldType type, |
116 views::View** focusable_field); | |
115 // Create an extra view to go to the right of the field with |type|, which | 117 // 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. | 118 // can either be a textfield, combobox, or custom view. |
117 virtual std::unique_ptr<views::View> CreateExtraViewForField( | 119 virtual std::unique_ptr<views::View> CreateExtraViewForField( |
118 autofill::ServerFieldType type); | 120 autofill::ServerFieldType type); |
119 | 121 |
120 // Returns the field definitions used to build the UI. | 122 // Returns the field definitions used to build the UI. |
121 virtual std::vector<EditorField> GetFieldDefinitions() = 0; | 123 virtual std::vector<EditorField> GetFieldDefinitions() = 0; |
122 virtual base::string16 GetInitialValueForType( | 124 virtual base::string16 GetInitialValueForType( |
123 autofill::ServerFieldType type) = 0; | 125 autofill::ServerFieldType type) = 0; |
124 // Validates the data entered and attempts to save; returns true on success. | 126 // Validates the data entered and attempts to save; returns true on success. |
(...skipping 28 matching lines...) Expand all Loading... | |
153 void ContentsChanged(views::Textfield* sender, | 155 void ContentsChanged(views::Textfield* sender, |
154 const base::string16& new_contents) override; | 156 const base::string16& new_contents) override; |
155 | 157 |
156 // Creates the whole editor view to go within the editor dialog. It | 158 // Creates the whole editor view to go within the editor dialog. It |
157 // encompasses all the input fields created by CreateInputField(). | 159 // encompasses all the input fields created by CreateInputField(). |
158 std::unique_ptr<views::View> CreateEditorView(); | 160 std::unique_ptr<views::View> CreateEditorView(); |
159 | 161 |
160 // Adds some views to |layout|, to represent an input field and its labels. | 162 // Adds some views to |layout|, to represent an input field and its labels. |
161 // |field| is the field definition, which contains the label and the hint | 163 // |field| is the field definition, which contains the label and the hint |
162 // about the length of the input field. A placeholder error label is also | 164 // about the length of the input field. A placeholder error label is also |
163 // added (see implementation). | 165 // added (see implementation). Returns a pointer to a view filled with a valid |
164 void CreateInputField(views::GridLayout* layout, const EditorField& field); | 166 // field value that could receive the initial focus if not invalid value is |
anthonyvd
2017/05/12 14:19:44
I'm not sure what this means? Does it return any v
MAD
2017/05/18 16:01:45
Rephrased. Better?
anthonyvd
2017/05/18 18:12:24
Yep, thanks!
| |
167 // found. | |
168 views::View* CreateInputField(views::GridLayout* layout, | |
169 const EditorField& field); | |
165 | 170 |
166 // Returns the widest column width of across all extra views of a certain | 171 // Returns the widest column width of across all extra views of a certain |
167 // |size| type. | 172 // |size| type. |
168 int ComputeWidestExtraViewWidth(EditorField::LengthHint size); | 173 int ComputeWidestExtraViewWidth(EditorField::LengthHint size); |
169 | 174 |
170 // Used to remember the association between the input field UI element and the | 175 // Used to remember the association between the input field UI element and the |
171 // original field definition. The ValidatingTextfield* and ValidatingCombobox* | 176 // original field definition. The ValidatingTextfield* and ValidatingCombobox* |
172 // are owned by their parent view, this only keeps a reference that is good as | 177 // are owned by their parent view, this only keeps a reference that is good as |
173 // long as the input field is visible. | 178 // long as the input field is visible. |
174 TextFieldsMap text_fields_; | 179 TextFieldsMap text_fields_; |
175 ComboboxMap comboboxes_; | 180 ComboboxMap comboboxes_; |
176 // Tracks the relationship between a field and its error label. | 181 // Tracks the relationship between a field and its error label. |
177 ErrorLabelMap error_labels_; | 182 ErrorLabelMap error_labels_; |
178 | 183 |
179 // The first label in the editor, used to set the initial focus. | 184 // The first, potentially invalid, field in the editor, used to set the focus. |
180 views::View* first_field_view_; | 185 views::View* first_field_view_; |
181 | 186 |
182 // Identifies where to go back when the editing completes successfully. | 187 // Identifies where to go back when the editing completes successfully. |
183 BackNavigationType back_navigation_type_; | 188 BackNavigationType back_navigation_type_; |
184 | 189 |
185 DISALLOW_COPY_AND_ASSIGN(EditorViewController); | 190 DISALLOW_COPY_AND_ASSIGN(EditorViewController); |
186 }; | 191 }; |
187 | 192 |
188 } // namespace payments | 193 } // namespace payments |
189 | 194 |
190 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ | 195 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ |
OLD | NEW |