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 #include "chrome/browser/ui/views/payments/contact_info_editor_view_controller.h
" | 5 #include "chrome/browser/ui/views/payments/contact_info_editor_view_controller.h
" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/ui/views/payments/validating_textfield.h" | 8 #include "chrome/browser/ui/views/payments/validating_textfield.h" |
9 #include "components/autofill/core/browser/autofill_country.h" | 9 #include "components/autofill/core/browser/autofill_country.h" |
10 #include "components/autofill/core/browser/autofill_profile.h" | 10 #include "components/autofill/core/browser/autofill_profile.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 ContactInfoEditorViewController::ContactInfoValidationDelegate:: | 136 ContactInfoEditorViewController::ContactInfoValidationDelegate:: |
137 ContactInfoValidationDelegate(const EditorField& field, | 137 ContactInfoValidationDelegate(const EditorField& field, |
138 const std::string& locale, | 138 const std::string& locale, |
139 EditorViewController* controller) | 139 EditorViewController* controller) |
140 : field_(field), controller_(controller), locale_(locale) {} | 140 : field_(field), controller_(controller), locale_(locale) {} |
141 | 141 |
142 ContactInfoEditorViewController::ContactInfoValidationDelegate:: | 142 ContactInfoEditorViewController::ContactInfoValidationDelegate:: |
143 ~ContactInfoValidationDelegate() {} | 143 ~ContactInfoValidationDelegate() {} |
144 | 144 |
145 bool ContactInfoEditorViewController::ContactInfoValidationDelegate:: | 145 bool ContactInfoEditorViewController::ContactInfoValidationDelegate:: |
146 ValidateTextfield(views::Textfield* textfield) { | 146 ValidateTextfield(views::Textfield* textfield, bool display_error) { |
147 bool is_valid = true; | 147 bool is_valid = true; |
148 base::string16 error_message; | 148 base::string16 error_message; |
149 | 149 |
150 if (textfield->text().empty()) { | 150 if (textfield->text().empty()) { |
151 is_valid = false; | 151 is_valid = false; |
152 error_message = l10n_util::GetStringUTF16( | 152 error_message = l10n_util::GetStringUTF16( |
153 IDS_PAYMENTS_FIELD_REQUIRED_VALIDATION_MESSAGE); | 153 IDS_PAYMENTS_FIELD_REQUIRED_VALIDATION_MESSAGE); |
154 } else { | 154 } else { |
155 switch (field_.type) { | 155 switch (field_.type) { |
156 case autofill::PHONE_HOME_WHOLE_NUMBER: { | 156 case autofill::PHONE_HOME_WHOLE_NUMBER: { |
(...skipping 23 matching lines...) Expand all Loading... |
180 break; | 180 break; |
181 } | 181 } |
182 | 182 |
183 default: { | 183 default: { |
184 NOTREACHED(); | 184 NOTREACHED(); |
185 break; | 185 break; |
186 } | 186 } |
187 } | 187 } |
188 } | 188 } |
189 | 189 |
190 controller_->DisplayErrorMessageForField(field_, error_message); | 190 if (display_error) |
| 191 controller_->DisplayErrorMessageForField(field_, error_message); |
191 return is_valid; | 192 return is_valid; |
192 } | 193 } |
193 | 194 |
194 bool ContactInfoEditorViewController::ContactInfoValidationDelegate:: | 195 bool ContactInfoEditorViewController::ContactInfoValidationDelegate:: |
195 ValidateCombobox(views::Combobox* combobox) { | 196 ValidateCombobox(views::Combobox* combobox, bool display_error) { |
196 // This UI doesn't contain any comboboxes. | 197 // This UI doesn't contain any comboboxes. |
197 NOTREACHED(); | 198 NOTREACHED(); |
198 return true; | 199 return true; |
199 } | 200 } |
200 | 201 |
201 } // namespace payments | 202 } // namespace payments |
OLD | NEW |