| 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_mac.h" |     5 #include "chrome/browser/password_manager/password_store_mac.h" | 
|     6 #include "chrome/browser/password_manager/password_store_mac_internal.h" |     6 #include "chrome/browser/password_manager/password_store_mac_internal.h" | 
|     7  |     7  | 
|     8 #include <CoreServices/CoreServices.h> |     8 #include <CoreServices/CoreServices.h> | 
|     9 #include <set> |     9 #include <set> | 
|    10 #include <string> |    10 #include <string> | 
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   878   PasswordStoreChangeList changes; |   878   PasswordStoreChangeList changes; | 
|   879   if (AddToKeychainIfNecessary(form)) { |   879   if (AddToKeychainIfNecessary(form)) { | 
|   880     changes = login_metadata_db_->AddLogin(form); |   880     changes = login_metadata_db_->AddLogin(form); | 
|   881   } |   881   } | 
|   882   return changes; |   882   return changes; | 
|   883 } |   883 } | 
|   884  |   884  | 
|   885 PasswordStoreChangeList PasswordStoreMac::UpdateLoginImpl( |   885 PasswordStoreChangeList PasswordStoreMac::UpdateLoginImpl( | 
|   886     const PasswordForm& form) { |   886     const PasswordForm& form) { | 
|   887   DCHECK(thread_->message_loop() == base::MessageLoop::current()); |   887   DCHECK(thread_->message_loop() == base::MessageLoop::current()); | 
|   888   PasswordStoreChangeList changes; |   888   PasswordStoreChangeList changes = login_metadata_db_->UpdateLogin(form); | 
|   889   int update_count = 0; |  | 
|   890   if (!login_metadata_db_->UpdateLogin(form, &update_count)) |  | 
|   891     return changes; |  | 
|   892  |   889  | 
|   893   MacKeychainPasswordFormAdapter keychain_adapter(keychain_.get()); |   890   MacKeychainPasswordFormAdapter keychain_adapter(keychain_.get()); | 
|   894   if (update_count == 0 && |   891   if (changes.empty() && | 
|   895       !keychain_adapter.HasPasswordsMergeableWithForm(form)) { |   892       !keychain_adapter.HasPasswordsMergeableWithForm(form)) { | 
|   896     // If the password isn't in either the DB or the keychain, then it must have |   893     // If the password isn't in either the DB or the keychain, then it must have | 
|   897     // been deleted after autofill happened, and should not be re-added. |   894     // been deleted after autofill happened, and should not be re-added. | 
|   898     return changes; |   895     return changes; | 
|   899   } |   896   } | 
|   900  |   897  | 
|   901   // The keychain add will update if there is a collision and add if there |   898   // The keychain add will update if there is a collision and add if there | 
|   902   // isn't, which is the behavior we want, so there's no separate update call. |   899   // isn't, which is the behavior we want, so there's no separate update call. | 
|   903   if (AddToKeychainIfNecessary(form)) { |   900   if (AddToKeychainIfNecessary(form) && changes.empty()) { | 
|   904     if (update_count == 0) |   901     changes = login_metadata_db_->AddLogin(form); | 
|   905       changes = login_metadata_db_->AddLogin(form); |  | 
|   906     else |  | 
|   907       changes.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, form)); |  | 
|   908   } |   902   } | 
|   909   return changes; |   903   return changes; | 
|   910 } |   904 } | 
|   911  |   905  | 
|   912 PasswordStoreChangeList PasswordStoreMac::RemoveLoginImpl( |   906 PasswordStoreChangeList PasswordStoreMac::RemoveLoginImpl( | 
|   913     const PasswordForm& form) { |   907     const PasswordForm& form) { | 
|   914   DCHECK(thread_->message_loop() == base::MessageLoop::current()); |   908   DCHECK(thread_->message_loop() == base::MessageLoop::current()); | 
|   915   PasswordStoreChangeList changes; |   909   PasswordStoreChangeList changes; | 
|   916   if (login_metadata_db_->RemoveLogin(form)) { |   910   if (login_metadata_db_->RemoveLogin(form)) { | 
|   917     // See if we own a Keychain item associated with this item. We can do an |   911     // See if we own a Keychain item associated with this item. We can do an | 
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1125  |  1119  | 
|  1126 void PasswordStoreMac::RemoveKeychainForms( |  1120 void PasswordStoreMac::RemoveKeychainForms( | 
|  1127     const std::vector<PasswordForm*>& forms) { |  1121     const std::vector<PasswordForm*>& forms) { | 
|  1128   MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); |  1122   MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); | 
|  1129   owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |  1123   owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 
|  1130   for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); |  1124   for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); | 
|  1131        i != forms.end(); ++i) { |  1125        i != forms.end(); ++i) { | 
|  1132     owned_keychain_adapter.RemovePassword(**i); |  1126     owned_keychain_adapter.RemovePassword(**i); | 
|  1133   } |  1127   } | 
|  1134 } |  1128 } | 
| OLD | NEW |