| 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 "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "chrome/browser/ui/views/payments/editor_view_controller.h" | 14 #include "chrome/browser/ui/views/payments/editor_view_controller.h" |
| 15 #include "chrome/browser/ui/views/payments/validating_textfield.h" | 15 #include "chrome/browser/ui/views/payments/validating_textfield.h" |
| 16 | 16 |
| 17 namespace autofill { | 17 namespace autofill { |
| 18 class AutofillProfile; | 18 class AutofillProfile; |
| 19 } // namespace autofill | 19 } // namespace autofill |
| 20 | 20 |
| 21 namespace payments { | 21 namespace payments { |
| 22 | 22 |
| 23 class PaymentRequestSpec; | 23 class PaymentRequestSpec; |
| 24 class PaymentRequestState; | 24 class PaymentRequestState; |
| 25 class PaymentRequestDialogView; | 25 class PaymentRequestDialogView; |
| 26 | 26 |
| 27 // Shipping Address editor screen of the Payment Request flow. | 27 // Shipping Address editor screen of the Payment Request flow. |
| 28 class ShippingAddressEditorViewController : public EditorViewController { | 28 class ShippingAddressEditorViewController : public EditorViewController { |
| 29 public: | 29 public: |
| 30 // Does not take ownership of the arguments, which should outlive this object. | 30 // Does not take ownership of the arguments (except for the |on_edited| and |
| 31 ShippingAddressEditorViewController(PaymentRequestSpec* spec, | 31 // |on_added| callbacks), which should outlive this object. Additionally, |
| 32 PaymentRequestState* state, | 32 // |profile| could be nullptr if we are adding a new shipping address. Else, |
| 33 PaymentRequestDialogView* dialog, | 33 // it's a valid pointer to a card that needs to be updated, and which will |
| 34 autofill::AutofillProfile* profile); | 34 // outlive this controller. |
| 35 ShippingAddressEditorViewController( |
| 36 PaymentRequestSpec* spec, |
| 37 PaymentRequestState* state, |
| 38 PaymentRequestDialogView* dialog, |
| 39 base::OnceClosure on_edited, |
| 40 base::OnceCallback<void(const autofill::AutofillProfile&)> on_added, |
| 41 autofill::AutofillProfile* profile); |
| 35 ~ShippingAddressEditorViewController() override; | 42 ~ShippingAddressEditorViewController() override; |
| 36 | 43 |
| 37 // EditorViewController: | 44 // EditorViewController: |
| 38 std::unique_ptr<views::View> CreateHeaderView() override; | 45 std::unique_ptr<views::View> CreateHeaderView() override; |
| 39 std::vector<EditorField> GetFieldDefinitions() override; | 46 std::vector<EditorField> GetFieldDefinitions() override; |
| 40 base::string16 GetInitialValueForType( | 47 base::string16 GetInitialValueForType( |
| 41 autofill::ServerFieldType type) override; | 48 autofill::ServerFieldType type) override; |
| 42 bool ValidateModelAndSave() override; | 49 bool ValidateModelAndSave() override; |
| 43 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( | 50 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( |
| 44 const EditorField& field) override; | 51 const EditorField& field) override; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 68 | 75 |
| 69 EditorField field_; | 76 EditorField field_; |
| 70 | 77 |
| 71 // Raw pointer back to the owner of this class, therefore will not be null. | 78 // Raw pointer back to the owner of this class, therefore will not be null. |
| 72 ShippingAddressEditorViewController* controller_; | 79 ShippingAddressEditorViewController* controller_; |
| 73 | 80 |
| 74 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate); | 81 DISALLOW_COPY_AND_ASSIGN(ShippingAddressValidationDelegate); |
| 75 }; | 82 }; |
| 76 friend class ShippingAddressValidationDelegate; | 83 friend class ShippingAddressValidationDelegate; |
| 77 | 84 |
| 85 // Called when |profile_to_edit_| was successfully edited. |
| 86 base::OnceClosure on_edited_; |
| 87 // Called when a new profile was added. The const reference is short-lived, |
| 88 // and the callee should make a copy. |
| 89 base::OnceCallback<void(const autofill::AutofillProfile&)> on_added_; |
| 90 |
| 78 // If non-nullptr, a point to an object to be edited, which should outlive | 91 // If non-nullptr, a point to an object to be edited, which should outlive |
| 79 // this controller. | 92 // this controller. |
| 80 autofill::AutofillProfile* profile_to_edit_; | 93 autofill::AutofillProfile* profile_to_edit_; |
| 81 | 94 |
| 82 // A temporary profile to keep unsaved data in between relayout (e.g., when | 95 // A temporary profile to keep unsaved data in between relayout (e.g., when |
| 83 // the country is changed and fields set may be different). | 96 // the country is changed and fields set may be different). |
| 84 std::unique_ptr<autofill::AutofillProfile> temporary_profile_; | 97 std::unique_ptr<autofill::AutofillProfile> temporary_profile_; |
| 85 | 98 |
| 86 // List of fields, reset everytime the current country changes. | 99 // List of fields, reset everytime the current country changes. |
| 87 std::vector<EditorField> editor_fields_; | 100 std::vector<EditorField> editor_fields_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 116 | 129 |
| 117 // Failed to fetch the region data in time. | 130 // Failed to fetch the region data in time. |
| 118 void RegionDataLoadTimedOut(); | 131 void RegionDataLoadTimedOut(); |
| 119 | 132 |
| 120 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController); | 133 DISALLOW_COPY_AND_ASSIGN(ShippingAddressEditorViewController); |
| 121 }; | 134 }; |
| 122 | 135 |
| 123 } // namespace payments | 136 } // namespace payments |
| 124 | 137 |
| 125 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL
LER_H_ | 138 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_SHIPPING_ADDRESS_EDITOR_VIEW_CONTROL
LER_H_ |
| OLD | NEW |