| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/password_manager/password_store_win.h" | 5 #include "chrome/browser/password_manager/password_store_win.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 web_data_service_->CancelRequest(i->first); | 81 web_data_service_->CancelRequest(i->first); |
| 82 delete i->second.form; | 82 delete i->second.form; |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 void PasswordStoreWin::DBHandler::GetIE7Login( | 86 void PasswordStoreWin::DBHandler::GetIE7Login( |
| 87 const PasswordForm& form, | 87 const PasswordForm& form, |
| 88 const PasswordStoreWin::ConsumerCallbackRunner& callback_runner) { | 88 const PasswordStoreWin::ConsumerCallbackRunner& callback_runner) { |
| 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 90 IE7PasswordInfo info; | 90 IE7PasswordInfo info; |
| 91 info.url_hash = | 91 info.url_hash = ie7_password::GetUrlHash(UTF8ToWide(form.origin.spec())); |
| 92 ie7_password::GetUrlHash(base::UTF8ToWide(form.origin.spec())); | |
| 93 WebDataService::Handle handle = web_data_service_->GetIE7Login(info, this); | 92 WebDataService::Handle handle = web_data_service_->GetIE7Login(info, this); |
| 94 pending_requests_[handle] = | 93 pending_requests_[handle] = |
| 95 RequestInfo(new PasswordForm(form), callback_runner); | 94 RequestInfo(new PasswordForm(form), callback_runner); |
| 96 } | 95 } |
| 97 | 96 |
| 98 PasswordForm* PasswordStoreWin::DBHandler::GetIE7Result( | 97 PasswordForm* PasswordStoreWin::DBHandler::GetIE7Result( |
| 99 const WDTypedResult *result, | 98 const WDTypedResult *result, |
| 100 const PasswordForm& form) { | 99 const PasswordForm& form) { |
| 101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 102 | 101 |
| 103 const WDResult<IE7PasswordInfo>* r = | 102 const WDResult<IE7PasswordInfo>* r = |
| 104 static_cast<const WDResult<IE7PasswordInfo>*>(result); | 103 static_cast<const WDResult<IE7PasswordInfo>*>(result); |
| 105 IE7PasswordInfo info = r->GetValue(); | 104 IE7PasswordInfo info = r->GetValue(); |
| 106 | 105 |
| 107 if (!info.encrypted_data.empty()) { | 106 if (!info.encrypted_data.empty()) { |
| 108 // We got a result. | 107 // We got a result. |
| 109 // Delete the entry. If it's good we will add it to the real saved password | 108 // Delete the entry. If it's good we will add it to the real saved password |
| 110 // table. | 109 // table. |
| 111 web_data_service_->RemoveIE7Login(info); | 110 web_data_service_->RemoveIE7Login(info); |
| 112 std::wstring username; | 111 std::wstring username; |
| 113 std::wstring password; | 112 std::wstring password; |
| 114 std::wstring url = base::ASCIIToWide(form.origin.spec()); | 113 std::wstring url = ASCIIToWide(form.origin.spec()); |
| 115 if (!ie7_password::DecryptPassword(url, info.encrypted_data, | 114 if (!ie7_password::DecryptPassword(url, info.encrypted_data, |
| 116 &username, &password)) { | 115 &username, &password)) { |
| 117 return NULL; | 116 return NULL; |
| 118 } | 117 } |
| 119 | 118 |
| 120 PasswordForm* autofill = new PasswordForm(form); | 119 PasswordForm* autofill = new PasswordForm(form); |
| 121 autofill->username_value = username; | 120 autofill->username_value = username; |
| 122 autofill->password_value = password; | 121 autofill->password_value = password; |
| 123 autofill->preferred = true; | 122 autofill->preferred = true; |
| 124 autofill->ssl_valid = form.origin.SchemeIsSecure(); | 123 autofill->ssl_valid = form.origin.SchemeIsSecure(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 197 } |
| 199 | 198 |
| 200 void PasswordStoreWin::GetLoginsImpl( | 199 void PasswordStoreWin::GetLoginsImpl( |
| 201 const PasswordForm& form, | 200 const PasswordForm& form, |
| 202 const ConsumerCallbackRunner& callback_runner) { | 201 const ConsumerCallbackRunner& callback_runner) { |
| 203 ConsumerCallbackRunner get_ie7_login = | 202 ConsumerCallbackRunner get_ie7_login = |
| 204 base::Bind(&PasswordStoreWin::GetIE7LoginIfNecessary, | 203 base::Bind(&PasswordStoreWin::GetIE7LoginIfNecessary, |
| 205 this, form, callback_runner); | 204 this, form, callback_runner); |
| 206 PasswordStoreDefault::GetLoginsImpl(form, get_ie7_login); | 205 PasswordStoreDefault::GetLoginsImpl(form, get_ie7_login); |
| 207 } | 206 } |
| OLD | NEW |