| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } else if (migrated == 0) { | 232 } else if (migrated == 0) { |
| 233 // As long as we are able to migrate some passwords, we know the native | 233 // As long as we are able to migrate some passwords, we know the native |
| 234 // store is working. But if there is nothing to migrate, the "migration" | 234 // store is working. But if there is nothing to migrate, the "migration" |
| 235 // can succeed even when the native store would fail. In this case we | 235 // can succeed even when the native store would fail. In this case we |
| 236 // allow a later fallback to the default store. Once any later operation | 236 // allow a later fallback to the default store. Once any later operation |
| 237 // succeeds on the native store, we will no longer allow fallback. | 237 // succeeds on the native store, we will no longer allow fallback. |
| 238 allow_fallback_ = true; | 238 allow_fallback_ = true; |
| 239 } else { | 239 } else { |
| 240 LOG(WARNING) << "Native password store migration failed! " << | 240 LOG(WARNING) << "Native password store migration failed! " << |
| 241 "Falling back on default (unencrypted) store."; | 241 "Falling back on default (unencrypted) store."; |
| 242 backend_.reset(NULL); | 242 backend_.reset(); |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 bool PasswordStoreX::allow_default_store() { | 246 bool PasswordStoreX::allow_default_store() { |
| 247 if (allow_fallback_) { | 247 if (allow_fallback_) { |
| 248 LOG(WARNING) << "Native password store failed! " << | 248 LOG(WARNING) << "Native password store failed! " << |
| 249 "Falling back on default (unencrypted) store."; | 249 "Falling back on default (unencrypted) store."; |
| 250 backend_.reset(NULL); | 250 backend_.reset(); |
| 251 // Don't warn again. We'll use the default store because backend_ is NULL. | 251 // Don't warn again. We'll use the default store because backend_ is NULL. |
| 252 allow_fallback_ = false; | 252 allow_fallback_ = false; |
| 253 } | 253 } |
| 254 return !backend_.get(); | 254 return !backend_.get(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 ssize_t PasswordStoreX::MigrateLogins() { | 257 ssize_t PasswordStoreX::MigrateLogins() { |
| 258 DCHECK(backend_.get()); | 258 DCHECK(backend_.get()); |
| 259 ScopedVector<autofill::PasswordForm> forms; | 259 ScopedVector<autofill::PasswordForm> forms; |
| 260 bool ok = PasswordStoreDefault::FillAutofillableLogins(&forms) && | 260 bool ok = PasswordStoreDefault::FillAutofillableLogins(&forms) && |
| (...skipping 23 matching lines...) Expand all Loading... |
| 284 // Finally, delete the database file itself. We remove the passwords from | 284 // Finally, delete the database file itself. We remove the passwords from |
| 285 // 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 |
| 286 // 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 |
| 287 // otherwise cause passwords to re-migrate next (or maybe every) time. | 287 // otherwise cause passwords to re-migrate next (or maybe every) time. |
| 288 DeleteAndRecreateDatabaseFile(); | 288 DeleteAndRecreateDatabaseFile(); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 ssize_t result = ok ? forms.size() : -1; | 291 ssize_t result = ok ? forms.size() : -1; |
| 292 return result; | 292 return result; |
| 293 } | 293 } |
| OLD | NEW |