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

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

Issue 2709093006: Adding new shipping address editor view to payment flow. (Closed)
Patch Set: Bot failure fix Created 3 years, 9 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
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/views/payments/editor_view_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 29 matching lines...) Expand all
40 class PaymentRequestDialogView; 40 class PaymentRequestDialogView;
41 class ValidatingCombobox; 41 class ValidatingCombobox;
42 class ValidatingTextfield; 42 class ValidatingTextfield;
43 43
44 // Field definition for an editor field, used to build the UI. 44 // Field definition for an editor field, used to build the UI.
45 struct EditorField { 45 struct EditorField {
46 enum class LengthHint : int { HINT_LONG, HINT_SHORT }; 46 enum class LengthHint : int { HINT_LONG, HINT_SHORT };
47 enum class ControlType : int { TEXTFIELD, COMBOBOX }; 47 enum class ControlType : int { TEXTFIELD, COMBOBOX };
48 48
49 EditorField(autofill::ServerFieldType type, 49 EditorField(autofill::ServerFieldType type,
50 const base::string16& label, 50 base::string16 label,
51 LengthHint length_hint, 51 LengthHint length_hint,
52 bool required, 52 bool required,
53 ControlType control_type = ControlType::TEXTFIELD) 53 ControlType control_type = ControlType::TEXTFIELD)
54 : type(type), 54 : type(type),
55 label(label), 55 label(std::move(label)),
56 length_hint(length_hint), 56 length_hint(length_hint),
57 required(required), 57 required(required),
58 control_type(control_type) {} 58 control_type(control_type) {}
59 59
60 struct Compare { 60 struct Compare {
61 bool operator()(const EditorField& lhs, const EditorField& rhs) const { 61 bool operator()(const EditorField& lhs, const EditorField& rhs) const {
62 return std::tie(lhs.type, lhs.label) < std::tie(rhs.type, rhs.label); 62 return std::tie(lhs.type, lhs.label) < std::tie(rhs.type, rhs.label);
63 } 63 }
64 }; 64 };
65 65
66 // Data type in the field. 66 // Data type in the field.
67 const autofill::ServerFieldType type; 67 autofill::ServerFieldType type;
68 // Label to be shown alongside the field. 68 // Label to be shown alongside the field.
69 const base::string16 label; 69 base::string16 label;
70 // Hint about the length of this field's contents. 70 // Hint about the length of this field's contents.
71 LengthHint length_hint; 71 LengthHint length_hint;
72 // Whether the field is required. 72 // Whether the field is required.
73 bool required; 73 bool required;
74 // The control type. 74 // The control type.
75 ControlType control_type; 75 ControlType control_type;
76 }; 76 };
77 77
78 // The PaymentRequestSheetController subtype for the editor screens of the 78 // The PaymentRequestSheetController subtype for the editor screens of the
79 // Payment Request flow. 79 // Payment Request flow.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // |field| definition. 117 // |field| definition.
118 virtual std::unique_ptr<ValidationDelegate> CreateValidationDelegate( 118 virtual std::unique_ptr<ValidationDelegate> CreateValidationDelegate(
119 const EditorField& field) = 0; 119 const EditorField& field) = 0;
120 virtual std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( 120 virtual std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType(
121 const autofill::ServerFieldType& type) = 0; 121 const autofill::ServerFieldType& type) = 0;
122 122
123 // PaymentRequestSheetController; 123 // PaymentRequestSheetController;
124 std::unique_ptr<views::Button> CreatePrimaryButton() override; 124 std::unique_ptr<views::Button> CreatePrimaryButton() override;
125 std::unique_ptr<views::View> CreateExtraFooterView() override; 125 std::unique_ptr<views::View> CreateExtraFooterView() override;
126 126
127 // views::ComboboxListener:
128 void OnPerformAction(views::Combobox* combobox) override;
129
130 // Update the editor view by removing all it's child views and recreating
131 // the input fields returned by GetFieldDefinitions. Note that
132 // CreateEditorView MUST have been called at least once before calling
133 // UpdateEditorView.
134 virtual void UpdateEditorView();
135
127 private: 136 private:
128 // PaymentRequestSheetController: 137 // PaymentRequestSheetController:
129 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 138 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
130 139
131 // views::TextfieldController: 140 // views::TextfieldController:
132 void ContentsChanged(views::Textfield* sender, 141 void ContentsChanged(views::Textfield* sender,
133 const base::string16& new_contents) override; 142 const base::string16& new_contents) override;
134 143
135 // views::ComboboxListener:
136 void OnPerformAction(views::Combobox* combobox) override;
137
138 // Creates the whole editor view to go within the editor dialog. It 144 // Creates the whole editor view to go within the editor dialog. It
139 // encompasses all the input fields created by CreateInputField(). 145 // encompasses all the input fields created by CreateInputField().
140 std::unique_ptr<views::View> CreateEditorView(); 146 void CreateEditorView();
141 147
142 // Adds some views to |layout|, to represent an input field and its labels. 148 // Adds some views to |layout|, to represent an input field and its labels.
143 // |field| is the field definition, which contains the label and the hint 149 // |field| is the field definition, which contains the label and the hint
144 // about the length of the input field. A placeholder error label is also 150 // about the length of the input field. A placeholder error label is also
145 // added (see implementation). 151 // added (see implementation).
146 void CreateInputField(views::GridLayout* layout, const EditorField& field); 152 void CreateInputField(views::GridLayout* layout, const EditorField& field);
147 153
154 // The implementation of UpdateEditorView which is also called from
155 // CreateEditorView.
156 void UpdateEditorViewImpl();
157
158 // The editor content view, owned by the client so the derived classes can
159 // refresh it when some user interactions cause layout changes by calling
160 // UpdateEditorView().
161 std::unique_ptr<views::View> editor_view_;
162
148 // Used to remember the association between the input field UI element and the 163 // Used to remember the association between the input field UI element and the
149 // original field definition. The ValidatingTextfield* and ValidatingCombobox* 164 // original field definition. The ValidatingTextfield* and ValidatingCombobox*
150 // are owned by their parent view, this only keeps a reference that is good as 165 // are owned by their parent view, this only keeps a reference that is good as
151 // long as the input field is visible. 166 // long as the input field is visible.
152 TextFieldsMap text_fields_; 167 TextFieldsMap text_fields_;
153 ComboboxMap comboboxes_; 168 ComboboxMap comboboxes_;
154 // Tracks the relationship between a field and its error label. 169 // Tracks the relationship between a field and its error label.
155 ErrorLabelMap error_labels_; 170 ErrorLabelMap error_labels_;
156 171
157 DISALLOW_COPY_AND_ASSIGN(EditorViewController); 172 DISALLOW_COPY_AND_ASSIGN(EditorViewController);
158 }; 173 };
159 174
160 } // namespace payments 175 } // namespace payments
161 176
162 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ 177 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/views/payments/editor_view_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698