Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Side by Side Diff: chrome/browser/ui/views/payments/credit_card_editor_view_controller.h

Issue 2807363003: [Payments] After adding/editing a credit card, instrument is selected. (Closed)
Patch Set: include fix Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/credit_card_editor_view_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/callback_forward.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "chrome/browser/ui/views/payments/editor_view_controller.h" 15 #include "chrome/browser/ui/views/payments/editor_view_controller.h"
15 #include "chrome/browser/ui/views/payments/validation_delegate.h" 16 #include "chrome/browser/ui/views/payments/validation_delegate.h"
16 #include "ui/base/models/simple_combobox_model.h" 17 #include "ui/base/models/simple_combobox_model.h"
17 18
18 namespace autofill { 19 namespace autofill {
19 class CreditCard; 20 class CreditCard;
20 } // namespace autofill 21 } // namespace autofill
21 22
22 namespace payments { 23 namespace payments {
23 24
24 class PaymentRequestSpec; 25 class PaymentRequestSpec;
25 class PaymentRequestState; 26 class PaymentRequestState;
26 class PaymentRequestDialogView; 27 class PaymentRequestDialogView;
27 28
28 // Credit card editor screen of the Payment Request flow. 29 // Credit card editor screen of the Payment Request flow.
29 class CreditCardEditorViewController : public EditorViewController { 30 class CreditCardEditorViewController : public EditorViewController {
30 public: 31 public:
31 // Does not take ownership of the arguments, which should outlive this object. 32 // 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 // 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 // it's a valid pointer to a card that needs to be updated, and which will
34 // outlive this controller. 35 // outlive this controller.
35 CreditCardEditorViewController(PaymentRequestSpec* spec, 36 CreditCardEditorViewController(
36 PaymentRequestState* state, 37 PaymentRequestSpec* spec,
37 PaymentRequestDialogView* dialog, 38 PaymentRequestState* state,
38 autofill::CreditCard* credit_card); 39 PaymentRequestDialogView* dialog,
40 base::OnceClosure on_edited,
41 base::OnceCallback<void(const autofill::CreditCard&)> on_added,
42 autofill::CreditCard* credit_card);
39 ~CreditCardEditorViewController() override; 43 ~CreditCardEditorViewController() override;
40 44
41 // EditorViewController: 45 // EditorViewController:
42 std::unique_ptr<views::View> CreateHeaderView() override; 46 std::unique_ptr<views::View> CreateHeaderView() override;
43 std::vector<EditorField> GetFieldDefinitions() override; 47 std::vector<EditorField> GetFieldDefinitions() override;
44 base::string16 GetInitialValueForType( 48 base::string16 GetInitialValueForType(
45 autofill::ServerFieldType type) override; 49 autofill::ServerFieldType type) override;
46 bool ValidateModelAndSave() override; 50 bool ValidateModelAndSave() override;
47 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( 51 std::unique_ptr<ValidationDelegate> CreateValidationDelegate(
48 const EditorField& field) override; 52 const EditorField& field) override;
(...skipping 26 matching lines...) Expand all
75 79
76 EditorField field_; 80 EditorField field_;
77 // Outlives this class. 81 // Outlives this class.
78 EditorViewController* controller_; 82 EditorViewController* controller_;
79 // The list of supported basic card networks. 83 // The list of supported basic card networks.
80 std::set<std::string> supported_card_networks_; 84 std::set<std::string> supported_card_networks_;
81 85
82 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate); 86 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate);
83 }; 87 };
84 88
89 // Called when |credit_card_to_edit_| was successfully edited.
90 base::OnceClosure on_edited_;
91 // Called when a new card was added. The const reference is short-lived, and
92 // the callee should make a copy.
93 base::OnceCallback<void(const autofill::CreditCard&)> on_added_;
94
85 // If non-nullptr, a pointer to an object to be edited. Must outlive this 95 // If non-nullptr, a pointer to an object to be edited. Must outlive this
86 // controller. 96 // controller.
87 autofill::CreditCard* credit_card_to_edit_; 97 autofill::CreditCard* credit_card_to_edit_;
88 98
89 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController); 99 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController);
90 }; 100 };
91 101
92 } // namespace payments 102 } // namespace payments
93 103
94 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H _ 104 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H _
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/credit_card_editor_view_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698