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/core/common/password_form_fill_data.h" | 5 #include "components/autofill/core/common/password_form_fill_data.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "components/autofill/core/common/form_field_data.h" | 8 #include "components/autofill/core/common/form_field_data.h" |
9 | 9 |
10 namespace autofill { | 10 namespace autofill { |
11 | 11 |
12 UsernamesCollectionKey::UsernamesCollectionKey() {} | 12 UsernamesCollectionKey::UsernamesCollectionKey() {} |
13 | 13 |
14 UsernamesCollectionKey::~UsernamesCollectionKey() {} | 14 UsernamesCollectionKey::~UsernamesCollectionKey() {} |
15 | 15 |
16 bool UsernamesCollectionKey::operator<( | 16 bool UsernamesCollectionKey::operator<( |
17 const UsernamesCollectionKey& other) const { | 17 const UsernamesCollectionKey& other) const { |
18 if (username != other.username) | 18 if (username != other.username) |
19 return username < other.username; | 19 return username < other.username; |
20 if (password != other.password) | 20 if (password != other.password) |
21 return password < other.password; | 21 return password < other.password; |
22 return realm < other.realm; | 22 return realm < other.realm; |
23 } | 23 } |
24 | 24 |
25 PasswordFormFillData::PasswordFormFillData() : wait_for_username(false) { | 25 PasswordFormFillData::PasswordFormFillData() : wait_for_username(false) { |
Ilya Sherman
2014/11/04 23:05:31
Please also initialize the user_submitted field.
Pritam Nikam
2014/11/05 05:58:14
Done.
| |
26 } | 26 } |
27 | 27 |
28 PasswordFormFillData::~PasswordFormFillData() { | 28 PasswordFormFillData::~PasswordFormFillData() { |
29 } | 29 } |
30 | 30 |
31 void InitPasswordFormFillData( | 31 void InitPasswordFormFillData( |
32 const PasswordForm& form_on_page, | 32 const PasswordForm& form_on_page, |
33 const PasswordFormMap& matches, | 33 const PasswordFormMap& matches, |
34 const PasswordForm* const preferred_match, | 34 const PasswordForm* const preferred_match, |
35 bool wait_for_username_before_autofill, | 35 bool wait_for_username_before_autofill, |
36 bool enable_other_possible_usernames, | 36 bool enable_other_possible_usernames, |
37 PasswordFormFillData* result) { | 37 PasswordFormFillData* result) { |
38 // Note that many of the |FormFieldData| members are not initialized for | 38 // Note that many of the |FormFieldData| members are not initialized for |
39 // |username_field| and |password_field| because they are currently not used | 39 // |username_field| and |password_field| because they are currently not used |
40 // by the password autocomplete code. | 40 // by the password autocomplete code. |
41 FormFieldData username_field; | 41 FormFieldData username_field; |
42 username_field.name = form_on_page.username_element; | 42 username_field.name = form_on_page.username_element; |
43 username_field.value = preferred_match->username_value; | 43 username_field.value = preferred_match->username_value; |
44 FormFieldData password_field; | 44 FormFieldData password_field; |
45 password_field.name = form_on_page.password_element; | 45 password_field.name = form_on_page.password_element; |
46 password_field.value = preferred_match->password_value; | 46 password_field.value = preferred_match->password_value; |
47 password_field.form_control_type = "password"; | 47 password_field.form_control_type = "password"; |
48 | 48 |
49 // Fill basic form data. | 49 // Fill basic form data. |
50 result->basic_data.name = form_on_page.form_data.name; | 50 result->name = form_on_page.form_data.name; |
51 result->basic_data.origin = form_on_page.origin; | 51 result->origin = form_on_page.origin; |
52 result->basic_data.action = form_on_page.action; | 52 result->action = form_on_page.action; |
53 result->basic_data.fields.push_back(username_field); | 53 result->username_field = username_field; |
54 result->basic_data.fields.push_back(password_field); | 54 result->password_field = password_field; |
55 result->wait_for_username = wait_for_username_before_autofill; | 55 result->wait_for_username = wait_for_username_before_autofill; |
Ilya Sherman
2014/11/04 23:05:31
Where do you set the user_submitted value?
Pritam Nikam
2014/11/05 05:58:14
Done.
| |
56 | 56 |
57 result->preferred_realm = preferred_match->original_signon_realm; | 57 result->preferred_realm = preferred_match->original_signon_realm; |
58 | 58 |
59 // Copy additional username/value pairs. | 59 // Copy additional username/value pairs. |
60 PasswordFormMap::const_iterator iter; | 60 PasswordFormMap::const_iterator iter; |
61 for (iter = matches.begin(); iter != matches.end(); iter++) { | 61 for (iter = matches.begin(); iter != matches.end(); iter++) { |
62 if (iter->second != preferred_match) { | 62 if (iter->second != preferred_match) { |
63 PasswordAndRealm value; | 63 PasswordAndRealm value; |
64 value.password = iter->second->password_value; | 64 value.password = iter->second->password_value; |
65 value.realm = iter->second->original_signon_realm; | 65 value.realm = iter->second->original_signon_realm; |
66 result->additional_logins[iter->first] = value; | 66 result->additional_logins[iter->first] = value; |
67 } | 67 } |
68 if (enable_other_possible_usernames && | 68 if (enable_other_possible_usernames && |
69 !iter->second->other_possible_usernames.empty()) { | 69 !iter->second->other_possible_usernames.empty()) { |
70 // Note that there may be overlap between other_possible_usernames and | 70 // Note that there may be overlap between other_possible_usernames and |
71 // other saved usernames or with other other_possible_usernames. For now | 71 // other saved usernames or with other other_possible_usernames. For now |
72 // we will ignore this overlap as it should be a rare occurence. We may | 72 // we will ignore this overlap as it should be a rare occurence. We may |
73 // want to revisit this in the future. | 73 // want to revisit this in the future. |
74 UsernamesCollectionKey key; | 74 UsernamesCollectionKey key; |
75 key.username = iter->first; | 75 key.username = iter->first; |
76 key.password = iter->second->password_value; | 76 key.password = iter->second->password_value; |
77 key.realm = iter->second->original_signon_realm; | 77 key.realm = iter->second->original_signon_realm; |
78 result->other_possible_usernames[key] = | 78 result->other_possible_usernames[key] = |
79 iter->second->other_possible_usernames; | 79 iter->second->other_possible_usernames; |
80 } | 80 } |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 } // namespace autofill | 84 } // namespace autofill |
OLD | NEW |