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