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

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

Issue 2905733002: [WebPayments] Disabling done button when form invalid (Closed)
Patch Set: mathp feedback Created 3 years, 6 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 const TextFieldsMap& text_fields() const { return text_fields_; } 106 const TextFieldsMap& text_fields() const { return text_fields_; }
107 107
108 // Returns the View ID that can be used to lookup the input field for |type|. 108 // Returns the View ID that can be used to lookup the input field for |type|.
109 static int GetInputFieldViewId(autofill::ServerFieldType type); 109 static int GetInputFieldViewId(autofill::ServerFieldType type);
110 110
111 protected: 111 protected:
112 // Create a header view to be inserted before all fields. 112 // Create a header view to be inserted before all fields.
113 virtual std::unique_ptr<views::View> CreateHeaderView(); 113 virtual std::unique_ptr<views::View> CreateHeaderView();
114 // |focusable_field| is to be set with a pointer to the view that should get 114 // |focusable_field| is to be set with a pointer to the view that should get
115 // default focus within the custom view. |valid| should be set to the initial 115 // default focus within the custom view. |valid| should be set to the initial
116 // validity state of the custom view. 116 // validity state of the custom view. If a custom view requires model
117 // validation, it should be tracked in |text_fields_| or |comboboxes_| (e.g.,
118 // by using CreateComboboxForField).
117 virtual std::unique_ptr<views::View> CreateCustomFieldView( 119 virtual std::unique_ptr<views::View> CreateCustomFieldView(
118 autofill::ServerFieldType type, 120 autofill::ServerFieldType type,
119 views::View** focusable_field, 121 views::View** focusable_field,
120 bool* valid); 122 bool* valid);
121 // Create an extra view to go to the right of the field with |type|, which 123 // Create an extra view to go to the right of the field with |type|, which
122 // can either be a textfield, combobox, or custom view. 124 // can either be a textfield, combobox, or custom view.
123 virtual std::unique_ptr<views::View> CreateExtraViewForField( 125 virtual std::unique_ptr<views::View> CreateExtraViewForField(
124 autofill::ServerFieldType type); 126 autofill::ServerFieldType type);
125 127
126 // Returns the field definitions used to build the UI. 128 // Returns the field definitions used to build the UI.
127 virtual std::vector<EditorField> GetFieldDefinitions() = 0; 129 virtual std::vector<EditorField> GetFieldDefinitions() = 0;
128 virtual base::string16 GetInitialValueForType( 130 virtual base::string16 GetInitialValueForType(
129 autofill::ServerFieldType type) = 0; 131 autofill::ServerFieldType type) = 0;
130 // Validates the data entered and attempts to save; returns true on success. 132 // Validates the data entered and attempts to save; returns true on success.
131 virtual bool ValidateModelAndSave() = 0; 133 virtual bool ValidateModelAndSave() = 0;
134
132 // Creates a ValidationDelegate which knows how to validate for a given 135 // Creates a ValidationDelegate which knows how to validate for a given
133 // |field| definition. 136 // |field| definition.
134 virtual std::unique_ptr<ValidationDelegate> CreateValidationDelegate( 137 virtual std::unique_ptr<ValidationDelegate> CreateValidationDelegate(
135 const EditorField& field) = 0; 138 const EditorField& field) = 0;
136 virtual std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( 139 virtual std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType(
137 const autofill::ServerFieldType& type) = 0; 140 const autofill::ServerFieldType& type) = 0;
138 141
142 // Returns true if all fields are valid.
143 bool ValidateModel();
Mathieu 2017/05/31 17:50:17 I would consider naming this ValidateInputFields,
144
139 // PaymentRequestSheetController; 145 // PaymentRequestSheetController;
140 std::unique_ptr<views::Button> CreatePrimaryButton() override; 146 std::unique_ptr<views::Button> CreatePrimaryButton() override;
141 void FillContentView(views::View* content_view) override; 147 void FillContentView(views::View* content_view) override;
142 148
143 // views::ComboboxListener: 149 // views::ComboboxListener:
144 void OnPerformAction(views::Combobox* combobox) override; 150 void OnPerformAction(views::Combobox* combobox) override;
145 151
146 // Update the editor view by removing all it's child views and recreating 152 // Update the editor view by removing all it's child views and recreating
147 // the input fields returned by GetFieldDefinitions. Note that 153 // the input fields returned by GetFieldDefinitions. Note that
148 // CreateEditorView MUST have been called at least once before calling 154 // CreateEditorView MUST have been called at least once before calling
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 201
196 // Identifies where to go back when the editing completes successfully. 202 // Identifies where to go back when the editing completes successfully.
197 BackNavigationType back_navigation_type_; 203 BackNavigationType back_navigation_type_;
198 204
199 DISALLOW_COPY_AND_ASSIGN(EditorViewController); 205 DISALLOW_COPY_AND_ASSIGN(EditorViewController);
200 }; 206 };
201 207
202 } // namespace payments 208 } // namespace payments
203 209
204 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ 210 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698