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

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

Issue 2895473005: [Payments] Have expiration date be on the same line in CC editor (Closed)
Patch Set: Initial 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 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(std::move(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 {
61 bool operator()(const EditorField& lhs, const EditorField& rhs) const {
62 return std::tie(lhs.type, lhs.label) < std::tie(rhs.type, rhs.label);
63 }
64 };
65
66 // Data type in the field. 60 // Data type in the field.
67 autofill::ServerFieldType type; 61 autofill::ServerFieldType type;
68 // Label to be shown alongside the field. 62 // Label to be shown alongside the field.
69 base::string16 label; 63 base::string16 label;
70 // Hint about the length of this field's contents. 64 // Hint about the length of this field's contents.
71 LengthHint length_hint; 65 LengthHint length_hint;
72 // Whether the field is required. 66 // Whether the field is required.
73 bool required; 67 bool required;
74 // The control type. 68 // The control type.
75 ControlType control_type; 69 ControlType control_type;
76 }; 70 };
77 71
78 // The PaymentRequestSheetController subtype for the editor screens of the 72 // The PaymentRequestSheetController subtype for the editor screens of the
79 // Payment Request flow. 73 // Payment Request flow.
80 class EditorViewController : public PaymentRequestSheetController, 74 class EditorViewController : public PaymentRequestSheetController,
81 public views::TextfieldController, 75 public views::TextfieldController,
82 public views::ComboboxListener { 76 public views::ComboboxListener {
83 public: 77 public:
84 using TextFieldsMap = 78 using TextFieldsMap =
85 std::unordered_map<ValidatingTextfield*, const EditorField>; 79 std::unordered_map<ValidatingTextfield*, const EditorField>;
86 using ComboboxMap = 80 using ComboboxMap =
87 std::unordered_map<ValidatingCombobox*, const EditorField>; 81 std::unordered_map<ValidatingCombobox*, const EditorField>;
88 using ErrorLabelMap = 82 using ErrorLabelMap = std::map<autofill::ServerFieldType, views::View*>;
89 std::map<const EditorField, views::View*, EditorField::Compare>;
90 83
91 // Does not take ownership of the arguments, which should outlive this object. 84 // Does not take ownership of the arguments, which should outlive this object.
92 // |back_navigation_type| identifies what sort of back navigation should be 85 // |back_navigation_type| identifies what sort of back navigation should be
93 // done when editing is successful. This is independent of the back arrow 86 // done when editing is successful. This is independent of the back arrow
94 // which always goes back one step. 87 // which always goes back one step.
95 EditorViewController(PaymentRequestSpec* spec, 88 EditorViewController(PaymentRequestSpec* spec,
96 PaymentRequestState* state, 89 PaymentRequestState* state,
97 PaymentRequestDialogView* dialog, 90 PaymentRequestDialogView* dialog,
98 BackNavigationType back_navigation_type); 91 BackNavigationType back_navigation_type);
99 ~EditorViewController() override; 92 ~EditorViewController() override;
100 93
101 // Will display |error_message| alongside the input field represented by 94 // Will display |error_message| alongside the input field represented by
102 // |field|. 95 // field |type|.
103 void DisplayErrorMessageForField(const EditorField& field, 96 void DisplayErrorMessageForField(autofill::ServerFieldType type,
104 const base::string16& error_message); 97 const base::string16& error_message);
105 98
106 const ComboboxMap& comboboxes() const { return comboboxes_; } 99 const ComboboxMap& comboboxes() const { return comboboxes_; }
107 const TextFieldsMap& text_fields() const { return text_fields_; } 100 const TextFieldsMap& text_fields() const { return text_fields_; }
108 101
109 protected: 102 protected:
110 // Create a header view to be inserted before all fields. 103 // Create a header view to be inserted before all fields.
111 virtual std::unique_ptr<views::View> CreateHeaderView(); 104 virtual std::unique_ptr<views::View> CreateHeaderView();
112 // Create a custom view for the specified |type|. 105 // Create a custom view for the specified |type|.
113 virtual std::unique_ptr<views::View> CreateCustomFieldView( 106 virtual std::unique_ptr<views::View> CreateCustomFieldView(
(...skipping 26 matching lines...) Expand all
140 // Update the editor view by removing all it's child views and recreating 133 // Update the editor view by removing all it's child views and recreating
141 // the input fields returned by GetFieldDefinitions. Note that 134 // the input fields returned by GetFieldDefinitions. Note that
142 // CreateEditorView MUST have been called at least once before calling 135 // CreateEditorView MUST have been called at least once before calling
143 // UpdateEditorView. 136 // UpdateEditorView.
144 virtual void UpdateEditorView(); 137 virtual void UpdateEditorView();
145 138
146 // PaymentRequestSheetController: 139 // PaymentRequestSheetController:
147 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 140 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
148 views::View* GetFirstFocusedView() override; 141 views::View* GetFirstFocusedView() override;
149 142
143 // Will create a combobox according to the |field| definition. Will also keep
144 // track of this field to populate the edited model on save.
145 std::unique_ptr<ValidatingCombobox> CreateComboboxForField(
146 const EditorField& field);
147
150 private: 148 private:
151 // views::TextfieldController: 149 // views::TextfieldController:
152 void ContentsChanged(views::Textfield* sender, 150 void ContentsChanged(views::Textfield* sender,
153 const base::string16& new_contents) override; 151 const base::string16& new_contents) override;
154 152
155 // Creates the whole editor view to go within the editor dialog. It 153 // Creates the whole editor view to go within the editor dialog. It
156 // encompasses all the input fields created by CreateInputField(). 154 // encompasses all the input fields created by CreateInputField().
157 std::unique_ptr<views::View> CreateEditorView(); 155 std::unique_ptr<views::View> CreateEditorView();
158 156
159 // Adds some views to |layout|, to represent an input field and its labels. 157 // Adds some views to |layout|, to represent an input field and its labels.
(...skipping 20 matching lines...) Expand all
180 178
181 // Identifies where to go back when the editing completes successfully. 179 // Identifies where to go back when the editing completes successfully.
182 BackNavigationType back_navigation_type_; 180 BackNavigationType back_navigation_type_;
183 181
184 DISALLOW_COPY_AND_ASSIGN(EditorViewController); 182 DISALLOW_COPY_AND_ASSIGN(EditorViewController);
185 }; 183 };
186 184
187 } // namespace payments 185 } // namespace payments
188 186
189 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ 187 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698