| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // |field| definition. | 118 // |field| definition. |
| 119 virtual std::unique_ptr<ValidationDelegate> CreateValidationDelegate( | 119 virtual std::unique_ptr<ValidationDelegate> CreateValidationDelegate( |
| 120 const EditorField& field) = 0; | 120 const EditorField& field) = 0; |
| 121 virtual std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( | 121 virtual std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( |
| 122 const autofill::ServerFieldType& type) = 0; | 122 const autofill::ServerFieldType& type) = 0; |
| 123 | 123 |
| 124 // PaymentRequestSheetController; | 124 // PaymentRequestSheetController; |
| 125 std::unique_ptr<views::Button> CreatePrimaryButton() override; | 125 std::unique_ptr<views::Button> CreatePrimaryButton() override; |
| 126 std::unique_ptr<views::View> CreateExtraFooterView() override; | 126 std::unique_ptr<views::View> CreateExtraFooterView() override; |
| 127 | 127 |
| 128 protected: |
| 129 // The editor content view, owned by the client so the derived classes can |
| 130 // refresh it when some user interactions cause layout changes. |
| 131 std::unique_ptr<views::View> editor_view_; |
| 132 |
| 133 // Update the editor view by removing all it's child views and recreating |
| 134 // the input fields returned by GetFieldDefinitions. Note that |
| 135 // CreateEditorView MUST have been called at least once before calling |
| 136 // UpdateEditorView. |
| 137 virtual void UpdateEditorView(); |
| 138 |
| 139 // views::ComboboxListener: |
| 140 void OnPerformAction(views::Combobox* combobox) override; |
| 141 |
| 128 private: | 142 private: |
| 129 // PaymentRequestSheetController: | 143 // PaymentRequestSheetController: |
| 130 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 144 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 131 | 145 |
| 132 // views::TextfieldController: | 146 // views::TextfieldController: |
| 133 void ContentsChanged(views::Textfield* sender, | 147 void ContentsChanged(views::Textfield* sender, |
| 134 const base::string16& new_contents) override; | 148 const base::string16& new_contents) override; |
| 135 | 149 |
| 136 // views::ComboboxListener: | |
| 137 void OnPerformAction(views::Combobox* combobox) override; | |
| 138 | |
| 139 // Creates the whole editor view to go within the editor dialog. It | 150 // Creates the whole editor view to go within the editor dialog. It |
| 140 // encompasses all the input fields created by CreateInputField(). | 151 // encompasses all the input fields created by CreateInputField(). |
| 141 std::unique_ptr<views::View> CreateEditorView(); | 152 void CreateEditorView(); |
| 142 | 153 |
| 143 // Adds some views to |layout|, to represent an input field and its labels. | 154 // Adds some views to |layout|, to represent an input field and its labels. |
| 144 // |field| is the field definition, which contains the label and the hint | 155 // |field| is the field definition, which contains the label and the hint |
| 145 // about the length of the input field. A placeholder error label is also | 156 // about the length of the input field. A placeholder error label is also |
| 146 // added (see implementation). | 157 // added (see implementation). |
| 147 void CreateInputField(views::GridLayout* layout, const EditorField& field); | 158 void CreateInputField(views::GridLayout* layout, const EditorField& field); |
| 148 | 159 |
| 149 // Used to remember the association between the input field UI element and the | 160 // Used to remember the association between the input field UI element and the |
| 150 // original field definition. The ValidatingTextfield* and ValidatingCombobox* | 161 // original field definition. The ValidatingTextfield* and ValidatingCombobox* |
| 151 // are owned by their parent view, this only keeps a reference that is good as | 162 // are owned by their parent view, this only keeps a reference that is good as |
| 152 // long as the input field is visible. | 163 // long as the input field is visible. |
| 153 TextFieldsMap text_fields_; | 164 TextFieldsMap text_fields_; |
| 154 ComboboxMap comboboxes_; | 165 ComboboxMap comboboxes_; |
| 155 // Tracks the relationship between a field and its error label. | 166 // Tracks the relationship between a field and its error label. |
| 156 ErrorLabelMap error_labels_; | 167 ErrorLabelMap error_labels_; |
| 157 | 168 |
| 158 DISALLOW_COPY_AND_ASSIGN(EditorViewController); | 169 DISALLOW_COPY_AND_ASSIGN(EditorViewController); |
| 159 }; | 170 }; |
| 160 | 171 |
| 161 } // namespace payments | 172 } // namespace payments |
| 162 | 173 |
| 163 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ | 174 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_EDITOR_VIEW_CONTROLLER_H_ |
| OLD | NEW |