Chromium Code Reviews| Index: chrome/browser/ui/views/payments/contact_info_editor_view_controller.h |
| diff --git a/chrome/browser/ui/views/payments/contact_info_editor_view_controller.h b/chrome/browser/ui/views/payments/contact_info_editor_view_controller.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..af19265da4afb29605098b4b48f09bb87f6cd371 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/payments/contact_info_editor_view_controller.h |
| @@ -0,0 +1,74 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_CONTACT_INFO_EDITOR_VIEW_CONTROLLER_H_ |
| +#define CHROME_BROWSER_UI_VIEWS_PAYMENTS_CONTACT_INFO_EDITOR_VIEW_CONTROLLER_H_ |
| + |
| +#include <memory> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "base/strings/string16.h" |
| +#include "chrome/browser/ui/views/payments/editor_view_controller.h" |
| +#include "chrome/browser/ui/views/payments/validation_delegate.h" |
| +#include "ui/base/models/simple_combobox_model.h" |
|
Mathieu
2017/04/17 02:50:10
does it work without this line? normally editor_vi
tmartino
2017/04/18 19:39:17
We do need it in the .cc, but editor_view_controll
|
| + |
| +namespace autofill { |
| +class AutofillProfile; |
| +} |
|
Mathieu
2017/04/17 02:50:09
} // namespace autofill
tmartino
2017/04/18 19:39:17
Done
|
| + |
| +namespace payments { |
| + |
| +class ContactInfoEditorViewController : public EditorViewController { |
| + public: |
| + // Does not take ownership of the arguments, which should outlive this object. |
|
Mathieu
2017/04/17 02:50:09
Mention that |profile| can be nullptr but not the
tmartino
2017/04/18 19:39:17
Done
|
| + ContactInfoEditorViewController(PaymentRequestSpec* spec, |
| + PaymentRequestState* state, |
| + PaymentRequestDialogView* dialog, |
| + autofill::AutofillProfile* profile); |
| + ~ContactInfoEditorViewController() override; |
| + |
| + // EditorViewController: |
| + std::unique_ptr<views::View> CreateHeaderView() override; |
| + std::vector<EditorField> GetFieldDefinitions() override; |
| + base::string16 GetInitialValueForType( |
| + autofill::ServerFieldType type) override; |
| + bool ValidateModelAndSave() override; |
| + std::unique_ptr<ValidationDelegate> CreateValidationDelegate( |
| + const EditorField& field) override; |
| + std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( |
| + const autofill::ServerFieldType& type) override; |
| + |
| + protected: |
| + // PaymentRequestSheetController: |
| + base::string16 GetSheetTitle() override; |
| + |
| + private: |
| + bool ValidateModel(); |
| + void PopulateProfile(autofill::AutofillProfile* profile); |
|
Mathieu
2017/04/17 02:50:09
A comment would be good to explain populating what
tmartino
2017/04/18 19:39:17
Done
|
| + |
| + autofill::AutofillProfile* profile_to_edit_; |
| + |
| + class ContactInfoValidationDelegate : public ValidationDelegate { |
| + public: |
| + ContactInfoValidationDelegate(const EditorField& field, |
| + const std::string& locale, |
| + EditorViewController* controller); |
| + ~ContactInfoValidationDelegate() override; |
| + |
| + // ValidationDelegate: |
| + bool ValidateTextfield(views::Textfield* textfield) override; |
| + bool ValidateCombobox(views::Combobox* combobox) override; |
| + void ComboboxModelChanged(views::Combobox* combobox) override {} |
| + |
| + private: |
| + EditorField field_; |
| + EditorViewController* controller_; |
|
Mathieu
2017/04/17 02:50:09
outlives this class, never null, etc.
tmartino
2017/04/18 19:39:17
Done
|
| + std::string locale_; |
|
Mathieu
2017/04/17 02:50:10
can keep const std::string& to avoid the copy
tmartino
2017/04/18 19:39:17
Done
|
| + }; |
| +}; |
| + |
| +} // namespace payments |
| + |
| +#endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CONTACT_INFO_EDITOR_VIEW_CONTROLLER_H_ |