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 | 6 |
7 #include <CoreServices/CoreServices.h> | 7 #include <CoreServices/CoreServices.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 } else { | 540 } else { |
541 unused_database_forms.push_back(std::move(form)); | 541 unused_database_forms.push_back(std::move(form)); |
542 } | 542 } |
543 }); | 543 }); |
544 database_forms->swap(unused_database_forms); | 544 database_forms->swap(unused_database_forms); |
545 | 545 |
546 // Clear out all the Keychain entries we used. | 546 // Clear out all the Keychain entries we used. |
547 ScopedVector<autofill::PasswordForm> unused_keychain_forms; | 547 ScopedVector<autofill::PasswordForm> unused_keychain_forms; |
548 unused_keychain_forms.reserve(keychain_forms->size()); | 548 unused_keychain_forms.reserve(keychain_forms->size()); |
549 for (auto*& keychain_form : *keychain_forms) { | 549 for (auto*& keychain_form : *keychain_forms) { |
550 if (!ContainsKey(used_keychain_forms, keychain_form)) { | 550 if (!base::ContainsKey(used_keychain_forms, keychain_form)) { |
551 unused_keychain_forms.push_back(keychain_form); | 551 unused_keychain_forms.push_back(keychain_form); |
552 keychain_form = nullptr; | 552 keychain_form = nullptr; |
553 } | 553 } |
554 } | 554 } |
555 keychain_forms->swap(unused_keychain_forms); | 555 keychain_forms->swap(unused_keychain_forms); |
556 } | 556 } |
557 | 557 |
558 std::vector<ItemFormPair> ExtractAllKeychainItemAttributesIntoPasswordForms( | 558 std::vector<ItemFormPair> ExtractAllKeychainItemAttributesIntoPasswordForms( |
559 std::vector<SecKeychainItemRef>* keychain_items, | 559 std::vector<SecKeychainItemRef>* keychain_items, |
560 const AppleKeychain& keychain) { | 560 const AppleKeychain& keychain) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 ScopedVector<autofill::PasswordForm> keychain_matches = | 604 ScopedVector<autofill::PasswordForm> keychain_matches = |
605 ExtractPasswordsMergeableWithForm(keychain, item_form_pairs, *form); | 605 ExtractPasswordsMergeableWithForm(keychain, item_form_pairs, *form); |
606 | 606 |
607 ScopedVector<autofill::PasswordForm> db_form_container; | 607 ScopedVector<autofill::PasswordForm> db_form_container; |
608 db_form_container.push_back(std::move(form)); | 608 db_form_container.push_back(std::move(form)); |
609 MergePasswordForms(&keychain_matches, &db_form_container, passwords); | 609 MergePasswordForms(&keychain_matches, &db_form_container, passwords); |
610 AppendSecondToFirst(&unused_db_forms, &db_form_container); | 610 AppendSecondToFirst(&unused_db_forms, &db_form_container); |
611 }); | 611 }); |
612 database_forms->swap(unused_db_forms); | 612 database_forms->swap(unused_db_forms); |
613 | 613 |
614 STLDeleteContainerPairSecondPointers(item_form_pairs.begin(), | 614 base::STLDeleteContainerPairSecondPointers(item_form_pairs.begin(), |
615 item_form_pairs.end()); | 615 item_form_pairs.end()); |
616 for (SecKeychainItemRef item : keychain_items) { | 616 for (SecKeychainItemRef item : keychain_items) { |
617 keychain.Free(item); | 617 keychain.Free(item); |
618 } | 618 } |
619 } | 619 } |
620 | 620 |
621 // TODO(stuartmorgan): signon_realm for proxies is not yet supported. | 621 // TODO(stuartmorgan): signon_realm for proxies is not yet supported. |
622 bool ExtractSignonRealmComponents(const std::string& signon_realm, | 622 bool ExtractSignonRealmComponents(const std::string& signon_realm, |
623 std::string* server, | 623 std::string* server, |
624 UInt32* port, | 624 UInt32* port, |
625 bool* is_secure, | 625 bool* is_secure, |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 // Check if any corresponding keychain items are created by Chrome. | 1022 // Check if any corresponding keychain items are created by Chrome. |
1023 for (const auto& item_form_pair : item_form_pairs) { | 1023 for (const auto& item_form_pair : item_form_pairs) { |
1024 if (internal_keychain_helpers::FormIsValidAndMatchesOtherForm( | 1024 if (internal_keychain_helpers::FormIsValidAndMatchesOtherForm( |
1025 *form, *item_form_pair.second) && | 1025 *form, *item_form_pair.second) && |
1026 internal_keychain_helpers::HasChromeCreatorCode( | 1026 internal_keychain_helpers::HasChromeCreatorCode( |
1027 *keychain_, *item_form_pair.first)) | 1027 *keychain_, *item_form_pair.first)) |
1028 chrome_owned_locked_forms_count++; | 1028 chrome_owned_locked_forms_count++; |
1029 } | 1029 } |
1030 } | 1030 } |
1031 } | 1031 } |
1032 STLDeleteContainerPairSecondPointers(item_form_pairs.begin(), | 1032 base::STLDeleteContainerPairSecondPointers(item_form_pairs.begin(), |
1033 item_form_pairs.end()); | 1033 item_form_pairs.end()); |
1034 for (SecKeychainItemRef item : keychain_items) | 1034 for (SecKeychainItemRef item : keychain_items) |
1035 keychain_->Free(item); | 1035 keychain_->Free(item); |
1036 | 1036 |
1037 if (unmerged_forms_count) { | 1037 if (unmerged_forms_count) { |
1038 UMA_HISTOGRAM_COUNTS( | 1038 UMA_HISTOGRAM_COUNTS( |
1039 "PasswordManager.KeychainMigration.NumPasswordsOnFailure", | 1039 "PasswordManager.KeychainMigration.NumPasswordsOnFailure", |
1040 database_forms.size()); | 1040 database_forms.size()); |
1041 UMA_HISTOGRAM_COUNTS("PasswordManager.KeychainMigration.NumFailedPasswords", | 1041 UMA_HISTOGRAM_COUNTS("PasswordManager.KeychainMigration.NumFailedPasswords", |
1042 unmerged_forms_count); | 1042 unmerged_forms_count); |
1043 UMA_HISTOGRAM_COUNTS( | 1043 UMA_HISTOGRAM_COUNTS( |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 ScopedVector<PasswordForm> forms_with_keychain_entry; | 1397 ScopedVector<PasswordForm> forms_with_keychain_entry; |
1398 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, | 1398 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, |
1399 &forms_with_keychain_entry); | 1399 &forms_with_keychain_entry); |
1400 | 1400 |
1401 // Clean up any orphaned database entries. | 1401 // Clean up any orphaned database entries. |
1402 RemoveDatabaseForms(&database_forms); | 1402 RemoveDatabaseForms(&database_forms); |
1403 | 1403 |
1404 // Move the orphaned DB forms to the output parameter. | 1404 // Move the orphaned DB forms to the output parameter. |
1405 AppendSecondToFirst(orphaned_forms, &database_forms); | 1405 AppendSecondToFirst(orphaned_forms, &database_forms); |
1406 } | 1406 } |
OLD | NEW |