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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 }; | 171 }; |
172 | 172 |
173 // Sorts |list| by origin, like the ORDER BY clause in login_database.cc. | 173 // Sorts |list| by origin, like the ORDER BY clause in login_database.cc. |
174 void SortLoginsByOrigin(std::vector<autofill::PasswordForm*>* list) { | 174 void SortLoginsByOrigin(std::vector<autofill::PasswordForm*>* list) { |
175 std::sort(list->begin(), list->end(), LoginLessThan()); | 175 std::sort(list->begin(), list->end(), LoginLessThan()); |
176 } | 176 } |
177 | 177 |
178 } // anonymous namespace | 178 } // anonymous namespace |
179 | 179 |
180 ScopedVector<autofill::PasswordForm> PasswordStoreX::FillMatchingLogins( | 180 ScopedVector<autofill::PasswordForm> PasswordStoreX::FillMatchingLogins( |
181 const autofill::PasswordForm& form, | 181 const autofill::PasswordForm& form) { |
182 AuthorizationPromptPolicy prompt_policy) { | |
183 CheckMigration(); | 182 CheckMigration(); |
184 ScopedVector<autofill::PasswordForm> matched_forms; | 183 ScopedVector<autofill::PasswordForm> matched_forms; |
185 if (use_native_backend() && backend_->GetLogins(form, &matched_forms)) { | 184 if (use_native_backend() && backend_->GetLogins(form, &matched_forms)) { |
186 SortLoginsByOrigin(&matched_forms.get()); | 185 SortLoginsByOrigin(&matched_forms.get()); |
187 // The native backend may succeed and return no data even while locked, if | 186 // The native backend may succeed and return no data even while locked, if |
188 // the query did not match anything stored. So we continue to allow fallback | 187 // the query did not match anything stored. So we continue to allow fallback |
189 // until we perform a write operation, or until a read returns actual data. | 188 // until we perform a write operation, or until a read returns actual data. |
190 if (!matched_forms.empty()) | 189 if (!matched_forms.empty()) |
191 allow_fallback_ = false; | 190 allow_fallback_ = false; |
192 return matched_forms; | 191 return matched_forms; |
193 } | 192 } |
194 if (allow_default_store()) | 193 if (allow_default_store()) |
195 return PasswordStoreDefault::FillMatchingLogins(form, prompt_policy); | 194 return PasswordStoreDefault::FillMatchingLogins(form); |
196 return ScopedVector<autofill::PasswordForm>(); | 195 return ScopedVector<autofill::PasswordForm>(); |
197 } | 196 } |
198 | 197 |
199 bool PasswordStoreX::FillAutofillableLogins( | 198 bool PasswordStoreX::FillAutofillableLogins( |
200 ScopedVector<autofill::PasswordForm>* forms) { | 199 ScopedVector<autofill::PasswordForm>* forms) { |
201 CheckMigration(); | 200 CheckMigration(); |
202 if (use_native_backend() && backend_->GetAutofillableLogins(forms)) { | 201 if (use_native_backend() && backend_->GetAutofillableLogins(forms)) { |
203 SortLoginsByOrigin(&forms->get()); | 202 SortLoginsByOrigin(&forms->get()); |
204 // See GetLoginsImpl() for why we disallow fallback conditionally here. | 203 // See GetLoginsImpl() for why we disallow fallback conditionally here. |
205 if (!forms->empty()) | 204 if (!forms->empty()) |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 // Finally, delete the database file itself. We remove the passwords from | 292 // Finally, delete the database file itself. We remove the passwords from |
294 // it before deleting the file just in case there is some problem deleting | 293 // it before deleting the file just in case there is some problem deleting |
295 // the file (e.g. directory is not writable, but file is), which would | 294 // the file (e.g. directory is not writable, but file is), which would |
296 // otherwise cause passwords to re-migrate next (or maybe every) time. | 295 // otherwise cause passwords to re-migrate next (or maybe every) time. |
297 DeleteAndRecreateDatabaseFile(); | 296 DeleteAndRecreateDatabaseFile(); |
298 } | 297 } |
299 } | 298 } |
300 ssize_t result = ok ? forms.size() : -1; | 299 ssize_t result = ok ? forms.size() : -1; |
301 return result; | 300 return result; |
302 } | 301 } |
OLD | NEW |