| 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 = ie7_password::GetUrlHash(UTF8ToWide(form.origin.spec())); | 91 info.url_hash = |
| 92 ie7_password::GetUrlHash(base::UTF8ToWide(form.origin.spec())); |
| 92 WebDataService::Handle handle = web_data_service_->GetIE7Login(info, this); | 93 WebDataService::Handle handle = web_data_service_->GetIE7Login(info, this); |
| 93 pending_requests_[handle] = | 94 pending_requests_[handle] = |
| 94 RequestInfo(new PasswordForm(form), callback_runner); | 95 RequestInfo(new PasswordForm(form), callback_runner); |
| 95 } | 96 } |
| 96 | 97 |
| 97 PasswordForm* PasswordStoreWin::DBHandler::GetIE7Result( | 98 PasswordForm* PasswordStoreWin::DBHandler::GetIE7Result( |
| 98 const WDTypedResult *result, | 99 const WDTypedResult *result, |
| 99 const PasswordForm& form) { | 100 const PasswordForm& form) { |
| 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 101 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 101 | 102 |
| 102 const WDResult<IE7PasswordInfo>* r = | 103 const WDResult<IE7PasswordInfo>* r = |
| 103 static_cast<const WDResult<IE7PasswordInfo>*>(result); | 104 static_cast<const WDResult<IE7PasswordInfo>*>(result); |
| 104 IE7PasswordInfo info = r->GetValue(); | 105 IE7PasswordInfo info = r->GetValue(); |
| 105 | 106 |
| 106 if (!info.encrypted_data.empty()) { | 107 if (!info.encrypted_data.empty()) { |
| 107 // We got a result. | 108 // We got a result. |
| 108 // Delete the entry. If it's good we will add it to the real saved password | 109 // Delete the entry. If it's good we will add it to the real saved password |
| 109 // table. | 110 // table. |
| 110 web_data_service_->RemoveIE7Login(info); | 111 web_data_service_->RemoveIE7Login(info); |
| 111 std::wstring username; | 112 std::wstring username; |
| 112 std::wstring password; | 113 std::wstring password; |
| 113 std::wstring url = ASCIIToWide(form.origin.spec()); | 114 std::wstring url = base::ASCIIToWide(form.origin.spec()); |
| 114 if (!ie7_password::DecryptPassword(url, info.encrypted_data, | 115 if (!ie7_password::DecryptPassword(url, info.encrypted_data, |
| 115 &username, &password)) { | 116 &username, &password)) { |
| 116 return NULL; | 117 return NULL; |
| 117 } | 118 } |
| 118 | 119 |
| 119 PasswordForm* autofill = new PasswordForm(form); | 120 PasswordForm* autofill = new PasswordForm(form); |
| 120 autofill->username_value = username; | 121 autofill->username_value = username; |
| 121 autofill->password_value = password; | 122 autofill->password_value = password; |
| 122 autofill->preferred = true; | 123 autofill->preferred = true; |
| 123 autofill->ssl_valid = form.origin.SchemeIsSecure(); | 124 autofill->ssl_valid = form.origin.SchemeIsSecure(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 198 } |
| 198 | 199 |
| 199 void PasswordStoreWin::GetLoginsImpl( | 200 void PasswordStoreWin::GetLoginsImpl( |
| 200 const PasswordForm& form, | 201 const PasswordForm& form, |
| 201 const ConsumerCallbackRunner& callback_runner) { | 202 const ConsumerCallbackRunner& callback_runner) { |
| 202 ConsumerCallbackRunner get_ie7_login = | 203 ConsumerCallbackRunner get_ie7_login = |
| 203 base::Bind(&PasswordStoreWin::GetIE7LoginIfNecessary, | 204 base::Bind(&PasswordStoreWin::GetIE7LoginIfNecessary, |
| 204 this, form, callback_runner); | 205 this, form, callback_runner); |
| 205 PasswordStoreDefault::GetLoginsImpl(form, get_ie7_login); | 206 PasswordStoreDefault::GetLoginsImpl(form, get_ie7_login); |
| 206 } | 207 } |
| OLD | NEW |