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 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 | 870 |
871 void PasswordStoreMac::ReportMetricsImpl() { | 871 void PasswordStoreMac::ReportMetricsImpl() { |
872 login_metadata_db_->ReportMetrics(); | 872 login_metadata_db_->ReportMetrics(); |
873 } | 873 } |
874 | 874 |
875 PasswordStoreChangeList PasswordStoreMac::AddLoginImpl( | 875 PasswordStoreChangeList PasswordStoreMac::AddLoginImpl( |
876 const PasswordForm& form) { | 876 const PasswordForm& form) { |
877 DCHECK(thread_->message_loop() == base::MessageLoop::current()); | 877 DCHECK(thread_->message_loop() == base::MessageLoop::current()); |
878 PasswordStoreChangeList changes; | 878 PasswordStoreChangeList changes; |
879 if (AddToKeychainIfNecessary(form)) { | 879 if (AddToKeychainIfNecessary(form)) { |
880 if (login_metadata_db_->AddLogin(form)) { | 880 changes = login_metadata_db_->AddLogin(form); |
881 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); | |
882 } | |
883 } | 881 } |
884 return changes; | 882 return changes; |
885 } | 883 } |
886 | 884 |
887 PasswordStoreChangeList PasswordStoreMac::UpdateLoginImpl( | 885 PasswordStoreChangeList PasswordStoreMac::UpdateLoginImpl( |
888 const PasswordForm& form) { | 886 const PasswordForm& form) { |
889 DCHECK(thread_->message_loop() == base::MessageLoop::current()); | 887 DCHECK(thread_->message_loop() == base::MessageLoop::current()); |
890 PasswordStoreChangeList changes; | 888 PasswordStoreChangeList changes; |
891 int update_count = 0; | 889 int update_count = 0; |
892 if (!login_metadata_db_->UpdateLogin(form, &update_count)) | 890 if (!login_metadata_db_->UpdateLogin(form, &update_count)) |
893 return changes; | 891 return changes; |
894 | 892 |
895 MacKeychainPasswordFormAdapter keychain_adapter(keychain_.get()); | 893 MacKeychainPasswordFormAdapter keychain_adapter(keychain_.get()); |
896 if (update_count == 0 && | 894 if (update_count == 0 && |
897 !keychain_adapter.HasPasswordsMergeableWithForm(form)) { | 895 !keychain_adapter.HasPasswordsMergeableWithForm(form)) { |
898 // If the password isn't in either the DB or the keychain, then it must have | 896 // If the password isn't in either the DB or the keychain, then it must have |
899 // been deleted after autofill happened, and should not be re-added. | 897 // been deleted after autofill happened, and should not be re-added. |
900 return changes; | 898 return changes; |
901 } | 899 } |
902 | 900 |
903 // The keychain add will update if there is a collision and add if there | 901 // The keychain add will update if there is a collision and add if there |
904 // isn't, which is the behavior we want, so there's no separate update call. | 902 // isn't, which is the behavior we want, so there's no separate update call. |
905 if (AddToKeychainIfNecessary(form)) { | 903 if (AddToKeychainIfNecessary(form)) { |
906 if (update_count == 0) { | 904 if (update_count == 0) |
907 if (login_metadata_db_->AddLogin(form)) { | 905 changes = login_metadata_db_->AddLogin(form); |
908 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, | 906 else |
909 form)); | 907 changes.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, form)); |
910 } | |
911 } else { | |
912 changes.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, | |
913 form)); | |
914 } | |
915 } | 908 } |
916 return changes; | 909 return changes; |
917 } | 910 } |
918 | 911 |
919 PasswordStoreChangeList PasswordStoreMac::RemoveLoginImpl( | 912 PasswordStoreChangeList PasswordStoreMac::RemoveLoginImpl( |
920 const PasswordForm& form) { | 913 const PasswordForm& form) { |
921 DCHECK(thread_->message_loop() == base::MessageLoop::current()); | 914 DCHECK(thread_->message_loop() == base::MessageLoop::current()); |
922 PasswordStoreChangeList changes; | 915 PasswordStoreChangeList changes; |
923 if (login_metadata_db_->RemoveLogin(form)) { | 916 if (login_metadata_db_->RemoveLogin(form)) { |
924 // See if we own a Keychain item associated with this item. We can do an | 917 // 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... |
1132 | 1125 |
1133 void PasswordStoreMac::RemoveKeychainForms( | 1126 void PasswordStoreMac::RemoveKeychainForms( |
1134 const std::vector<PasswordForm*>& forms) { | 1127 const std::vector<PasswordForm*>& forms) { |
1135 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); | 1128 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); |
1136 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 1129 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
1137 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); | 1130 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); |
1138 i != forms.end(); ++i) { | 1131 i != forms.end(); ++i) { |
1139 owned_keychain_adapter.RemovePassword(**i); | 1132 owned_keychain_adapter.RemovePassword(**i); |
1140 } | 1133 } |
1141 } | 1134 } |
OLD | NEW |