OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/content/browser/wallet/form_field_error.h" | 5 #include "components/autofill/content/browser/wallet/form_field_error.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 | 11 |
12 namespace autofill { | 12 namespace autofill { |
13 namespace wallet { | 13 namespace wallet { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 FormFieldError::ErrorType ErrorTypeFromString(const std::string& error_type) { | 17 FormFieldError::ErrorType ErrorTypeFromString(const std::string& error_type) { |
18 if (LowerCaseEqualsASCII(error_type, "unknown_error")) | 18 if (base::LowerCaseEqualsASCII(error_type, "unknown_error")) |
19 return FormFieldError::UNKNOWN_ERROR; | 19 return FormFieldError::UNKNOWN_ERROR; |
20 if (LowerCaseEqualsASCII(error_type, "invalid_phone_number")) | 20 if (base::LowerCaseEqualsASCII(error_type, "invalid_phone_number")) |
21 return FormFieldError::INVALID_PHONE_NUMBER; | 21 return FormFieldError::INVALID_PHONE_NUMBER; |
22 if (LowerCaseEqualsASCII(error_type, "invalid_postal_code")) | 22 if (base::LowerCaseEqualsASCII(error_type, "invalid_postal_code")) |
23 return FormFieldError::INVALID_POSTAL_CODE; | 23 return FormFieldError::INVALID_POSTAL_CODE; |
24 if (LowerCaseEqualsASCII(error_type, "invalid_address")) | 24 if (base::LowerCaseEqualsASCII(error_type, "invalid_address")) |
25 return FormFieldError::INVALID_ADDRESS; | 25 return FormFieldError::INVALID_ADDRESS; |
26 if (LowerCaseEqualsASCII(error_type, "invalid_card_details")) | 26 if (base::LowerCaseEqualsASCII(error_type, "invalid_card_details")) |
27 return FormFieldError::INVALID_CARD_DETAILS; | 27 return FormFieldError::INVALID_CARD_DETAILS; |
28 if (LowerCaseEqualsASCII(error_type, "invalid_city")) | 28 if (base::LowerCaseEqualsASCII(error_type, "invalid_city")) |
29 return FormFieldError::INVALID_CITY; | 29 return FormFieldError::INVALID_CITY; |
30 if (LowerCaseEqualsASCII(error_type, "invalid_instrument")) | 30 if (base::LowerCaseEqualsASCII(error_type, "invalid_instrument")) |
31 return FormFieldError::INVALID_INSTRUMENT; | 31 return FormFieldError::INVALID_INSTRUMENT; |
32 if (LowerCaseEqualsASCII(error_type, "invalid_state")) | 32 if (base::LowerCaseEqualsASCII(error_type, "invalid_state")) |
33 return FormFieldError::INVALID_STATE; | 33 return FormFieldError::INVALID_STATE; |
34 if (LowerCaseEqualsASCII(error_type, "required_field_not_set")) | 34 if (base::LowerCaseEqualsASCII(error_type, "required_field_not_set")) |
35 return FormFieldError::REQUIRED_FIELD_NOT_SET; | 35 return FormFieldError::REQUIRED_FIELD_NOT_SET; |
36 return FormFieldError::UNKNOWN_ERROR; | 36 return FormFieldError::UNKNOWN_ERROR; |
37 } | 37 } |
38 | 38 |
39 FormFieldError::Location LocationFromString(const std::string& location) { | 39 FormFieldError::Location LocationFromString(const std::string& location) { |
40 if (LowerCaseEqualsASCII(location, "unknown_location")) | 40 if (base::LowerCaseEqualsASCII(location, "unknown_location")) |
41 return FormFieldError::UNKNOWN_LOCATION; | 41 return FormFieldError::UNKNOWN_LOCATION; |
42 if (LowerCaseEqualsASCII(location, "payment_instrument")) | 42 if (base::LowerCaseEqualsASCII(location, "payment_instrument")) |
43 return FormFieldError::PAYMENT_INSTRUMENT; | 43 return FormFieldError::PAYMENT_INSTRUMENT; |
44 if (LowerCaseEqualsASCII(location, "shipping_address")) | 44 if (base::LowerCaseEqualsASCII(location, "shipping_address")) |
45 return FormFieldError::SHIPPING_ADDRESS; | 45 return FormFieldError::SHIPPING_ADDRESS; |
46 if (LowerCaseEqualsASCII(location, "legal_address")) | 46 if (base::LowerCaseEqualsASCII(location, "legal_address")) |
47 return FormFieldError::LEGAL_ADDRESS; | 47 return FormFieldError::LEGAL_ADDRESS; |
48 return FormFieldError::UNKNOWN_LOCATION; | 48 return FormFieldError::UNKNOWN_LOCATION; |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 FormFieldError::FormFieldError(ErrorType error_type, Location location) | 53 FormFieldError::FormFieldError(ErrorType error_type, Location location) |
54 : error_type_(error_type), | 54 : error_type_(error_type), |
55 location_(location) {} | 55 location_(location) {} |
56 | 56 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 return form_field_error; | 146 return form_field_error; |
147 } | 147 } |
148 | 148 |
149 bool FormFieldError::operator==(const FormFieldError& other) const { | 149 bool FormFieldError::operator==(const FormFieldError& other) const { |
150 return error_type_ == other.error_type_ && location_ == other.location_; | 150 return error_type_ == other.error_type_ && location_ == other.location_; |
151 } | 151 } |
152 | 152 |
153 } // namespace wallet | 153 } // namespace wallet |
154 } // namespace autofill | 154 } // namespace autofill |
OLD | NEW |