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

Unified Diff: chrome/browser/password_manager/password_store_win.cc

Issue 26465006: Fix IE password import (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 2 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: chrome/browser/password_manager/password_store_win.cc
diff --git a/chrome/browser/password_manager/password_store_win.cc b/chrome/browser/password_manager/password_store_win.cc
index cc02c6ee382cce8b5dfd14245b1238b9370b92a4..315b4d63bd57a454cb62f406274ec2882a2a748c 100644
--- a/chrome/browser/password_manager/password_store_win.cc
+++ b/chrome/browser/password_manager/password_store_win.cc
@@ -54,8 +54,9 @@ class PasswordStoreWin::DBHandler : public WebDataServiceConsumer {
// Gets logins from IE7 if no others are found. Also copies them into
// Chrome's WebDatabase so we don't need to look next time.
- PasswordForm* GetIE7Result(const WDTypedResult* result,
- const PasswordForm& form);
+ void GetIE7Results(const WDTypedResult* result,
+ const PasswordForm& form,
+ std::vector<autofill::PasswordForm*>* matching_forms);
// WebDataServiceConsumer implementation.
virtual void OnWebDataServiceRequestDone(
@@ -94,9 +95,10 @@ void PasswordStoreWin::DBHandler::GetIE7Login(
RequestInfo(new PasswordForm(form), callback_runner);
}
-PasswordForm* PasswordStoreWin::DBHandler::GetIE7Result(
+void PasswordStoreWin::DBHandler::GetIE7Results(
Lei Zhang 2013/10/08 17:49:46 Just return a std::vector<PasswordForm*>, but writ
const WDTypedResult *result,
- const PasswordForm& form) {
+ const PasswordForm& form,
+ std::vector<PasswordForm*>* matching_forms) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
const WDResult<IE7PasswordInfo>* r =
@@ -108,26 +110,27 @@ PasswordForm* PasswordStoreWin::DBHandler::GetIE7Result(
// Delete the entry. If it's good we will add it to the real saved password
// table.
web_data_service_->RemoveIE7Login(info);
- std::wstring username;
- std::wstring password;
+ std::vector<ie7_password::DecryptedCredentials> credentials;
std::wstring url = ASCIIToWide(form.origin.spec());
- if (!ie7_password::DecryptPassword(url, info.encrypted_data,
- &username, &password)) {
- return NULL;
+ if (!ie7_password::DecryptPasswords(url,
+ info.encrypted_data,
+ &credentials)) {
+ return;
}
- PasswordForm* autofill = new PasswordForm(form);
- autofill->username_value = username;
- autofill->password_value = password;
- autofill->preferred = true;
- autofill->ssl_valid = form.origin.SchemeIsSecure();
- autofill->date_created = info.date_created;
- // Add this PasswordForm to the saved password table. We're on the DB thread
- // already, so we use AddLoginImpl.
- password_store_->AddLoginImpl(*autofill);
- return autofill;
+ for (size_t i = 0; i < credentials.size(); ++i) {
+ PasswordForm* autofill = new PasswordForm(form);
+ autofill->username_value = credentials[i].username;
+ autofill->password_value = credentials[i].password;
+ autofill->preferred = true;
+ autofill->ssl_valid = form.origin.SchemeIsSecure();
+ autofill->date_created = info.date_created;
+ matching_forms->push_back(autofill);
+ // Add this PasswordForm to the saved password table. We're on the DB
+ // thread already, so we use AddLoginImpl.
+ password_store_->AddLoginImpl(*autofill);
+ }
}
- return NULL;
}
void PasswordStoreWin::DBHandler::OnWebDataServiceRequestDone(
@@ -153,10 +156,7 @@ void PasswordStoreWin::DBHandler::OnWebDataServiceRequestDone(
}
DCHECK_EQ(PASSWORD_IE7_RESULT, result->GetType());
- PasswordForm* ie7_form = GetIE7Result(result, *form);
-
- if (ie7_form)
- matched_forms.push_back(ie7_form);
+ GetIE7Results(result, *form, &matched_forms);
callback_runner.Run(matched_forms);
}
« no previous file with comments | « no previous file | components/webdata/encryptor/ie7_password.h » ('j') | components/webdata/encryptor/ie7_password.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698