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

Unified 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: Addressed comments from isherman 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/common/password_form_fill_data.cc
diff --git a/components/autofill/common/password_form_fill_data.cc b/components/autofill/common/password_form_fill_data.cc
index 99e089e5708990ae0e3777d42ad6f23ff5d46b9c..95154bcd684217fb06a92d457b3d3da1ca046b53 100644
--- a/components/autofill/common/password_form_fill_data.cc
+++ b/components/autofill/common/password_form_fill_data.cc
@@ -5,8 +5,19 @@
#include "components/autofill/common/password_form_fill_data.h"
#include "base/logging.h"
+#include "base/utf_string_conversions.h"
#include "components/autofill/common/form_field_data.h"
+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.
+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.
+ if (form->IsPublicSuffixMatch())
+ return form->original_signon_realm;
+ else
+ return form->signon_realm;
+}
+
+} // namespace
+
namespace autofill {
UsernamesCollectionKey::UsernamesCollectionKey() {}
@@ -51,11 +62,17 @@ void InitPasswordFormFillData(
result->basic_data.fields.push_back(password_field);
result->wait_for_username = wait_for_username_before_autofill;
+ result->preferred_realm = GetPreferredSignonRealm(preferred_match);
+
// Copy additional username/value pairs.
content::PasswordFormMap::const_iterator iter;
for (iter = matches.begin(); iter != matches.end(); iter++) {
- if (iter->second != preferred_match)
- result->additional_logins[iter->first] = iter->second->password_value;
+ if (iter->second != preferred_match) {
+ PasswordAndRealm value;
+ value.password = iter->second->password_value;
+ value.realm = GetPreferredSignonRealm(iter->second);
+ result->additional_logins[iter->first] = value;
+ }
if (enable_other_possible_usernames &&
!iter->second->other_possible_usernames.empty()) {
// Note that there may be overlap between other_possible_usernames and

Powered by Google App Engine
This is Rietveld 408576698