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 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 if (!DatabaseHasFormMatchingKeychainForm(form)) { | 1126 if (!DatabaseHasFormMatchingKeychainForm(form)) { |
1126 owned_keychain_adapter.RemovePassword(form); | 1127 owned_keychain_adapter.RemovePassword(form); |
1127 } | 1128 } |
1128 } | 1129 } |
1129 | 1130 |
1130 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); | 1131 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); |
1131 } | 1132 } |
1132 return changes; | 1133 return changes; |
1133 } | 1134 } |
1134 | 1135 |
| 1136 PasswordStoreChangeList PasswordStoreMac::RemoveLoginsByOriginAndTimeImpl( |
| 1137 const url::Origin& origin, |
| 1138 base::Time delete_begin, |
| 1139 base::Time delete_end) { |
| 1140 PasswordStoreChangeList changes; |
| 1141 ScopedVector<PasswordForm> forms_to_consider; |
| 1142 ScopedVector<PasswordForm> forms_to_remove; |
| 1143 if (login_metadata_db_ && |
| 1144 login_metadata_db_->GetLoginsCreatedBetween(delete_begin, delete_end, |
| 1145 &forms_to_consider)) { |
| 1146 MoveAllFormsOut( |
| 1147 &forms_to_consider, |
| 1148 [this, &origin, &forms_to_remove]( |
| 1149 scoped_ptr<autofill::PasswordForm> form_to_consider) { |
| 1150 if (origin.IsSameOriginWith(url::Origin(form_to_consider->origin)) && |
| 1151 login_metadata_db_->RemoveLogin(*form_to_consider)) |
| 1152 forms_to_remove.push_back(form_to_consider.Pass()); |
| 1153 }); |
| 1154 if (!forms_to_remove.empty()) { |
| 1155 RemoveKeychainForms(forms_to_remove.get()); |
| 1156 CleanOrphanedForms(&forms_to_remove); // Add the orphaned forms. |
| 1157 changes = FormsToRemoveChangeList(forms_to_remove.get()); |
| 1158 LogStatsForBulkDeletion(changes.size()); |
| 1159 } |
| 1160 } |
| 1161 return changes; |
| 1162 } |
| 1163 |
1135 PasswordStoreChangeList PasswordStoreMac::RemoveLoginsCreatedBetweenImpl( | 1164 PasswordStoreChangeList PasswordStoreMac::RemoveLoginsCreatedBetweenImpl( |
1136 base::Time delete_begin, | 1165 base::Time delete_begin, |
1137 base::Time delete_end) { | 1166 base::Time delete_end) { |
1138 PasswordStoreChangeList changes; | 1167 PasswordStoreChangeList changes; |
1139 ScopedVector<PasswordForm> forms_to_remove; | 1168 ScopedVector<PasswordForm> forms_to_remove; |
1140 if (login_metadata_db_ && | 1169 if (login_metadata_db_ && |
1141 login_metadata_db_->GetLoginsCreatedBetween(delete_begin, delete_end, | 1170 login_metadata_db_->GetLoginsCreatedBetween(delete_begin, delete_end, |
1142 &forms_to_remove) && | 1171 &forms_to_remove) && |
1143 login_metadata_db_->RemoveLoginsCreatedBetween(delete_begin, | 1172 login_metadata_db_->RemoveLoginsCreatedBetween(delete_begin, |
1144 delete_end)) { | 1173 delete_end)) { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 ScopedVector<PasswordForm> forms_with_keychain_entry; | 1365 ScopedVector<PasswordForm> forms_with_keychain_entry; |
1337 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, | 1366 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, |
1338 &forms_with_keychain_entry); | 1367 &forms_with_keychain_entry); |
1339 | 1368 |
1340 // Clean up any orphaned database entries. | 1369 // Clean up any orphaned database entries. |
1341 RemoveDatabaseForms(&database_forms); | 1370 RemoveDatabaseForms(&database_forms); |
1342 | 1371 |
1343 // Move the orphaned DB forms to the output parameter. | 1372 // Move the orphaned DB forms to the output parameter. |
1344 AppendSecondToFirst(orphaned_forms, &database_forms); | 1373 AppendSecondToFirst(orphaned_forms, &database_forms); |
1345 } | 1374 } |
OLD | NEW |