Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Unified Diff: chrome/browser/password_manager/password_store_x.cc

Issue 906973007: PasswordStore: Clean up expectations about rewriting vectors of forms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Linux compile Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/password_manager/password_store_x.cc
diff --git a/chrome/browser/password_manager/password_store_x.cc b/chrome/browser/password_manager/password_store_x.cc
index 71694ad4a5df47528f17f6d728cfffcdff9b8e93..f490fb354f33debcecb30b8ebd41f8dcb858dff4 100644
--- a/chrome/browser/password_manager/password_store_x.cc
+++ b/chrome/browser/password_manager/password_store_x.cc
@@ -146,13 +146,13 @@ ScopedVector<autofill::PasswordForm> PasswordStoreX::FillMatchingLogins(
// The native backend may succeed and return no data even while locked, if
// the query did not match anything stored. So we continue to allow fallback
// until we perform a write operation, or until a read returns actual data.
- if (matched_forms.size() > 0)
+ if (!matched_forms.empty())
allow_fallback_ = false;
- } else if (allow_default_store()) {
- DCHECK(matched_forms.empty());
- return PasswordStoreDefault::FillMatchingLogins(form, prompt_policy);
+ return matched_forms.Pass();
}
- return matched_forms.Pass();
+ if (allow_default_store())
+ return PasswordStoreDefault::FillMatchingLogins(form, prompt_policy);
+ return ScopedVector<autofill::PasswordForm>();
}
bool PasswordStoreX::FillAutofillableLogins(
@@ -221,8 +221,12 @@ bool PasswordStoreX::allow_default_store() {
ssize_t PasswordStoreX::MigrateLogins() {
DCHECK(backend_.get());
ScopedVector<autofill::PasswordForm> forms;
+ ScopedVector<autofill::PasswordForm> blacklist_forms;
bool ok = PasswordStoreDefault::FillAutofillableLogins(&forms) &&
- PasswordStoreDefault::FillBlacklistLogins(&forms);
+ PasswordStoreDefault::FillBlacklistLogins(&blacklist_forms);
+ forms.reserve(forms.size() + blacklist_forms.size());
+ forms.insert(forms.end(), blacklist_forms.begin(), blacklist_forms.end());
+ blacklist_forms.weak_clear();
if (ok) {
// We add all the passwords (and blacklist entries) to the native backend
// before attempting to remove any from the login database, to make sure we

Powered by Google App Engine
This is Rietveld 408576698