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_COMMON_PASSWORD_FORM_FILL_DATA_H_ | 5 #ifndef COMPONENTS_AUTOFILL_COMMON_PASSWORD_FORM_FILL_DATA_H_ |
6 #define COMPONENTS_AUTOFILL_COMMON_PASSWORD_FORM_FILL_DATA_H_ | 6 #define COMPONENTS_AUTOFILL_COMMON_PASSWORD_FORM_FILL_DATA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "components/autofill/common/form_data.h" | 11 #include "components/autofill/common/form_data.h" |
12 #include "content/public/common/password_form.h" | 12 #include "content/public/common/password_form.h" |
13 | 13 |
14 namespace autofill { | 14 namespace autofill { |
15 | 15 |
16 // Helper struct for PasswordFormFillData | 16 // Helper struct for PasswordFormFillData |
17 struct UsernamesCollectionKey { | 17 struct UsernamesCollectionKey { |
18 UsernamesCollectionKey(); | 18 UsernamesCollectionKey(); |
19 ~UsernamesCollectionKey(); | 19 ~UsernamesCollectionKey(); |
20 | 20 |
21 // Defined so that this struct can be used as a key in a std::map. | 21 // Defined so that this struct can be used as a key in a std::map. |
22 bool operator<(const UsernamesCollectionKey& other) const; | 22 bool operator<(const UsernamesCollectionKey& other) const; |
23 | 23 |
24 base::string16 username; | 24 base::string16 username; |
25 base::string16 password; | 25 base::string16 password; |
26 }; | 26 }; |
27 | 27 |
| 28 struct PasswordAndRealm { |
| 29 base::string16 password; |
| 30 std::string realm; |
| 31 }; |
| 32 |
28 // Structure used for autofilling password forms. | 33 // Structure used for autofilling password forms. |
29 // basic_data identifies the HTML form on the page and preferred username/ | |
30 // password for login, while | |
31 // additional_logins is a list of other matching user/pass pairs for the form. | |
32 // other_possible_usernames is a list of possible usernames in the case where we | |
33 // aren't completely sure that the original saved username is correct. | |
34 // This data is keyed by the saved username/password to ensure uniqueness, | |
35 // though the username is not used. | |
36 // wait_for_username tells us whether we need to wait for the user to enter | |
37 // a valid username before we autofill the password. By default, this is off | |
38 // unless the PasswordManager determined there is an additional risk | |
39 // associated with this form. This can happen, for example, if action URI's | |
40 // of the observed form and our saved representation don't match up. | |
41 struct PasswordFormFillData { | 34 struct PasswordFormFillData { |
42 typedef std::map<base::string16, base::string16> LoginCollection; | 35 typedef std::map<base::string16, PasswordAndRealm> LoginCollection; |
43 typedef std::map<UsernamesCollectionKey, | 36 typedef std::map<UsernamesCollectionKey, |
44 std::vector<base::string16> > UsernamesCollection; | 37 std::vector<base::string16> > UsernamesCollection; |
45 | 38 |
| 39 // Identifies the HTML form on the page and preferred username/password for |
| 40 // login. |
46 FormData basic_data; | 41 FormData basic_data; |
| 42 |
| 43 // The signon realm of the preferred user/pass pair. |
| 44 std::string preferred_realm; |
| 45 |
| 46 // A list of other matching username->PasswordAndRealm pairs for the form. |
47 LoginCollection additional_logins; | 47 LoginCollection additional_logins; |
| 48 |
| 49 // A list of possible usernames in the case where we aren't completely sure |
| 50 // that the original saved username is correct. This data is keyed by the |
| 51 // saved username/password to ensure uniqueness, though the username is not |
| 52 // used. |
48 UsernamesCollection other_possible_usernames; | 53 UsernamesCollection other_possible_usernames; |
| 54 |
| 55 // Tells us whether we need to wait for the user to enter a valid username |
| 56 // before we autofill the password. By default, this is off unless the |
| 57 // PasswordManager determined there is an additional risk associated with this |
| 58 // form. This can happen, for example, if action URI's of the observed form |
| 59 // and our saved representation don't match up. |
49 bool wait_for_username; | 60 bool wait_for_username; |
| 61 |
50 PasswordFormFillData(); | 62 PasswordFormFillData(); |
51 ~PasswordFormFillData(); | 63 ~PasswordFormFillData(); |
52 }; | 64 }; |
53 | 65 |
54 // Create a FillData structure in preparation for autofilling a form, | 66 // Create a FillData structure in preparation for autofilling a form, |
55 // from basic_data identifying which form to fill, and a collection of | 67 // from basic_data identifying which form to fill, and a collection of |
56 // matching stored logins to use as username/password values. | 68 // matching stored logins to use as username/password values. |
57 // |preferred_match| should equal (address) one of matches. | 69 // |preferred_match| should equal (address) one of matches. |
58 // |wait_for_username_before_autofill| is true if we should not autofill | 70 // |wait_for_username_before_autofill| is true if we should not autofill |
59 // anything until the user typed in a valid username and blurred the field. | 71 // anything until the user typed in a valid username and blurred the field. |
60 // If |enable_possible_usernames| is true, we will populate possible_usernames | 72 // If |enable_possible_usernames| is true, we will populate possible_usernames |
61 // in |result|. | 73 // in |result|. |
62 void InitPasswordFormFillData( | 74 void InitPasswordFormFillData( |
63 const content::PasswordForm& form_on_page, | 75 const content::PasswordForm& form_on_page, |
64 const content::PasswordFormMap& matches, | 76 const content::PasswordFormMap& matches, |
65 const content::PasswordForm* const preferred_match, | 77 const content::PasswordForm* const preferred_match, |
66 bool wait_for_username_before_autofill, | 78 bool wait_for_username_before_autofill, |
67 bool enable_other_possible_usernames, | 79 bool enable_other_possible_usernames, |
68 PasswordFormFillData* result); | 80 PasswordFormFillData* result); |
69 | 81 |
70 } // namespace autofill | 82 } // namespace autofill |
71 | 83 |
72 #endif // COMPONENTS_AUTOFILL_COMMON_PASSWORD_FORM_FILL_DATA_H__ | 84 #endif // COMPONENTS_AUTOFILL_COMMON_PASSWORD_FORM_FILL_DATA_H__ |
OLD | NEW |