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