OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/common/password_form_fill_data.h" | 5 #include "components/autofill/common/password_form_fill_data.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/utf_string_conversions.h" | |
8 #include "components/autofill/common/form_field_data.h" | 9 #include "components/autofill/common/form_field_data.h" |
9 | 10 |
11 namespace { | |
Ilya Sherman
2013/06/19 23:41:14
nit: Please leave a blank line after this one.
nyquist
2013/06/21 21:01:27
Done.
| |
12 std::string GetPreferredSignonRealm(const content::PasswordForm* form) { | |
Ilya Sherman
2013/06/19 23:41:14
nit: Can this be passed by const-reference?
nyquist
2013/06/21 21:01:27
Done.
| |
13 if (form->IsPublicSuffixMatch()) | |
14 return form->original_signon_realm; | |
15 else | |
16 return form->signon_realm; | |
17 } | |
18 | |
19 } // namespace | |
20 | |
10 namespace autofill { | 21 namespace autofill { |
11 | 22 |
12 UsernamesCollectionKey::UsernamesCollectionKey() {} | 23 UsernamesCollectionKey::UsernamesCollectionKey() {} |
13 | 24 |
14 UsernamesCollectionKey::~UsernamesCollectionKey() {} | 25 UsernamesCollectionKey::~UsernamesCollectionKey() {} |
15 | 26 |
16 bool UsernamesCollectionKey::operator<( | 27 bool UsernamesCollectionKey::operator<( |
17 const UsernamesCollectionKey& other) const { | 28 const UsernamesCollectionKey& other) const { |
18 if (username != other.username) | 29 if (username != other.username) |
19 return username < other.username; | 30 return username < other.username; |
(...skipping 24 matching lines...) Expand all Loading... | |
44 password_field.value = preferred_match->password_value; | 55 password_field.value = preferred_match->password_value; |
45 password_field.form_control_type = "password"; | 56 password_field.form_control_type = "password"; |
46 | 57 |
47 // Fill basic form data. | 58 // Fill basic form data. |
48 result->basic_data.origin = form_on_page.origin; | 59 result->basic_data.origin = form_on_page.origin; |
49 result->basic_data.action = form_on_page.action; | 60 result->basic_data.action = form_on_page.action; |
50 result->basic_data.fields.push_back(username_field); | 61 result->basic_data.fields.push_back(username_field); |
51 result->basic_data.fields.push_back(password_field); | 62 result->basic_data.fields.push_back(password_field); |
52 result->wait_for_username = wait_for_username_before_autofill; | 63 result->wait_for_username = wait_for_username_before_autofill; |
53 | 64 |
65 result->preferred_realm = GetPreferredSignonRealm(preferred_match); | |
66 | |
54 // Copy additional username/value pairs. | 67 // Copy additional username/value pairs. |
55 content::PasswordFormMap::const_iterator iter; | 68 content::PasswordFormMap::const_iterator iter; |
56 for (iter = matches.begin(); iter != matches.end(); iter++) { | 69 for (iter = matches.begin(); iter != matches.end(); iter++) { |
57 if (iter->second != preferred_match) | 70 if (iter->second != preferred_match) { |
58 result->additional_logins[iter->first] = iter->second->password_value; | 71 PasswordAndRealm value; |
72 value.password = iter->second->password_value; | |
73 value.realm = GetPreferredSignonRealm(iter->second); | |
74 result->additional_logins[iter->first] = value; | |
75 } | |
59 if (enable_other_possible_usernames && | 76 if (enable_other_possible_usernames && |
60 !iter->second->other_possible_usernames.empty()) { | 77 !iter->second->other_possible_usernames.empty()) { |
61 // Note that there may be overlap between other_possible_usernames and | 78 // Note that there may be overlap between other_possible_usernames and |
62 // other saved usernames or with other other_possible_usernames. For now | 79 // other saved usernames or with other other_possible_usernames. For now |
63 // we will ignore this overlap as it should be a rare occurence. We may | 80 // we will ignore this overlap as it should be a rare occurence. We may |
64 // want to revisit this in the future. | 81 // want to revisit this in the future. |
65 UsernamesCollectionKey key; | 82 UsernamesCollectionKey key; |
66 key.username = iter->first; | 83 key.username = iter->first; |
67 key.password = iter->second->password_value; | 84 key.password = iter->second->password_value; |
68 result->other_possible_usernames[key] = | 85 result->other_possible_usernames[key] = |
69 iter->second->other_possible_usernames; | 86 iter->second->other_possible_usernames; |
70 } | 87 } |
71 } | 88 } |
72 } | 89 } |
73 | 90 |
74 } // namespace autofill | 91 } // namespace autofill |
OLD | NEW |