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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 PasswordStoreMac::GetBackgroundTaskRunner() { | 867 PasswordStoreMac::GetBackgroundTaskRunner() { |
868 return (thread_.get()) ? thread_->message_loop_proxy() : NULL; | 868 return (thread_.get()) ? thread_->message_loop_proxy() : NULL; |
869 } | 869 } |
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 PasswordStoreChangeList changes; | 878 PasswordStoreChangeList changes; |
878 if (AddToKeychainIfNecessary(form)) { | 879 if (AddToKeychainIfNecessary(form)) { |
879 if (login_metadata_db_->AddLogin(form)) { | 880 if (login_metadata_db_->AddLogin(form)) { |
880 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); | 881 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); |
881 } | 882 } |
882 } | 883 } |
883 return changes; | 884 return changes; |
884 } | 885 } |
885 | 886 |
886 PasswordStoreChangeList PasswordStoreMac::UpdateLoginImpl( | 887 PasswordStoreChangeList PasswordStoreMac::UpdateLoginImpl( |
887 const PasswordForm& form) { | 888 const PasswordForm& form) { |
| 889 DCHECK(thread_->message_loop() == base::MessageLoop::current()); |
888 PasswordStoreChangeList changes; | 890 PasswordStoreChangeList changes; |
889 int update_count = 0; | 891 int update_count = 0; |
890 if (!login_metadata_db_->UpdateLogin(form, &update_count)) | 892 if (!login_metadata_db_->UpdateLogin(form, &update_count)) |
891 return changes; | 893 return changes; |
892 | 894 |
893 MacKeychainPasswordFormAdapter keychain_adapter(keychain_.get()); | 895 MacKeychainPasswordFormAdapter keychain_adapter(keychain_.get()); |
894 if (update_count == 0 && | 896 if (update_count == 0 && |
895 !keychain_adapter.HasPasswordsMergeableWithForm(form)) { | 897 !keychain_adapter.HasPasswordsMergeableWithForm(form)) { |
896 // If the password isn't in either the DB or the keychain, then it must have | 898 // 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. | 899 // been deleted after autofill happened, and should not be re-added. |
(...skipping 11 matching lines...) Expand all Loading... |
909 } else { | 911 } else { |
910 changes.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, | 912 changes.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, |
911 form)); | 913 form)); |
912 } | 914 } |
913 } | 915 } |
914 return changes; | 916 return changes; |
915 } | 917 } |
916 | 918 |
917 PasswordStoreChangeList PasswordStoreMac::RemoveLoginImpl( | 919 PasswordStoreChangeList PasswordStoreMac::RemoveLoginImpl( |
918 const PasswordForm& form) { | 920 const PasswordForm& form) { |
| 921 DCHECK(thread_->message_loop() == base::MessageLoop::current()); |
919 PasswordStoreChangeList changes; | 922 PasswordStoreChangeList changes; |
920 if (login_metadata_db_->RemoveLogin(form)) { | 923 if (login_metadata_db_->RemoveLogin(form)) { |
921 // See if we own a Keychain item associated with this item. We can do an | 924 // See if we own a Keychain item associated with this item. We can do an |
922 // exact search rather than messing around with trying to do fuzzy matching | 925 // exact search rather than messing around with trying to do fuzzy matching |
923 // because passwords that we created will always have an exact-match | 926 // because passwords that we created will always have an exact-match |
924 // database entry. | 927 // database entry. |
925 // (If a user does lose their profile but not their keychain we'll treat the | 928 // (If a user does lose their profile but not their keychain we'll treat the |
926 // entries we find like other imported entries anyway, so it's reasonable to | 929 // entries we find like other imported entries anyway, so it's reasonable to |
927 // handle deletes on them the way we would for an imported item.) | 930 // handle deletes on them the way we would for an imported item.) |
928 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); | 931 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 | 1132 |
1130 void PasswordStoreMac::RemoveKeychainForms( | 1133 void PasswordStoreMac::RemoveKeychainForms( |
1131 const std::vector<PasswordForm*>& forms) { | 1134 const std::vector<PasswordForm*>& forms) { |
1132 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); | 1135 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); |
1133 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 1136 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
1134 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); | 1137 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); |
1135 i != forms.end(); ++i) { | 1138 i != forms.end(); ++i) { |
1136 owned_keychain_adapter.RemovePassword(**i); | 1139 owned_keychain_adapter.RemovePassword(**i); |
1137 } | 1140 } |
1138 } | 1141 } |
OLD | NEW |