Chromium Code Reviews| 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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/mac/foundation_util.h" | 16 #include "base/mac/foundation_util.h" |
| 17 #include "base/mac/mac_logging.h" | 17 #include "base/mac/mac_logging.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/metrics/histogram_macros.h" | 19 #include "base/metrics/histogram_macros.h" |
| 20 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
| 21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 23 #include "chrome/browser/mac/security_wrappers.h" | 23 #include "chrome/browser/mac/security_wrappers.h" |
| 24 #include "components/os_crypt/os_crypt.h" | 24 #include "components/os_crypt/os_crypt.h" |
| 25 #include "components/password_manager/core/browser/affiliation_utils.h" | 25 #include "components/password_manager/core/browser/affiliation_utils.h" |
| 26 #include "components/password_manager/core/browser/login_database.h" | 26 #include "components/password_manager/core/browser/login_database.h" |
| 27 #include "components/password_manager/core/browser/password_store_change.h" | 27 #include "components/password_manager/core/browser/password_store_change.h" |
| 28 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 29 #include "crypto/apple_keychain.h" | 29 #include "crypto/apple_keychain.h" |
| 30 #include "url/origin.h" | |
| 30 | 31 |
| 31 using autofill::PasswordForm; | 32 using autofill::PasswordForm; |
| 32 using crypto::AppleKeychain; | 33 using crypto::AppleKeychain; |
| 33 using password_manager::PasswordStoreChange; | 34 using password_manager::PasswordStoreChange; |
| 34 using password_manager::PasswordStoreChangeList; | 35 using password_manager::PasswordStoreChangeList; |
| 35 | 36 |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| 38 // Utility class to handle the details of constructing and running a keychain | 39 // Utility class to handle the details of constructing and running a keychain |
| 39 // search from a set of attributes. | 40 // search from a set of attributes. |
| (...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1120 if (!DatabaseHasFormMatchingKeychainForm(form)) { | 1121 if (!DatabaseHasFormMatchingKeychainForm(form)) { |
| 1121 owned_keychain_adapter.RemovePassword(form); | 1122 owned_keychain_adapter.RemovePassword(form); |
| 1122 } | 1123 } |
| 1123 } | 1124 } |
| 1124 | 1125 |
| 1125 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); | 1126 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); |
| 1126 } | 1127 } |
| 1127 return changes; | 1128 return changes; |
| 1128 } | 1129 } |
| 1129 | 1130 |
| 1131 PasswordStoreChangeList PasswordStoreMac::RemoveLoginsByOriginAndTimeImpl( | |
| 1132 const url::Origin& origin, | |
| 1133 base::Time delete_begin, | |
| 1134 base::Time delete_end) { | |
| 1135 PasswordStoreChangeList changes; | |
| 1136 ScopedVector<PasswordForm> forms_to_consider; | |
| 1137 ScopedVector<PasswordForm> forms_to_remove; | |
| 1138 if (login_metadata_db_ && | |
| 1139 login_metadata_db_->GetLoginsCreatedBetween(delete_begin, delete_end, | |
| 1140 &forms_to_consider)) { | |
| 1141 MoveAllFormsOut( | |
| 1142 &forms_to_consider, | |
| 1143 [this, &origin, &forms_to_remove]( | |
| 1144 scoped_ptr<autofill::PasswordForm> form_to_consider) { | |
| 1145 if (origin.IsSameOriginWith(url::Origin(form_to_consider->origin)) && | |
| 1146 login_metadata_db_->RemoveLogin(*form_to_consider)) | |
| 1147 forms_to_remove.push_back(form_to_consider.Pass()); | |
| 1148 }); | |
| 1149 if (!forms_to_remove.empty()) { | |
| 1150 RemoveKeychainForms(forms_to_remove.get()); | |
| 1151 CleanOrphanedForms(&forms_to_remove); // Add the orphaned forms. | |
|
Timo Reimann
2015/10/20 20:47:09
Note that I did not implement tests to verify that
vasilii
2015/10/21 16:47:56
You can proceed with the option 4. I don't think w
| |
| 1152 changes = FormsToRemoveChangeList(forms_to_remove.get()); | |
| 1153 LogStatsForBulkDeletion(changes.size()); | |
| 1154 } | |
| 1155 } | |
| 1156 return changes; | |
| 1157 } | |
| 1158 | |
| 1130 PasswordStoreChangeList PasswordStoreMac::RemoveLoginsCreatedBetweenImpl( | 1159 PasswordStoreChangeList PasswordStoreMac::RemoveLoginsCreatedBetweenImpl( |
| 1131 base::Time delete_begin, | 1160 base::Time delete_begin, |
| 1132 base::Time delete_end) { | 1161 base::Time delete_end) { |
| 1133 PasswordStoreChangeList changes; | 1162 PasswordStoreChangeList changes; |
| 1134 ScopedVector<PasswordForm> forms_to_remove; | 1163 ScopedVector<PasswordForm> forms_to_remove; |
| 1135 if (login_metadata_db_ && | 1164 if (login_metadata_db_ && |
| 1136 login_metadata_db_->GetLoginsCreatedBetween(delete_begin, delete_end, | 1165 login_metadata_db_->GetLoginsCreatedBetween(delete_begin, delete_end, |
| 1137 &forms_to_remove) && | 1166 &forms_to_remove) && |
| 1138 login_metadata_db_->RemoveLoginsCreatedBetween(delete_begin, | 1167 login_metadata_db_->RemoveLoginsCreatedBetween(delete_begin, |
| 1139 delete_end)) { | 1168 delete_end)) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1323 ScopedVector<PasswordForm> forms_with_keychain_entry; | 1352 ScopedVector<PasswordForm> forms_with_keychain_entry; |
| 1324 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, | 1353 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, |
| 1325 &forms_with_keychain_entry); | 1354 &forms_with_keychain_entry); |
| 1326 | 1355 |
| 1327 // Clean up any orphaned database entries. | 1356 // Clean up any orphaned database entries. |
| 1328 RemoveDatabaseForms(&database_forms); | 1357 RemoveDatabaseForms(&database_forms); |
| 1329 | 1358 |
| 1330 // Move the orphaned DB forms to the output parameter. | 1359 // Move the orphaned DB forms to the output parameter. |
| 1331 AppendSecondToFirst(orphaned_forms, &database_forms); | 1360 AppendSecondToFirst(orphaned_forms, &database_forms); |
| 1332 } | 1361 } |
| OLD | NEW |