| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 }; | 112 }; |
| 113 } // anonymous namespace | 113 } // anonymous namespace |
| 114 | 114 |
| 115 void PasswordStoreX::SortLoginsByOrigin(NativeBackend::PasswordFormList* list) { | 115 void PasswordStoreX::SortLoginsByOrigin(NativeBackend::PasswordFormList* list) { |
| 116 // In login_database.cc, the query has ORDER BY origin_url. Simulate that. | 116 // In login_database.cc, the query has ORDER BY origin_url. Simulate that. |
| 117 std::sort(list->begin(), list->end(), LoginLessThan()); | 117 std::sort(list->begin(), list->end(), LoginLessThan()); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void PasswordStoreX::GetLoginsImpl( | 120 void PasswordStoreX::GetLoginsImpl( |
| 121 const autofill::PasswordForm& form, | 121 const autofill::PasswordForm& form, |
| 122 AuthorizationPromptPolicy prompt_policy, |
| 122 const ConsumerCallbackRunner& callback_runner) { | 123 const ConsumerCallbackRunner& callback_runner) { |
| 123 CheckMigration(); | 124 CheckMigration(); |
| 124 std::vector<autofill::PasswordForm*> matched_forms; | 125 std::vector<autofill::PasswordForm*> matched_forms; |
| 125 if (use_native_backend() && backend_->GetLogins(form, &matched_forms)) { | 126 if (use_native_backend() && backend_->GetLogins(form, &matched_forms)) { |
| 126 SortLoginsByOrigin(&matched_forms); | 127 SortLoginsByOrigin(&matched_forms); |
| 127 callback_runner.Run(matched_forms); | 128 callback_runner.Run(matched_forms); |
| 128 // The native backend may succeed and return no data even while locked, if | 129 // The native backend may succeed and return no data even while locked, if |
| 129 // the query did not match anything stored. So we continue to allow fallback | 130 // the query did not match anything stored. So we continue to allow fallback |
| 130 // until we perform a write operation, or until a read returns actual data. | 131 // until we perform a write operation, or until a read returns actual data. |
| 131 if (matched_forms.size() > 0) | 132 if (matched_forms.size() > 0) |
| 132 allow_fallback_ = false; | 133 allow_fallback_ = false; |
| 133 } else if (allow_default_store()) { | 134 } else if (allow_default_store()) { |
| 134 DCHECK(matched_forms.empty()); | 135 DCHECK(matched_forms.empty()); |
| 135 PasswordStoreDefault::GetLoginsImpl(form, callback_runner); | 136 PasswordStoreDefault::GetLoginsImpl(form, prompt_policy, callback_runner); |
| 136 } else { | 137 } else { |
| 137 // The consumer will be left hanging unless we reply. | 138 // The consumer will be left hanging unless we reply. |
| 138 callback_runner.Run(matched_forms); | 139 callback_runner.Run(matched_forms); |
| 139 } | 140 } |
| 140 } | 141 } |
| 141 | 142 |
| 142 void PasswordStoreX::GetAutofillableLoginsImpl(GetLoginsRequest* request) { | 143 void PasswordStoreX::GetAutofillableLoginsImpl(GetLoginsRequest* request) { |
| 143 CheckMigration(); | 144 CheckMigration(); |
| 144 if (use_native_backend() && | 145 if (use_native_backend() && |
| 145 backend_->GetAutofillableLogins(&request->value)) { | 146 backend_->GetAutofillableLogins(&request->value)) { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } // anonymous namespace | 302 } // anonymous namespace |
| 302 | 303 |
| 303 // static | 304 // static |
| 304 void PasswordStoreX::SetPasswordsUseLocalProfileId(PrefService* prefs) { | 305 void PasswordStoreX::SetPasswordsUseLocalProfileId(PrefService* prefs) { |
| 305 // This method should work on any thread, but we expect the DB thread. | 306 // This method should work on any thread, but we expect the DB thread. |
| 306 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 307 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 308 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 308 base::Bind(&UISetPasswordsUseLocalProfileId, prefs)); | 309 base::Bind(&UISetPasswordsUseLocalProfileId, prefs)); |
| 309 } | 310 } |
| 310 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) | 311 #endif // !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX) |
| OLD | NEW |