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

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

Issue 15660018: [autofill] Add support for PSL domain matching for password autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated regexp, sanitized result, escaped form domain and added comments. Created 7 years, 6 months 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 | Annotate | Revision Log
OLDNEW
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
10 namespace autofill { 11 namespace autofill {
11 12
12 UsernamesCollectionKey::UsernamesCollectionKey() {} 13 UsernamesCollectionKey::UsernamesCollectionKey() {}
13 14
14 UsernamesCollectionKey::~UsernamesCollectionKey() {} 15 UsernamesCollectionKey::~UsernamesCollectionKey() {}
15 16
16 bool UsernamesCollectionKey::operator<( 17 bool UsernamesCollectionKey::operator<(
17 const UsernamesCollectionKey& other) const { 18 const UsernamesCollectionKey& other) const {
(...skipping 25 matching lines...) Expand all
43 password_field.name = form_on_page.password_element; 44 password_field.name = form_on_page.password_element;
44 password_field.value = preferred_match->password_value; 45 password_field.value = preferred_match->password_value;
45 46
46 // Fill basic form data. 47 // Fill basic form data.
47 result->basic_data.origin = form_on_page.origin; 48 result->basic_data.origin = form_on_page.origin;
48 result->basic_data.action = form_on_page.action; 49 result->basic_data.action = form_on_page.action;
49 result->basic_data.fields.push_back(username_field); 50 result->basic_data.fields.push_back(username_field);
50 result->basic_data.fields.push_back(password_field); 51 result->basic_data.fields.push_back(password_field);
51 result->wait_for_username = wait_for_username_before_autofill; 52 result->wait_for_username = wait_for_username_before_autofill;
52 53
54 if (preferred_match->is_psl_origin_match) {
55 result->preferred_realm =
56 ASCIIToUTF16(preferred_match->original_signon_realm);
57 } else {
58 result->preferred_realm = ASCIIToUTF16(preferred_match->signon_realm);
59 }
60
53 // Copy additional username/value pairs. 61 // Copy additional username/value pairs.
54 content::PasswordFormMap::const_iterator iter; 62 content::PasswordFormMap::const_iterator iter;
55 for (iter = matches.begin(); iter != matches.end(); iter++) { 63 for (iter = matches.begin(); iter != matches.end(); iter++) {
56 if (iter->second != preferred_match) 64 if (iter->second != preferred_match) {
57 result->additional_logins[iter->first] = iter->second->password_value; 65 result->additional_logins_passwords[iter->first] =
66 iter->second->password_value;
67 if (iter->second->is_psl_origin_match) {
68 result->additional_logins_realms[iter->first] =
69 ASCIIToUTF16(iter->second->original_signon_realm);
70 } else {
71 result->additional_logins_realms[iter->first] =
72 ASCIIToUTF16(iter->second->signon_realm);
73 }
74 }
58 if (enable_other_possible_usernames && 75 if (enable_other_possible_usernames &&
59 !iter->second->other_possible_usernames.empty()) { 76 !iter->second->other_possible_usernames.empty()) {
60 // Note that there may be overlap between other_possible_usernames and 77 // Note that there may be overlap between other_possible_usernames and
61 // other saved usernames or with other other_possible_usernames. For now 78 // other saved usernames or with other other_possible_usernames. For now
62 // we will ignore this overlap as it should be a rare occurence. We may 79 // we will ignore this overlap as it should be a rare occurence. We may
63 // want to revisit this in the future. 80 // want to revisit this in the future.
64 UsernamesCollectionKey key; 81 UsernamesCollectionKey key;
65 key.username = iter->first; 82 key.username = iter->first;
66 key.password = iter->second->password_value; 83 key.password = iter->second->password_value;
67 result->other_possible_usernames[key] = 84 result->other_possible_usernames[key] =
68 iter->second->other_possible_usernames; 85 iter->second->other_possible_usernames;
69 } 86 }
70 } 87 }
71 } 88 }
72 89
73 } // namespace autofill 90 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698