OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/core/common/autofill_data_validation.h" | 5 #include "components/autofill/core/common/autofill_data_validation.h" |
6 | 6 |
7 #include "components/autofill/core/common/form_data.h" | 7 #include "components/autofill/core/common/form_data.h" |
8 #include "components/autofill/core/common/form_field_data.h" | 8 #include "components/autofill/core/common/form_field_data.h" |
9 #include "components/autofill/core/common/password_form_fill_data.h" | 9 #include "components/autofill/core/common/password_form_fill_data.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 | 51 |
52 for (std::vector<FormFieldData>::const_iterator it = form.fields.begin(); | 52 for (std::vector<FormFieldData>::const_iterator it = form.fields.begin(); |
53 it != form.fields.end(); ++it) { | 53 it != form.fields.end(); ++it) { |
54 if (!IsValidFormFieldData(*it)) | 54 if (!IsValidFormFieldData(*it)) |
55 return false; | 55 return false; |
56 } | 56 } |
57 | 57 |
58 return true; | 58 return true; |
59 } | 59 } |
60 | 60 |
61 bool IsValidPasswordFormData(const PasswordFormFillData& form) { | |
Ilya Sherman
2014/11/04 23:05:31
If you wanted to factor out this function, it woul
Pritam Nikam
2014/11/05 05:58:14
Done.
| |
62 if (!IsValidString16(form.name) || !IsValidGURL(form.origin) || | |
63 !IsValidGURL(form.action)) | |
64 return false; | |
65 | |
66 return IsValidFormFieldData(form.username_field) && | |
67 IsValidFormFieldData(form.password_field); | |
68 } | |
69 | |
61 bool IsValidPasswordFormFillData(const PasswordFormFillData& form) { | 70 bool IsValidPasswordFormFillData(const PasswordFormFillData& form) { |
62 if (!IsValidFormData(form.basic_data) || | 71 if (!IsValidPasswordFormData(form) || !IsValidString(form.preferred_realm)) |
63 !IsValidString(form.preferred_realm)) | |
64 return false; | 72 return false; |
65 | 73 |
66 for (PasswordFormFillData::LoginCollection::const_iterator it = | 74 for (PasswordFormFillData::LoginCollection::const_iterator it = |
67 form.additional_logins.begin(); | 75 form.additional_logins.begin(); |
68 it != form.additional_logins.end(); ++it) { | 76 it != form.additional_logins.end(); ++it) { |
69 if (!IsValidString16(it->first) || | 77 if (!IsValidString16(it->first) || |
70 !IsValidString16(it->second.password) || | 78 !IsValidString16(it->second.password) || |
71 !IsValidString(it->second.realm)) | 79 !IsValidString(it->second.realm)) |
72 return false; | 80 return false; |
73 } | 81 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 for (std::vector<FormData>::const_iterator it = v.begin(); it != v.end(); | 113 for (std::vector<FormData>::const_iterator it = v.begin(); it != v.end(); |
106 ++it) { | 114 ++it) { |
107 if (!IsValidFormData(*it)) | 115 if (!IsValidFormData(*it)) |
108 return false; | 116 return false; |
109 } | 117 } |
110 | 118 |
111 return true; | 119 return true; |
112 } | 120 } |
113 | 121 |
114 } // namespace autofill | 122 } // namespace autofill |
OLD | NEW |