| 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" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/password_manager/password_manager.h" | 14 #include "chrome/browser/password_manager/password_manager.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/webdata/web_data_service.h" | 16 #include "chrome/browser/webdata/web_data_service.h" |
| 17 #include "components/webdata/encryptor/ie7_password.h" | 17 #include "components/webdata/encryptor/ie7_password.h" |
| 18 | 18 |
| 19 using autofill::PasswordForm; |
| 19 using content::BrowserThread; | 20 using content::BrowserThread; |
| 20 using content::PasswordForm; | |
| 21 | 21 |
| 22 // Handles requests to WebDataService. | 22 // Handles requests to WebDataService. |
| 23 class PasswordStoreWin::DBHandler : public WebDataServiceConsumer { | 23 class PasswordStoreWin::DBHandler : public WebDataServiceConsumer { |
| 24 public: | 24 public: |
| 25 DBHandler(WebDataService* web_data_service, | 25 DBHandler(WebDataService* web_data_service, |
| 26 PasswordStoreWin* password_store) | 26 PasswordStoreWin* password_store) |
| 27 : web_data_service_(web_data_service), | 27 : web_data_service_(web_data_service), |
| 28 password_store_(password_store) { | 28 password_store_(password_store) { |
| 29 } | 29 } |
| 30 | 30 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 137 | 137 |
| 138 PendingRequestMap::iterator i = pending_requests_.find(handle); | 138 PendingRequestMap::iterator i = pending_requests_.find(handle); |
| 139 DCHECK(i != pending_requests_.end()); | 139 DCHECK(i != pending_requests_.end()); |
| 140 | 140 |
| 141 scoped_ptr<PasswordForm> form(i->second.form); | 141 scoped_ptr<PasswordForm> form(i->second.form); |
| 142 PasswordStoreWin::ConsumerCallbackRunner callback_runner( | 142 PasswordStoreWin::ConsumerCallbackRunner callback_runner( |
| 143 i->second.callback_runner); | 143 i->second.callback_runner); |
| 144 pending_requests_.erase(i); | 144 pending_requests_.erase(i); |
| 145 | 145 |
| 146 std::vector<content::PasswordForm*> matched_forms; | 146 std::vector<autofill::PasswordForm*> matched_forms; |
| 147 | 147 |
| 148 if (!result) { | 148 if (!result) { |
| 149 // The WDS returns NULL if it is shutting down. Run callback with empty | 149 // The WDS returns NULL if it is shutting down. Run callback with empty |
| 150 // result. | 150 // result. |
| 151 callback_runner.Run(matched_forms); | 151 callback_runner.Run(matched_forms); |
| 152 return; | 152 return; |
| 153 } | 153 } |
| 154 | 154 |
| 155 DCHECK_EQ(PASSWORD_IE7_RESULT, result->GetType()); | 155 DCHECK_EQ(PASSWORD_IE7_RESULT, result->GetType()); |
| 156 PasswordForm* ie7_form = GetIE7Result(result, *form); | 156 PasswordForm* ie7_form = GetIE7Result(result, *form); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 179 void PasswordStoreWin::ShutdownOnUIThread() { | 179 void PasswordStoreWin::ShutdownOnUIThread() { |
| 180 BrowserThread::PostTask( | 180 BrowserThread::PostTask( |
| 181 BrowserThread::DB, FROM_HERE, | 181 BrowserThread::DB, FROM_HERE, |
| 182 base::Bind(&PasswordStoreWin::ShutdownOnDBThread, this)); | 182 base::Bind(&PasswordStoreWin::ShutdownOnDBThread, this)); |
| 183 PasswordStoreDefault::ShutdownOnUIThread(); | 183 PasswordStoreDefault::ShutdownOnUIThread(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void PasswordStoreWin::GetIE7LoginIfNecessary( | 186 void PasswordStoreWin::GetIE7LoginIfNecessary( |
| 187 const PasswordForm& form, | 187 const PasswordForm& form, |
| 188 const ConsumerCallbackRunner& callback_runner, | 188 const ConsumerCallbackRunner& callback_runner, |
| 189 const std::vector<content::PasswordForm*>& matched_forms) { | 189 const std::vector<autofill::PasswordForm*>& matched_forms) { |
| 190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 191 if (matched_forms.empty() && db_handler_.get()) { | 191 if (matched_forms.empty() && db_handler_.get()) { |
| 192 db_handler_->GetIE7Login(form, callback_runner); | 192 db_handler_->GetIE7Login(form, callback_runner); |
| 193 } else { | 193 } else { |
| 194 // No need to get IE7 login. | 194 // No need to get IE7 login. |
| 195 callback_runner.Run(matched_forms); | 195 callback_runner.Run(matched_forms); |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 | 198 |
| 199 void PasswordStoreWin::GetLoginsImpl( | 199 void PasswordStoreWin::GetLoginsImpl( |
| 200 const PasswordForm& form, | 200 const PasswordForm& form, |
| 201 const ConsumerCallbackRunner& callback_runner) { | 201 const ConsumerCallbackRunner& callback_runner) { |
| 202 ConsumerCallbackRunner get_ie7_login = | 202 ConsumerCallbackRunner get_ie7_login = |
| 203 base::Bind(&PasswordStoreWin::GetIE7LoginIfNecessary, | 203 base::Bind(&PasswordStoreWin::GetIE7LoginIfNecessary, |
| 204 this, form, callback_runner); | 204 this, form, callback_runner); |
| 205 PasswordStoreDefault::GetLoginsImpl(form, get_ie7_login); | 205 PasswordStoreDefault::GetLoginsImpl(form, get_ie7_login); |
| 206 } | 206 } |
| OLD | NEW |