Chromium Code Reviews| 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_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER _H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER _H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER _H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROLLER _H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "chrome/browser/ui/views/payments/editor_view_controller.h" | 13 #include "chrome/browser/ui/views/payments/editor_view_controller.h" |
| 14 #include "chrome/browser/ui/views/payments/validating_textfield.h" | 14 #include "chrome/browser/ui/views/payments/validating_textfield.h" |
| 15 | 15 |
| 16 namespace autofill { | 16 namespace autofill { |
| 17 class AutofillProfile; | 17 class AutofillProfile; |
| 18 } // namespace autofill | 18 } // namespace autofill |
| 19 | 19 |
| 20 namespace payments { | 20 namespace payments { |
| 21 | 21 |
| 22 class PaymentRequestSpec; | 22 class PaymentRequestSpec; |
| 23 class PaymentRequestState; | 23 class PaymentRequestState; |
| 24 class PaymentRequestDialogView; | 24 class PaymentRequestDialogView; |
| 25 | 25 |
| 26 // Shipping Address editor screen of the Payment Request flow. | 26 // Shipping Address editor screen of the Payment Request flow. |
| 27 class ShippingAddressEditorViewController : public EditorViewController { | 27 class ShippingAddressEditorViewController : public EditorViewController { |
| 28 public: | 28 public: |
| 29 // Does not take ownership of the arguments, which should outlive this object. | 29 // Does not take ownership of the arguments, which should outlive this object. |
|
Mathieu
2017/04/24 20:05:19
it does take ownership of the callbacks :)
MAD
2017/04/25 14:23:49
Done.
| |
| 30 ShippingAddressEditorViewController(PaymentRequestSpec* spec, | 30 ShippingAddressEditorViewController( |
| 31 PaymentRequestState* state, | 31 PaymentRequestSpec* spec, |
| 32 PaymentRequestDialogView* dialog, | 32 PaymentRequestState* state, |
| 33 autofill::AutofillProfile* profile); | 33 PaymentRequestDialogView* dialog, |
| 34 base::OnceClosure on_edited, | |
| 35 base::OnceCallback<void(const autofill::AutofillProfile&)> on_added, | |
| 36 autofill::AutofillProfile* profile); | |
| 34 ~ShippingAddressEditorViewController() override; | 37 ~ShippingAddressEditorViewController() override; |
| 35 | 38 |
| 36 // EditorViewController: | 39 // EditorViewController: |
| 37 std::unique_ptr<views::View> CreateHeaderView() override; | 40 std::unique_ptr<views::View> CreateHeaderView() override; |
| 38 std::vector<EditorField> GetFieldDefinitions() override; | 41 std::vector<EditorField> GetFieldDefinitions() override; |
| 39 base::string16 GetInitialValueForType( | 42 base::string16 GetInitialValueForType( |
| 40 autofill::ServerFieldType type) override; | 43 autofill::ServerFieldType type) override; |
| 41 bool ValidateModelAndSave() override; | 44 bool ValidateModelAndSave() override; |
| 42 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( | 45 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( |
| 43 const EditorField& field) override; | 46 const EditorField& field) override; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 67 | 70 |
| 68 EditorField field_; | 71 EditorField field_; |
| 69 | 72 |
| 70 // Raw pointer back to the owner of this class, therefore will not be null. | 73 // Raw pointer back to the owner of this class, therefore will not be null. |
| 71 ShippingAddressEditorViewController* controller_; | 74 ShippingAddressEditorViewController* controller_; |
| 72 | 75 |
| 73 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate); | 76 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate); |
| 74 }; | 77 }; |
| 75 friend class ShippingAddressValidationDelegate; | 78 friend class ShippingAddressValidationDelegate; |
| 76 | 79 |
| 80 // Called when |profile_to_edit_| was successfully edited. | |
| 81 base::OnceClosure on_edited_; | |
| 82 // Called when a new profile was added. The const reference is short-lived, | |
| 83 // and the callee should make a copy. | |
| 84 base::OnceCallback<void(const autofill::AutofillProfile&)> on_added_; | |
| 85 | |
| 77 // If non-nullptr, a point to an object to be edited, which should outlive | 86 // If non-nullptr, a point to an object to be edited, which should outlive |
| 78 // this controller. | 87 // this controller. |
| 79 autofill::AutofillProfile* profile_to_edit_; | 88 autofill::AutofillProfile* profile_to_edit_; |
| 80 | 89 |
| 81 // A temporary profile to keep unsaved data in between relayout (e.g., when | 90 // A temporary profile to keep unsaved data in between relayout (e.g., when |
| 82 // the country is changed and fields set may be different). | 91 // the country is changed and fields set may be different). |
| 83 std::unique_ptr<autofill::AutofillProfile> temporary_profile_; | 92 std::unique_ptr<autofill::AutofillProfile> temporary_profile_; |
| 84 | 93 |
| 85 // List of fields, reset everytime the current country changes. | 94 // List of fields, reset everytime the current country changes. |
| 86 std::vector<EditorField> editor_fields_; | 95 std::vector<EditorField> editor_fields_; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 111 // When a combobox model has changed, a view update might be needed, e.g., if | 120 // When a combobox model has changed, a view update might be needed, e.g., if |
| 112 // there is no data in the combobox and it must be converted to a text field. | 121 // there is no data in the combobox and it must be converted to a text field. |
| 113 void OnComboboxModelChanged(views::Combobox* combobox); | 122 void OnComboboxModelChanged(views::Combobox* combobox); |
| 114 | 123 |
| 115 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController); | 124 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController); |
| 116 }; | 125 }; |
| 117 | 126 |
| 118 } // namespace payments | 127 } // namespace payments |
| 119 | 128 |
| 120 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL LER_H_ | 129 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL LER_H_ |
| OLD | NEW |