| 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 <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 // Sorts |list| by origin, like the ORDER BY clause in login_database.cc. | 186 // Sorts |list| by origin, like the ORDER BY clause in login_database.cc. |
| 187 void SortLoginsByOrigin(std::vector<autofill::PasswordForm*>* list) { | 187 void SortLoginsByOrigin(std::vector<autofill::PasswordForm*>* list) { |
| 188 std::sort(list->begin(), list->end(), LoginLessThan()); | 188 std::sort(list->begin(), list->end(), LoginLessThan()); |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // anonymous namespace | 191 } // anonymous namespace |
| 192 | 192 |
| 193 ScopedVector<autofill::PasswordForm> PasswordStoreX::FillMatchingLogins( | 193 ScopedVector<autofill::PasswordForm> PasswordStoreX::FillMatchingLogins( |
| 194 const autofill::PasswordForm& form) { | 194 const FormDigest& form) { |
| 195 CheckMigration(); | 195 CheckMigration(); |
| 196 ScopedVector<autofill::PasswordForm> matched_forms; | 196 ScopedVector<autofill::PasswordForm> matched_forms; |
| 197 if (use_native_backend() && backend_->GetLogins(form, &matched_forms)) { | 197 if (use_native_backend() && backend_->GetLogins(form, &matched_forms)) { |
| 198 SortLoginsByOrigin(&matched_forms.get()); | 198 SortLoginsByOrigin(&matched_forms.get()); |
| 199 // The native backend may succeed and return no data even while locked, if | 199 // The native backend may succeed and return no data even while locked, if |
| 200 // the query did not match anything stored. So we continue to allow fallback | 200 // the query did not match anything stored. So we continue to allow fallback |
| 201 // until we perform a write operation, or until a read returns actual data. | 201 // until we perform a write operation, or until a read returns actual data. |
| 202 if (!matched_forms.empty()) | 202 if (!matched_forms.empty()) |
| 203 allow_fallback_ = false; | 203 allow_fallback_ = false; |
| 204 return matched_forms; | 204 return matched_forms; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // Finally, delete the database file itself. We remove the passwords from | 305 // Finally, delete the database file itself. We remove the passwords from |
| 306 // it before deleting the file just in case there is some problem deleting | 306 // it before deleting the file just in case there is some problem deleting |
| 307 // the file (e.g. directory is not writable, but file is), which would | 307 // the file (e.g. directory is not writable, but file is), which would |
| 308 // otherwise cause passwords to re-migrate next (or maybe every) time. | 308 // otherwise cause passwords to re-migrate next (or maybe every) time. |
| 309 DeleteAndRecreateDatabaseFile(); | 309 DeleteAndRecreateDatabaseFile(); |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 ssize_t result = ok ? forms.size() : -1; | 312 ssize_t result = ok ? forms.size() : -1; |
| 313 return result; | 313 return result; |
| 314 } | 314 } |
| OLD | NEW |