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

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

Issue 2894943002: Prevent existing card number to be used for new credit cards in the Payment Request (Closed)
Patch Set: Fixed unit tests crash Created 3 years, 7 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>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 bool ValidateModelAndSave() override; 60 bool ValidateModelAndSave() override;
61 std::unique_ptr<ValidationDelegate> CreateValidationDelegate( 61 std::unique_ptr<ValidationDelegate> CreateValidationDelegate(
62 const EditorField& field) override; 62 const EditorField& field) override;
63 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType( 63 std::unique_ptr<ui::ComboboxModel> GetComboboxModelForType(
64 const autofill::ServerFieldType& type) override; 64 const autofill::ServerFieldType& type) override;
65 65
66 // Selects the icon in the UI corresponding to |basic_card_network| with 66 // Selects the icon in the UI corresponding to |basic_card_network| with
67 // higher opacity. If empty string, selects none of them (all full opacity). 67 // higher opacity. If empty string, selects none of them (all full opacity).
68 void SelectBasicCardNetworkIcon(const std::string& basic_card_network); 68 void SelectBasicCardNetworkIcon(const std::string& basic_card_network);
69 69
70 // Exposed for validation delegate.
71 bool IsValidCreditCardNumber(const base::string16& card_number,
72 base::string16* error_message);
73
70 protected: 74 protected:
71 // PaymentRequestSheetController: 75 // PaymentRequestSheetController:
72 void FillContentView(views::View* content_view) override; 76 void FillContentView(views::View* content_view) override;
73 base::string16 GetSheetTitle() override; 77 base::string16 GetSheetTitle() override;
74 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 78 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
75 79
76 private: 80 private:
77 class CreditCardValidationDelegate : public ValidationDelegate { 81 class CreditCardValidationDelegate : public ValidationDelegate {
78 public: 82 public:
79 // Used to validate |field| type. A reference to the |controller| should 83 // Used to validate |field| type. A reference to the |controller| should
80 // outlive this delegate, and a list of |supported_card_networks| can be 84 // outlive this delegate.
81 // passed in to validate |field| (the data will be copied to the delegate). 85 CreditCardValidationDelegate(const EditorField& field,
82 CreditCardValidationDelegate( 86 CreditCardEditorViewController* controller);
83 const EditorField& field,
84 CreditCardEditorViewController* controller,
85 const std::vector<std::string>& supported_card_networks);
86 ~CreditCardValidationDelegate() override; 87 ~CreditCardValidationDelegate() override;
87 88
88 // ValidationDelegate: 89 // ValidationDelegate:
89 bool ShouldFormat() override; 90 bool ShouldFormat() override;
90 base::string16 Format(const base::string16& text) override; 91 base::string16 Format(const base::string16& text) override;
91 bool IsValidTextfield(views::Textfield* textfield) override; 92 bool IsValidTextfield(views::Textfield* textfield) override;
92 bool IsValidCombobox(views::Combobox* combobox) override; 93 bool IsValidCombobox(views::Combobox* combobox) override;
93 bool TextfieldValueChanged(views::Textfield* textfield, 94 bool TextfieldValueChanged(views::Textfield* textfield,
94 bool was_blurred) override; 95 bool was_blurred) override;
95 bool ComboboxValueChanged(views::Combobox* combobox) override; 96 bool ComboboxValueChanged(views::Combobox* combobox) override;
96 void ComboboxModelChanged(views::Combobox* combobox) override {} 97 void ComboboxModelChanged(views::Combobox* combobox) override {}
97 98
98 private: 99 private:
99 // Validates a specific |value|/|combobox|. 100 // Validates a specific |value|/|combobox|.
100 bool ValidateValue(const base::string16& value, 101 bool ValidateValue(const base::string16& value,
101 base::string16* error_message); 102 base::string16* error_message);
102 bool ValidateCombobox(views::Combobox* combobox, 103 bool ValidateCombobox(views::Combobox* combobox,
103 base::string16* error_message); 104 base::string16* error_message);
104 105
105 EditorField field_; 106 EditorField field_;
106 // Outlives this class. 107 // Outlives this class.
107 CreditCardEditorViewController* controller_; 108 CreditCardEditorViewController* controller_;
108 // The list of supported basic card networks.
109 std::set<std::string> supported_card_networks_;
110 109
111 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate); 110 DISALLOW_COPY_AND_ASSIGN(CreditCardValidationDelegate);
112 }; 111 };
113 112
114 bool GetSheetId(DialogViewID* sheet_id) override; 113 bool GetSheetId(DialogViewID* sheet_id) override;
115 114
116 // Called when a new address was created to be used as the billing address. 115 // Called when a new address was created to be used as the billing address.
117 // The lifespan of |profile| beyond this call is undefined but it's OK, it's 116 // The lifespan of |profile| beyond this call is undefined but it's OK, it's
118 // simply propagated to the address combobox model. 117 // simply propagated to the address combobox model.
119 void AddAndSelectNewBillingAddress(const autofill::AutofillProfile& profile); 118 void AddAndSelectNewBillingAddress(const autofill::AutofillProfile& profile);
120 119
121 // Called when |credit_card_to_edit_| was successfully edited. 120 // Called when |credit_card_to_edit_| was successfully edited.
122 base::OnceClosure on_edited_; 121 base::OnceClosure on_edited_;
123 // Called when a new card was added. The const reference is short-lived, and 122 // Called when a new card was added. The const reference is short-lived, and
124 // the callee should make a copy. 123 // the callee should make a copy.
125 base::OnceCallback<void(const autofill::CreditCard&)> on_added_; 124 base::OnceCallback<void(const autofill::CreditCard&)> on_added_;
126 125
127 // If non-nullptr, a pointer to an object to be edited. Must outlive this 126 // If non-nullptr, a pointer to an object to be edited. Must outlive this
128 // controller. 127 // controller.
129 autofill::CreditCard* credit_card_to_edit_; 128 autofill::CreditCard* credit_card_to_edit_;
130 129
131 // Keeps track of the card icons currently visible, keyed by basic card 130 // Keeps track of the card icons currently visible, keyed by basic card
132 // network. 131 // network.
133 std::map<std::string, views::View*> card_icons_; 132 std::map<std::string, views::View*> card_icons_;
134 133
135 // The value to use for the add billing address button tag. 134 // The value to use for the add billing address button tag.
136 int add_billing_address_button_tag_; 135 int add_billing_address_button_tag_;
137 136
137 // The list of supported basic card networks.
138 std::set<std::string> supported_card_networks_;
139
138 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController); 140 DISALLOW_COPY_AND_ASSIGN(CreditCardEditorViewController);
139 }; 141 };
140 142
141 } // namespace payments 143 } // namespace payments
142 144
143 #endif // CHROME_BROWSER_UI_VIEWS_PAYMENTS_CREDIT_CARD_EDITOR_VIEW_CONTROLLER_H _ 145 #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