| 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 #ifndef COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_FORM_H__ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_FORM_H__ |
| 6 #define COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_FORM_H__ | 6 #define COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_FORM_H__ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "components/autofill/core/common/form_data.h" | 14 #include "components/autofill/core/common/form_data.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 #include "url/origin.h" | 16 #include "url/origin.h" |
| 17 | 17 |
| 18 namespace autofill { | 18 namespace autofill { |
| 19 | 19 |
| 20 // Pair of possible username value and field name that contained this value. |
| 21 using PossibleUsernamePair = std::pair<base::string16, base::string16>; |
| 22 |
| 23 // Vector of possible username values and corresponding field names. |
| 24 using PossibleUsernamesVector = std::vector<PossibleUsernamePair>; |
| 25 |
| 20 // The PasswordForm struct encapsulates information about a login form, | 26 // The PasswordForm struct encapsulates information about a login form, |
| 21 // which can be an HTML form or a dialog with username/password text fields. | 27 // which can be an HTML form or a dialog with username/password text fields. |
| 22 // | 28 // |
| 23 // The Web Data database stores saved username/passwords and associated form | 29 // The Web Data database stores saved username/passwords and associated form |
| 24 // metdata using a PasswordForm struct, typically one that was created from | 30 // metdata using a PasswordForm struct, typically one that was created from |
| 25 // a parsed HTMLFormElement or LoginDialog, but the saved entries could have | 31 // a parsed HTMLFormElement or LoginDialog, but the saved entries could have |
| 26 // also been created by imported data from another browser. | 32 // also been created by imported data from another browser. |
| 27 // | 33 // |
| 28 // The PasswordManager implements a fuzzy-matching algorithm to compare saved | 34 // The PasswordManager implements a fuzzy-matching algorithm to compare saved |
| 29 // PasswordForm entries against PasswordForms that were created from a parsed | 35 // PasswordForm entries against PasswordForms that were created from a parsed |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // | 140 // |
| 135 // When parsing an HTML form, this is typically empty unless the site | 141 // When parsing an HTML form, this is typically empty unless the site |
| 136 // has implemented some form of autofill. | 142 // has implemented some form of autofill. |
| 137 base::string16 username_value; | 143 base::string16 username_value; |
| 138 | 144 |
| 139 // This member is populated in cases where we there are multiple input | 145 // This member is populated in cases where we there are multiple input |
| 140 // elements that could possibly be the username. Used when our heuristics for | 146 // elements that could possibly be the username. Used when our heuristics for |
| 141 // determining the username are incorrect. Optional. | 147 // determining the username are incorrect. Optional. |
| 142 // | 148 // |
| 143 // When parsing an HTML form, this is typically empty. | 149 // When parsing an HTML form, this is typically empty. |
| 144 std::vector<base::string16> other_possible_usernames; | 150 PossibleUsernamesVector other_possible_usernames; |
| 145 | 151 |
| 146 // The name of the input element corresponding to the current password. | 152 // The name of the input element corresponding to the current password. |
| 147 // Optional (improves scoring). | 153 // Optional (improves scoring). |
| 148 // | 154 // |
| 149 // When parsing an HTML form, this will always be set, unless it is a sign-up | 155 // When parsing an HTML form, this will always be set, unless it is a sign-up |
| 150 // form or a change password form that does not ask for the current password. | 156 // form or a change password form that does not ask for the current password. |
| 151 // In these two cases the |new_password_element| will always be set. | 157 // In these two cases the |new_password_element| will always be set. |
| 152 base::string16 password_element; | 158 base::string16 password_element; |
| 153 | 159 |
| 154 // The current password. Must be non-empty for PasswordForm instances that are | 160 // The current password. Must be non-empty for PasswordForm instances that are |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // (origin, username_element, username_value, password_element, signon_realm). | 300 // (origin, username_element, username_value, password_element, signon_realm). |
| 295 bool ArePasswordFormUniqueKeyEqual(const PasswordForm& left, | 301 bool ArePasswordFormUniqueKeyEqual(const PasswordForm& left, |
| 296 const PasswordForm& right); | 302 const PasswordForm& right); |
| 297 | 303 |
| 298 // A comparator for the unique key. | 304 // A comparator for the unique key. |
| 299 struct LessThanUniqueKey { | 305 struct LessThanUniqueKey { |
| 300 bool operator()(const std::unique_ptr<PasswordForm>& left, | 306 bool operator()(const std::unique_ptr<PasswordForm>& left, |
| 301 const std::unique_ptr<PasswordForm>& right) const; | 307 const std::unique_ptr<PasswordForm>& right) const; |
| 302 }; | 308 }; |
| 303 | 309 |
| 310 // Converts a vector of possible usernames to string. |
| 311 base::string16 OtherPossibleUsernamesToString( |
| 312 const PossibleUsernamesVector& possible_usernames); |
| 313 |
| 304 // For testing. | 314 // For testing. |
| 305 std::ostream& operator<<(std::ostream& os, PasswordForm::Layout layout); | 315 std::ostream& operator<<(std::ostream& os, PasswordForm::Layout layout); |
| 306 std::ostream& operator<<(std::ostream& os, const PasswordForm& form); | 316 std::ostream& operator<<(std::ostream& os, const PasswordForm& form); |
| 307 std::ostream& operator<<(std::ostream& os, PasswordForm* form); | 317 std::ostream& operator<<(std::ostream& os, PasswordForm* form); |
| 308 | 318 |
| 309 } // namespace autofill | 319 } // namespace autofill |
| 310 | 320 |
| 311 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_FORM_H__ | 321 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_PASSWORD_FORM_H__ |
| OLD | NEW |