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

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

Issue 2881643002: Focus first invalid field of payment request editor (Closed)
Patch Set: Fixed a case typo 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_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
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 within 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 27 matching lines...) Expand all
152 void ContentsChanged(views::Textfield* sender, 154 void ContentsChanged(views::Textfield* sender,
153 const base::string16& new_contents) override; 155 const base::string16& new_contents) override;
154 156
155 // Creates the whole editor view to go within the editor dialog. It 157 // Creates the whole editor view to go within the editor dialog. It
156 // encompasses all the input fields created by CreateInputField(). 158 // encompasses all the input fields created by CreateInputField().
157 std::unique_ptr<views::View> CreateEditorView(); 159 std::unique_ptr<views::View> CreateEditorView();
158 160
159 // Adds some views to |layout|, to represent an input field and its labels. 161 // Adds some views to |layout|, to represent an input field and its labels.
160 // |field| is the field definition, which contains the label and the hint 162 // |field| is the field definition, which contains the label and the hint
161 // about the length of the input field. A placeholder error label is also 163 // about the length of the input field. A placeholder error label is also
162 // added (see implementation). 164 // added (see implementation). Returns the input view for this field that
163 void CreateInputField(views::GridLayout* layout, const EditorField& field); 165 // could be focused if the caller identifies it as the first one, and there
166 // are no field identified as invalid once all the fields are created.
anthonyvd 2017/05/18 18:12:25 nit: field -> fields
MAD 2017/05/18 20:31:19 Done.
167 views::View* CreateInputField(views::GridLayout* layout,
168 const EditorField& field);
164 169
165 // Returns the widest column width of across all extra views of a certain 170 // Returns the widest column width of across all extra views of a certain
166 // |size| type. 171 // |size| type.
167 int ComputeWidestExtraViewWidth(EditorField::LengthHint size); 172 int ComputeWidestExtraViewWidth(EditorField::LengthHint size);
168 173
169 // Used to remember the association between the input field UI element and the 174 // Used to remember the association between the input field UI element and the
170 // original field definition. The ValidatingTextfield* and ValidatingCombobox* 175 // original field definition. The ValidatingTextfield* and ValidatingCombobox*
171 // are owned by their parent view, this only keeps a reference that is good as 176 // are owned by their parent view, this only keeps a reference that is good as
172 // long as the input field is visible. 177 // long as the input field is visible.
173 TextFieldsMap text_fields_; 178 TextFieldsMap text_fields_;
174 ComboboxMap comboboxes_; 179 ComboboxMap comboboxes_;
175 // Tracks the relationship between a field and its error label. 180 // Tracks the relationship between a field and its error label.
176 ErrorLabelMap error_labels_; 181 ErrorLabelMap error_labels_;
177 182
178 // The first label in the editor, used to set the initial focus. 183 // The input field view in the editor used to set the initial focus.
179 views::View* first_field_view_; 184 views::View* initial_focus_field_view_;
180 185
181 // Identifies where to go back when the editing completes successfully. 186 // Identifies where to go back when the editing completes successfully.
182 BackNavigationType back_navigation_type_; 187 BackNavigationType back_navigation_type_;
183 188
184 DISALLOW_COPY_AND_ASSIGN(EditorViewController); 189 DISALLOW_COPY_AND_ASSIGN(EditorViewController);
185 }; 190 };
186 191
187 } // namespace payments 192 } // namespace payments
188 193
189 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ 194 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698