| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/autofill/common/password_form_fill_data.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "components/autofill/common/form_field_data.h" | |
| 9 | |
| 10 namespace autofill { | |
| 11 | |
| 12 UsernamesCollectionKey::UsernamesCollectionKey() {} | |
| 13 | |
| 14 UsernamesCollectionKey::~UsernamesCollectionKey() {} | |
| 15 | |
| 16 bool UsernamesCollectionKey::operator<( | |
| 17 const UsernamesCollectionKey& other) const { | |
| 18 if (username != other.username) | |
| 19 return username < other.username; | |
| 20 return password < other.password; | |
| 21 } | |
| 22 | |
| 23 PasswordFormFillData::PasswordFormFillData() : wait_for_username(false) { | |
| 24 } | |
| 25 | |
| 26 PasswordFormFillData::~PasswordFormFillData() { | |
| 27 } | |
| 28 | |
| 29 void InitPasswordFormFillData( | |
| 30 const content::PasswordForm& form_on_page, | |
| 31 const content::PasswordFormMap& matches, | |
| 32 const content::PasswordForm* const preferred_match, | |
| 33 bool wait_for_username_before_autofill, | |
| 34 bool enable_other_possible_usernames, | |
| 35 PasswordFormFillData* result) { | |
| 36 // Note that many of the |FormFieldData| members are not initialized for | |
| 37 // |username_field| and |password_field| because they are currently not used | |
| 38 // by the password autocomplete code. | |
| 39 FormFieldData username_field; | |
| 40 username_field.name = form_on_page.username_element; | |
| 41 username_field.value = preferred_match->username_value; | |
| 42 FormFieldData password_field; | |
| 43 password_field.name = form_on_page.password_element; | |
| 44 password_field.value = preferred_match->password_value; | |
| 45 password_field.form_control_type = "password"; | |
| 46 | |
| 47 // Fill basic form data. | |
| 48 result->basic_data.origin = form_on_page.origin; | |
| 49 result->basic_data.action = form_on_page.action; | |
| 50 result->basic_data.fields.push_back(username_field); | |
| 51 result->basic_data.fields.push_back(password_field); | |
| 52 result->wait_for_username = wait_for_username_before_autofill; | |
| 53 | |
| 54 // Copy additional username/value pairs. | |
| 55 content::PasswordFormMap::const_iterator iter; | |
| 56 for (iter = matches.begin(); iter != matches.end(); iter++) { | |
| 57 if (iter->second != preferred_match) | |
| 58 result->additional_logins[iter->first] = iter->second->password_value; | |
| 59 if (enable_other_possible_usernames && | |
| 60 !iter->second->other_possible_usernames.empty()) { | |
| 61 // Note that there may be overlap between other_possible_usernames and | |
| 62 // 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 | |
| 64 // want to revisit this in the future. | |
| 65 UsernamesCollectionKey key; | |
| 66 key.username = iter->first; | |
| 67 key.password = iter->second->password_value; | |
| 68 result->other_possible_usernames[key] = | |
| 69 iter->second->other_possible_usernames; | |
| 70 } | |
| 71 } | |
| 72 } | |
| 73 | |
| 74 } // namespace autofill | |
| OLD | NEW |