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_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.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/validation_delegate.h" | 15 #include "chrome/browser/ui/views/payments/validation_delegate.h" |
16 #include "ui/base/models/simple_combobox_model.h" | 16 #include "ui/base/models/simple_combobox_model.h" |
17 | 17 |
| 18 namespace autofill { |
| 19 class CreditCard; |
| 20 } // namespace autofill |
| 21 |
18 namespace payments { | 22 namespace payments { |
19 | 23 |
20 class PaymentRequestSpec; | 24 class PaymentRequestSpec; |
21 class PaymentRequestState; | 25 class PaymentRequestState; |
22 class PaymentRequestDialogView; | 26 class PaymentRequestDialogView; |
23 | 27 |
24 // Credit card editor screen of the Payment Request flow. | 28 // Credit card editor screen of the Payment Request flow. |
25 class CreditCardEditorViewController : public EditorViewController { | 29 class CreditCardEditorViewController : public EditorViewController { |
26 public: | 30 public: |
27 // Does not take ownership of the arguments, which should outlive this object. | 31 // Does not take ownership of the arguments, which should outlive this object. |
| 32 // Additionally, |credit_card| could be nullptr if we are adding a card. Else, |
| 33 // it's a valid pointer to a card that needs to be updated, and which will |
| 34 // outlive this controller. |
28 CreditCardEditorViewController(PaymentRequestSpec* spec, | 35 CreditCardEditorViewController(PaymentRequestSpec* spec, |
29 PaymentRequestState* state, | 36 PaymentRequestState* state, |
30 PaymentRequestDialogView* dialog); | 37 PaymentRequestDialogView* dialog, |
| 38 autofill::CreditCard* credit_card); |
31 ~CreditCardEditorViewController() override; | 39 ~CreditCardEditorViewController() override; |
32 | 40 |
33 // EditorViewController: | 41 // EditorViewController: |
34 std::unique_ptr<views::View> CreateHeaderView() override; | 42 std::unique_ptr<views::View> CreateHeaderView() override; |
35 std::vector<EditorField> GetFieldDefinitions() override; | 43 std::vector<EditorField> GetFieldDefinitions() override; |
| 44 base::string16 GetInitialValueForType( |
| 45 autofill::ServerFieldType type) override; |
36 bool ValidateModelAndSave() override; | 46 bool ValidateModelAndSave() override; |
37 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( | 47 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( |
38 const EditorField& field) override; | 48 const EditorField& field) override; |
39 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( | 49 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( |
40 const autofill::ServerFieldType& type) override; | 50 const autofill::ServerFieldType& type) override; |
41 | 51 |
42 protected: | 52 protected: |
43 // PaymentRequestSheetController: | 53 // PaymentRequestSheetController: |
44 base::string16 GetSheetTitle() override; | 54 base::string16 GetSheetTitle() override; |
45 | 55 |
(...skipping 19 matching lines...) Expand all Loading... |
65 | 75 |
66 EditorField field_; | 76 EditorField field_; |
67 // Outlives this class. | 77 // Outlives this class. |
68 EditorViewController* controller_; | 78 EditorViewController* controller_; |
69 // The list of supported basic card networks. | 79 // The list of supported basic card networks. |
70 std::set<std::string> supported_card_networks_; | 80 std::set<std::string> supported_card_networks_; |
71 | 81 |
72 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate); | 82 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate); |
73 }; | 83 }; |
74 | 84 |
| 85 // If non-nullptr, a pointer to an object to be edited. Must outlive this |
| 86 // controller. |
| 87 autofill::CreditCard* credit_card_to_edit_; |
| 88 |
75 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController); | 89 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController); |
76 }; | 90 }; |
77 | 91 |
78 } // namespace payments | 92 } // namespace payments |
79 | 93 |
80 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H
_ | 94 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H
_ |
OLD | NEW |