| 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_x.h" | 5 #include "chrome/browser/password_manager/password_store_x.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 void PasswordStoreX::GetAutofillableLoginsImpl( | 157 void PasswordStoreX::GetAutofillableLoginsImpl( |
| 158 scoped_ptr<PasswordStore::GetLoginsRequest> request) { | 158 scoped_ptr<PasswordStore::GetLoginsRequest> request) { |
| 159 CheckMigration(); | 159 CheckMigration(); |
| 160 ScopedVector<autofill::PasswordForm> obtained_forms; | 160 ScopedVector<autofill::PasswordForm> obtained_forms; |
| 161 if (use_native_backend() && | 161 if (use_native_backend() && |
| 162 backend_->GetAutofillableLogins(&obtained_forms)) { | 162 backend_->GetAutofillableLogins(&obtained_forms)) { |
| 163 SortLoginsByOrigin(&obtained_forms.get()); | 163 SortLoginsByOrigin(&obtained_forms.get()); |
| 164 // See GetLoginsImpl() for why we disallow fallback conditionally here. | 164 // See GetLoginsImpl() for why we disallow fallback conditionally here. |
| 165 if (!obtained_forms.empty()) | 165 if (!obtained_forms.empty()) |
| 166 allow_fallback_ = false; | 166 allow_fallback_ = false; |
| 167 request->result()->swap(obtained_forms); | 167 request->NotifyConsumerWithResults(obtained_forms.Pass()); |
| 168 return; |
| 168 } else if (allow_default_store()) { | 169 } else if (allow_default_store()) { |
| 169 PasswordStoreDefault::GetAutofillableLoginsImpl(request.Pass()); | 170 PasswordStoreDefault::GetAutofillableLoginsImpl(request.Pass()); |
| 170 return; | 171 return; |
| 171 } | 172 } |
| 172 // The consumer will be left hanging unless we reply. | 173 // The consumer will be left hanging unless we reply. |
| 173 ForwardLoginsResult(request.Pass()); | 174 request->NotifyConsumerWithResults(ScopedVector<autofill::PasswordForm>()); |
| 174 } | 175 } |
| 175 | 176 |
| 176 void PasswordStoreX::GetBlacklistLoginsImpl( | 177 void PasswordStoreX::GetBlacklistLoginsImpl( |
| 177 scoped_ptr<PasswordStore::GetLoginsRequest> request) { | 178 scoped_ptr<PasswordStore::GetLoginsRequest> request) { |
| 178 CheckMigration(); | 179 CheckMigration(); |
| 179 ScopedVector<autofill::PasswordForm> obtained_forms; | 180 ScopedVector<autofill::PasswordForm> obtained_forms; |
| 180 if (use_native_backend() && backend_->GetBlacklistLogins(&obtained_forms)) { | 181 if (use_native_backend() && backend_->GetBlacklistLogins(&obtained_forms)) { |
| 181 SortLoginsByOrigin(&obtained_forms.get()); | 182 SortLoginsByOrigin(&obtained_forms.get()); |
| 182 // See GetLoginsImpl() for why we disallow fallback conditionally here. | 183 // See GetLoginsImpl() for why we disallow fallback conditionally here. |
| 183 if (!obtained_forms.empty()) | 184 if (!obtained_forms.empty()) |
| 184 allow_fallback_ = false; | 185 allow_fallback_ = false; |
| 185 request->result()->swap(obtained_forms); | 186 request->NotifyConsumerWithResults(obtained_forms.Pass()); |
| 187 return; |
| 186 } else if (allow_default_store()) { | 188 } else if (allow_default_store()) { |
| 187 PasswordStoreDefault::GetBlacklistLoginsImpl(request.Pass()); | 189 PasswordStoreDefault::GetBlacklistLoginsImpl(request.Pass()); |
| 188 return; | 190 return; |
| 189 } | 191 } |
| 190 // The consumer will be left hanging unless we reply. | 192 // The consumer will be left hanging unless we reply. |
| 191 ForwardLoginsResult(request.Pass()); | 193 request->NotifyConsumerWithResults(ScopedVector<autofill::PasswordForm>()); |
| 192 } | 194 } |
| 193 | 195 |
| 194 bool PasswordStoreX::FillAutofillableLogins( | 196 bool PasswordStoreX::FillAutofillableLogins( |
| 195 ScopedVector<autofill::PasswordForm>* forms) { | 197 ScopedVector<autofill::PasswordForm>* forms) { |
| 196 CheckMigration(); | 198 CheckMigration(); |
| 197 if (use_native_backend() && backend_->GetAutofillableLogins(forms)) { | 199 if (use_native_backend() && backend_->GetAutofillableLogins(forms)) { |
| 198 // See GetLoginsImpl() for why we disallow fallback conditionally here. | 200 // See GetLoginsImpl() for why we disallow fallback conditionally here. |
| 199 if (forms->size() > 0) | 201 if (forms->size() > 0) |
| 200 allow_fallback_ = false; | 202 allow_fallback_ = false; |
| 201 return true; | 203 return true; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // Finally, delete the database file itself. We remove the passwords from | 284 // Finally, delete the database file itself. We remove the passwords from |
| 283 // it before deleting the file just in case there is some problem deleting | 285 // it before deleting the file just in case there is some problem deleting |
| 284 // the file (e.g. directory is not writable, but file is), which would | 286 // the file (e.g. directory is not writable, but file is), which would |
| 285 // otherwise cause passwords to re-migrate next (or maybe every) time. | 287 // otherwise cause passwords to re-migrate next (or maybe every) time. |
| 286 DeleteAndRecreateDatabaseFile(); | 288 DeleteAndRecreateDatabaseFile(); |
| 287 } | 289 } |
| 288 } | 290 } |
| 289 ssize_t result = ok ? forms.size() : -1; | 291 ssize_t result = ok ? forms.size() : -1; |
| 290 return result; | 292 return result; |
| 291 } | 293 } |
| OLD | NEW |