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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 std::unordered_map<ValidatingCombobox*, const EditorField>; | 87 std::unordered_map<ValidatingCombobox*, const EditorField>; |
88 using ErrorLabelMap = | 88 using ErrorLabelMap = |
89 std::map<const EditorField, views::Label*, EditorField::Compare>; | 89 std::map<const EditorField, views::Label*, EditorField::Compare>; |
90 | 90 |
91 // Does not take ownership of the arguments, which should outlive this object. | 91 // Does not take ownership of the arguments, which should outlive this object. |
92 EditorViewController(PaymentRequestSpec* spec, | 92 EditorViewController(PaymentRequestSpec* spec, |
93 PaymentRequestState* state, | 93 PaymentRequestState* state, |
94 PaymentRequestDialogView* dialog); | 94 PaymentRequestDialogView* dialog); |
95 ~EditorViewController() override; | 95 ~EditorViewController() override; |
96 | 96 |
97 // PaymentRequestSheetController: | |
98 std::unique_ptr<views::View> CreateView() override; | |
99 | |
100 // Will display |error_message| alongside the input field represented by | 97 // Will display |error_message| alongside the input field represented by |
101 // |field|. | 98 // |field|. |
102 void DisplayErrorMessageForField(const EditorField& field, | 99 void DisplayErrorMessageForField(const EditorField& field, |
103 const base::string16& error_message); | 100 const base::string16& error_message); |
104 | 101 |
105 const ComboboxMap& comboboxes() const { return comboboxes_; } | 102 const ComboboxMap& comboboxes() const { return comboboxes_; } |
106 const TextFieldsMap& text_fields() const { return text_fields_; } | 103 const TextFieldsMap& text_fields() const { return text_fields_; } |
107 | 104 |
108 protected: | 105 protected: |
109 virtual std::unique_ptr<views::View> CreateHeaderView() = 0; | 106 virtual std::unique_ptr<views::View> CreateHeaderView() = 0; |
110 // Returns the resource id of the view header title. | |
111 virtual int GetViewHeaderTitleId() const = 0; | |
112 // Returns the field definitions used to build the UI. | 107 // Returns the field definitions used to build the UI. |
113 virtual std::vector<EditorField> GetFieldDefinitions() = 0; | 108 virtual std::vector<EditorField> GetFieldDefinitions() = 0; |
114 // Validates the data entered and attempts to save; returns true on success. | 109 // Validates the data entered and attempts to save; returns true on success. |
115 virtual bool ValidateModelAndSave() = 0; | 110 virtual bool ValidateModelAndSave() = 0; |
116 // Creates a ValidationDelegate which knows how to validate for a given | 111 // Creates a ValidationDelegate which knows how to validate for a given |
117 // |field| definition. | 112 // |field| definition. |
118 virtual std::unique_ptr<ValidationDelegate> CreateValidationDelegate( | 113 virtual std::unique_ptr<ValidationDelegate> CreateValidationDelegate( |
119 const EditorField& field) = 0; | 114 const EditorField& field) = 0; |
120 virtual std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( | 115 virtual std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( |
121 const autofill::ServerFieldType& type) = 0; | 116 const autofill::ServerFieldType& type) = 0; |
122 | 117 |
123 // PaymentRequestSheetController; | 118 // PaymentRequestSheetController; |
124 std::unique_ptr<views::Button> CreatePrimaryButton() override; | 119 std::unique_ptr<views::Button> CreatePrimaryButton() override; |
| 120 void FillContentView(views::View* content_view) override; |
125 std::unique_ptr<views::View> CreateExtraFooterView() override; | 121 std::unique_ptr<views::View> CreateExtraFooterView() override; |
126 | 122 |
127 private: | 123 private: |
128 // PaymentRequestSheetController: | 124 // PaymentRequestSheetController: |
129 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 125 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
130 | 126 |
131 // views::TextfieldController: | 127 // views::TextfieldController: |
132 void ContentsChanged(views::Textfield* sender, | 128 void ContentsChanged(views::Textfield* sender, |
133 const base::string16& new_contents) override; | 129 const base::string16& new_contents) override; |
134 | 130 |
(...skipping 18 matching lines...) Expand all Loading... |
153 ComboboxMap comboboxes_; | 149 ComboboxMap comboboxes_; |
154 // Tracks the relationship between a field and its error label. | 150 // Tracks the relationship between a field and its error label. |
155 ErrorLabelMap error_labels_; | 151 ErrorLabelMap error_labels_; |
156 | 152 |
157 DISALLOW_COPY_AND_ASSIGN(EditorViewController); | 153 DISALLOW_COPY_AND_ASSIGN(EditorViewController); |
158 }; | 154 }; |
159 | 155 |
160 } // namespace payments | 156 } // namespace payments |
161 | 157 |
162 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ | 158 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ |
OLD | NEW |