Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: components/autofill/core/common/password_form_fill_data.cc

Issue 614023002: [Password manager] Relplace the FormFieldData vector from autofill::FormData with named fields… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated nit from Vaclav's review. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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()
26 : user_submitted(false), wait_for_username(false) {
26 } 27 }
27 28
28 PasswordFormFillData::~PasswordFormFillData() { 29 PasswordFormFillData::~PasswordFormFillData() {
29 } 30 }
30 31
31 void InitPasswordFormFillData( 32 void InitPasswordFormFillData(
32 const PasswordForm& form_on_page, 33 const PasswordForm& form_on_page,
33 const PasswordFormMap& matches, 34 const PasswordFormMap& matches,
34 const PasswordForm* const preferred_match, 35 const PasswordForm* const preferred_match,
35 bool wait_for_username_before_autofill, 36 bool wait_for_username_before_autofill,
36 bool enable_other_possible_usernames, 37 bool enable_other_possible_usernames,
37 PasswordFormFillData* result) { 38 PasswordFormFillData* result) {
38 // Note that many of the |FormFieldData| members are not initialized for 39 // Note that many of the |FormFieldData| members are not initialized for
39 // |username_field| and |password_field| because they are currently not used 40 // |username_field| and |password_field| because they are currently not used
40 // by the password autocomplete code. 41 // by the password autocomplete code.
41 FormFieldData username_field; 42 FormFieldData username_field;
42 username_field.name = form_on_page.username_element; 43 username_field.name = form_on_page.username_element;
43 username_field.value = preferred_match->username_value; 44 username_field.value = preferred_match->username_value;
44 FormFieldData password_field; 45 FormFieldData password_field;
45 password_field.name = form_on_page.password_element; 46 password_field.name = form_on_page.password_element;
46 password_field.value = preferred_match->password_value; 47 password_field.value = preferred_match->password_value;
47 password_field.form_control_type = "password"; 48 password_field.form_control_type = "password";
48 49
49 // Fill basic form data. 50 // Fill basic form data.
50 result->basic_data.name = form_on_page.form_data.name; 51 result->name = form_on_page.form_data.name;
51 result->basic_data.origin = form_on_page.origin; 52 result->origin = form_on_page.origin;
52 result->basic_data.action = form_on_page.action; 53 result->action = form_on_page.action;
53 result->basic_data.fields.push_back(username_field); 54 result->user_submitted = form_on_page.form_data.user_submitted;
54 result->basic_data.fields.push_back(password_field); 55 result->username_field = username_field;
56 result->password_field = password_field;
55 result->wait_for_username = wait_for_username_before_autofill; 57 result->wait_for_username = wait_for_username_before_autofill;
56 58
57 result->preferred_realm = preferred_match->original_signon_realm; 59 result->preferred_realm = preferred_match->original_signon_realm;
58 60
59 // Copy additional username/value pairs. 61 // Copy additional username/value pairs.
60 PasswordFormMap::const_iterator iter; 62 PasswordFormMap::const_iterator iter;
61 for (iter = matches.begin(); iter != matches.end(); iter++) { 63 for (iter = matches.begin(); iter != matches.end(); iter++) {
62 if (iter->second != preferred_match) { 64 if (iter->second != preferred_match) {
63 PasswordAndRealm value; 65 PasswordAndRealm value;
64 value.password = iter->second->password_value; 66 value.password = iter->second->password_value;
(...skipping 10 matching lines...) Expand all
75 key.username = iter->first; 77 key.username = iter->first;
76 key.password = iter->second->password_value; 78 key.password = iter->second->password_value;
77 key.realm = iter->second->original_signon_realm; 79 key.realm = iter->second->original_signon_realm;
78 result->other_possible_usernames[key] = 80 result->other_possible_usernames[key] =
79 iter->second->other_possible_usernames; 81 iter->second->other_possible_usernames;
80 } 82 }
81 } 83 }
82 } 84 }
83 85
84 } // namespace autofill 86 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698