diff options
-rw-r--r-- | chrome/browser/password_manager/password_store_mac.cc | 17 | ||||
-rw-r--r-- | chrome/browser/password_manager/password_store_mac.h | 5 |
2 files changed, 18 insertions, 4 deletions
diff --git a/chrome/browser/password_manager/password_store_mac.cc b/chrome/browser/password_manager/password_store_mac.cc index 6841959..9234eaa 100644 --- a/chrome/browser/password_manager/password_store_mac.cc +++ b/chrome/browser/password_manager/password_store_mac.cc @@ -449,6 +449,9 @@ PasswordForm* MacKeychainPasswordFormAdapter::PasswordExactlyMatchingForm( } bool MacKeychainPasswordFormAdapter::AddLogin(const PasswordForm& form) { + // We should never be trying to store a blacklist in the keychain. + DCHECK(!form.blacklisted_by_user); + std::string server; std::string security_domain; int port; @@ -631,17 +634,15 @@ PasswordStoreMac::PasswordStoreMac(MacKeychain* keychain, PasswordStoreMac::~PasswordStoreMac() {} void PasswordStoreMac::AddLoginImpl(const PasswordForm& form) { - MacKeychainPasswordFormAdapter keychainAdapter(keychain_.get()); - if (keychainAdapter.AddLogin(form)) { + if (AddToKeychainIfNecessary(form)) { login_metadata_db_->AddLogin(form); } } void PasswordStoreMac::UpdateLoginImpl(const PasswordForm& form) { - MacKeychainPasswordFormAdapter keychainAdapter(keychain_.get()); // The keychain AddLogin will update if there is a collision and add if there // isn't, which is the behavior we want, so there's no separate UpdateLogin. - if (keychainAdapter.AddLogin(form)) { + if (AddToKeychainIfNecessary(form)) { int update_count = 0; login_metadata_db_->UpdateLogin(form, &update_count); // Update will catch any database entries that we already had, but we could @@ -694,3 +695,11 @@ void PasswordStoreMac::GetAllLoginsImpl(GetLoginsRequest* request) { void PasswordStoreMac::GetAllAutofillableLoginsImpl(GetLoginsRequest* request) { NOTIMPLEMENTED(); } + +bool PasswordStoreMac::AddToKeychainIfNecessary(const PasswordForm& form) { + if (form.blacklisted_by_user) { + return true; + } + MacKeychainPasswordFormAdapter keychainAdapter(keychain_.get()); + return keychainAdapter.AddLogin(form); +} diff --git a/chrome/browser/password_manager/password_store_mac.h b/chrome/browser/password_manager/password_store_mac.h index c407e4e..e99d7cc 100644 --- a/chrome/browser/password_manager/password_store_mac.h +++ b/chrome/browser/password_manager/password_store_mac.h @@ -29,6 +29,11 @@ class PasswordStoreMac : public PasswordStore { void GetAllLoginsImpl(GetLoginsRequest* request); void GetAllAutofillableLoginsImpl(GetLoginsRequest* request); + // Adds the given form to the Keychain if it's something we want to store + // there (i.e., not a blacklist entry). Returns true if the operation + // succeeded (either we added successfully, or we didn't need to). + bool AddToKeychainIfNecessary(const webkit_glue::PasswordForm& form); + scoped_ptr<MacKeychain> keychain_; scoped_ptr<LoginDatabaseMac> login_metadata_db_; |