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

Unified Diff: components/password_manager/core/browser/form_saver_impl.cc

Issue 2262843002: Make PasswordFormManager::best_matches_ const (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@621355_pass_creds_to_update_by_value
Patch Set: Just rebased Created 4 years, 4 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: components/password_manager/core/browser/form_saver_impl.cc
diff --git a/components/password_manager/core/browser/form_saver_impl.cc b/components/password_manager/core/browser/form_saver_impl.cc
index 970d8f009e6a376390f1ccf797edd6ebbc8b4fe1..c64b7a0fd6073a59589d0ceb8f9edafd9cacc4aa 100644
--- a/components/password_manager/core/browser/form_saver_impl.cc
+++ b/components/password_manager/core/browser/form_saver_impl.cc
@@ -18,7 +18,6 @@
#include "url/origin.h"
using autofill::PasswordForm;
-using autofill::PasswordFormMap;
namespace password_manager {
@@ -37,15 +36,16 @@ void FormSaverImpl::PermanentlyBlacklist(PasswordForm* observed) {
store_->AddLogin(*observed);
}
-void FormSaverImpl::Save(const PasswordForm& pending,
- const autofill::PasswordFormMap& best_matches,
- const PasswordForm* old_primary_key) {
+void FormSaverImpl::Save(
+ const PasswordForm& pending,
+ const std::map<base::string16, const PasswordForm*>& best_matches,
+ const PasswordForm* old_primary_key) {
SaveImpl(pending, true, best_matches, nullptr, old_primary_key);
}
void FormSaverImpl::Update(
const PasswordForm& pending,
- const autofill::PasswordFormMap& best_matches,
+ const std::map<base::string16, const PasswordForm*>& best_matches,
const std::vector<PasswordForm>* credentials_to_update,
const PasswordForm* old_primary_key) {
SaveImpl(pending, false, best_matches, credentials_to_update,
@@ -68,9 +68,10 @@ void FormSaverImpl::RemovePresavedPassword() {
presaved_ = nullptr;
}
-void FormSaverImpl::WipeOutdatedCopies(const PasswordForm& pending,
- PasswordFormMap* best_matches,
- const PasswordForm** preferred_match) {
+void FormSaverImpl::WipeOutdatedCopies(
+ const PasswordForm& pending,
+ std::map<base::string16, const PasswordForm*>* best_matches,
+ const PasswordForm** preferred_match) {
DCHECK(preferred_match); // Note: *preferred_match may still be null.
DCHECK(url::Origin(GURL(pending.signon_realm))
.IsSameOriginWith(
@@ -82,7 +83,7 @@ void FormSaverImpl::WipeOutdatedCopies(const PasswordForm& pending,
if ((pending.password_value != it->second->password_value) &&
gaia::AreEmailsSame(base::UTF16ToUTF8(pending.username_value),
base::UTF16ToUTF8(it->second->username_value))) {
- if (it->second.get() == *preferred_match)
+ if (it->second == *preferred_match)
*preferred_match = nullptr;
store_->RemoveLogin(*it->second);
it = best_matches->erase(it);
@@ -95,14 +96,14 @@ void FormSaverImpl::WipeOutdatedCopies(const PasswordForm& pending,
void FormSaverImpl::SaveImpl(
const PasswordForm& pending,
bool is_new_login,
- const PasswordFormMap& best_matches,
+ const std::map<base::string16, const PasswordForm*>& best_matches,
const std::vector<PasswordForm>* credentials_to_update,
const PasswordForm* old_primary_key) {
DCHECK(pending.preferred);
DCHECK(!pending.blacklisted_by_user);
- base::AutoReset<const autofill::PasswordFormMap*> ar1(&best_matches_,
- &best_matches);
+ base::AutoReset<const std::map<base::string16, const PasswordForm*>*> ar1(
+ &best_matches_, &best_matches);
base::AutoReset<const PasswordForm*> ar2(&pending_, &pending);
UpdatePreferredLoginState();
@@ -130,11 +131,11 @@ void FormSaverImpl::SaveImpl(
void FormSaverImpl::UpdatePreferredLoginState() {
const base::string16& preferred_username = pending_->username_value;
for (const auto& key_value_pair : *best_matches_) {
- const auto& form = key_value_pair.second;
- if (form->preferred && !form->is_public_suffix_match &&
- form->username_value != preferred_username) {
+ const PasswordForm& form = *key_value_pair.second;
+ if (form.preferred && !form.is_public_suffix_match &&
+ form.username_value != preferred_username) {
// This wasn't the selected login but it used to be preferred.
- PasswordForm update(*form);
+ PasswordForm update(form);
update.preferred = false;
store_->UpdateLogin(update);
}
@@ -145,7 +146,7 @@ void FormSaverImpl::DeleteEmptyUsernameCredentials() {
DCHECK(!pending_->username_value.empty());
for (const auto& match : *best_matches_) {
- const PasswordForm* form = match.second.get();
+ const PasswordForm* form = match.second;
if (!form->is_public_suffix_match && form->username_value.empty() &&
form->password_value == pending_->password_value) {
store_->RemoveLogin(*form);

Powered by Google App Engine
This is Rietveld 408576698