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 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 it != forms.end(); ++it) { | 958 it != forms.end(); ++it) { |
959 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, | 959 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, |
960 **it)); | 960 **it)); |
961 } | 961 } |
962 LogStatsForBulkDeletion(changes.size()); | 962 LogStatsForBulkDeletion(changes.size()); |
963 } | 963 } |
964 } | 964 } |
965 return changes; | 965 return changes; |
966 } | 966 } |
967 | 967 |
| 968 PasswordStoreChangeList PasswordStoreMac::RemoveLoginsSyncedBetweenImpl( |
| 969 base::Time delete_begin, |
| 970 base::Time delete_end) { |
| 971 PasswordStoreChangeList changes; |
| 972 std::vector<PasswordForm*> forms; |
| 973 if (login_metadata_db_->GetLoginsSyncedBetween( |
| 974 delete_begin, delete_end, &forms)) { |
| 975 if (login_metadata_db_->RemoveLoginsSyncedBetween(delete_begin, |
| 976 delete_end)) { |
| 977 // We can't delete from the Keychain by date because we may be sharing |
| 978 // items with database entries that weren't in the delete range. Instead, |
| 979 // we find all the Keychain items we own but aren't using any more and |
| 980 // delete those. |
| 981 std::vector<PasswordForm*> orphan_keychain_forms = |
| 982 GetUnusedKeychainForms(); |
| 983 // This is inefficient, since we have to re-look-up each keychain item |
| 984 // one at a time to delete it even though the search step already had a |
| 985 // list of Keychain item references. If this turns out to be noticeably |
| 986 // slow we'll need to rearchitect to allow the search and deletion steps |
| 987 // to share. |
| 988 RemoveKeychainForms(orphan_keychain_forms); |
| 989 STLDeleteElements(&orphan_keychain_forms); |
| 990 |
| 991 for (std::vector<PasswordForm*>::const_iterator it = forms.begin(); |
| 992 it != forms.end(); |
| 993 ++it) { |
| 994 changes.push_back( |
| 995 PasswordStoreChange(PasswordStoreChange::REMOVE, **it)); |
| 996 } |
| 997 } |
| 998 } |
| 999 return changes; |
| 1000 } |
| 1001 |
968 void PasswordStoreMac::GetLoginsImpl( | 1002 void PasswordStoreMac::GetLoginsImpl( |
969 const autofill::PasswordForm& form, | 1003 const autofill::PasswordForm& form, |
970 AuthorizationPromptPolicy prompt_policy, | 1004 AuthorizationPromptPolicy prompt_policy, |
971 const ConsumerCallbackRunner& callback_runner) { | 1005 const ConsumerCallbackRunner& callback_runner) { |
972 chrome::ScopedSecKeychainSetUserInteractionAllowed user_interaction_allowed( | 1006 chrome::ScopedSecKeychainSetUserInteractionAllowed user_interaction_allowed( |
973 prompt_policy == ALLOW_PROMPT); | 1007 prompt_policy == ALLOW_PROMPT); |
974 | 1008 |
975 std::vector<PasswordForm*> database_forms; | 1009 std::vector<PasswordForm*> database_forms; |
976 login_metadata_db_->GetLogins(form, &database_forms); | 1010 login_metadata_db_->GetLogins(form, &database_forms); |
977 | 1011 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 | 1153 |
1120 void PasswordStoreMac::RemoveKeychainForms( | 1154 void PasswordStoreMac::RemoveKeychainForms( |
1121 const std::vector<PasswordForm*>& forms) { | 1155 const std::vector<PasswordForm*>& forms) { |
1122 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); | 1156 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); |
1123 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 1157 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
1124 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); | 1158 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); |
1125 i != forms.end(); ++i) { | 1159 i != forms.end(); ++i) { |
1126 owned_keychain_adapter.RemovePassword(**i); | 1160 owned_keychain_adapter.RemovePassword(**i); |
1127 } | 1161 } |
1128 } | 1162 } |
OLD | NEW |