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

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: Renaming ie7_password to ie7_password_win 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..d8606db5e36eb901af4d1ad9f9e1aa1bf98c33e5 100644
--- a/chrome/browser/password_manager/password_store_win.cc
+++ b/chrome/browser/password_manager/password_store_win.cc
@@ -14,7 +14,7 @@
#include "chrome/browser/password_manager/password_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/webdata/web_data_service.h"
-#include "components/webdata/encryptor/ie7_password.h"
+#include "components/webdata/encryptor/ie7_password_win.h"
using autofill::PasswordForm;
using content::BrowserThread;
@@ -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);
+ std::vector<autofill::PasswordForm*> GetIE7Results(
+ const WDTypedResult* result,
+ const PasswordForm& form);
// WebDataServiceConsumer implementation.
virtual void OnWebDataServiceRequestDone(
@@ -94,10 +95,11 @@ void PasswordStoreWin::DBHandler::GetIE7Login(
RequestInfo(new PasswordForm(form), callback_runner);
}
-PasswordForm* PasswordStoreWin::DBHandler::GetIE7Result(
+std::vector<PasswordForm*> PasswordStoreWin::DBHandler::GetIE7Results(
const WDTypedResult *result,
const PasswordForm& form) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
+ std::vector<PasswordForm*> matching_forms;
const WDResult<IE7PasswordInfo>* r =
static_cast<const WDResult<IE7PasswordInfo>*>(result);
@@ -108,26 +110,26 @@ 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)) {
+ 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);
+ }
}
-
- 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;
}
- return NULL;
+ return matching_forms;
}
void PasswordStoreWin::DBHandler::OnWebDataServiceRequestDone(
@@ -143,20 +145,16 @@ void PasswordStoreWin::DBHandler::OnWebDataServiceRequestDone(
i->second.callback_runner);
pending_requests_.erase(i);
- std::vector<autofill::PasswordForm*> matched_forms;
-
if (!result) {
// The WDS returns NULL if it is shutting down. Run callback with empty
// result.
- callback_runner.Run(matched_forms);
+ callback_runner.Run(std::vector<autofill::PasswordForm*>());
return;
}
DCHECK_EQ(PASSWORD_IE7_RESULT, result->GetType());
- PasswordForm* ie7_form = GetIE7Result(result, *form);
-
- if (ie7_form)
- matched_forms.push_back(ie7_form);
+ std::vector<autofill::PasswordForm*> matched_forms =
+ GetIE7Results(result, *form);
callback_runner.Run(matched_forms);
}
« no previous file with comments | « chrome/browser/importer/in_process_importer_bridge.cc ('k') | chrome/browser/password_manager/password_store_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698