| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } else if (!partial_match) { | 219 } else if (!partial_match) { |
| 220 partial_match = keychain_form; | 220 partial_match = keychain_form; |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 return partial_match; | 224 return partial_match; |
| 225 } | 225 } |
| 226 | 226 |
| 227 // Iterates over all elements in |forms|, passes the pointed to objects to | 227 // Iterates over all elements in |forms|, passes the pointed to objects to |
| 228 // |mover|, and clears |forms| efficiently. FormMover needs to be a callable | 228 // |mover|, and clears |forms| efficiently. FormMover needs to be a callable |
| 229 // entity, accepting scoped_ptr<autofill::PasswordForm> as its sole argument. | 229 // entity, accepting std::unique_ptr<autofill::PasswordForm> as its sole |
| 230 // argument. |
| 230 template <typename FormMover> | 231 template <typename FormMover> |
| 231 inline void MoveAllFormsOut(ScopedVector<autofill::PasswordForm>* forms, | 232 inline void MoveAllFormsOut(ScopedVector<autofill::PasswordForm>* forms, |
| 232 FormMover mover) { | 233 FormMover mover) { |
| 233 for (autofill::PasswordForm* form_ptr : *forms) { | 234 for (autofill::PasswordForm* form_ptr : *forms) { |
| 234 mover(scoped_ptr<autofill::PasswordForm>(form_ptr)); | 235 mover(std::unique_ptr<autofill::PasswordForm>(form_ptr)); |
| 235 } | 236 } |
| 236 // We moved the ownership of every form out of |forms|. For performance | 237 // We moved the ownership of every form out of |forms|. For performance |
| 237 // reasons, we can just weak_clear it, instead of nullptr-ing the respective | 238 // reasons, we can just weak_clear it, instead of nullptr-ing the respective |
| 238 // elements and letting the vector's destructor to go through the list once | 239 // elements and letting the vector's destructor to go through the list once |
| 239 // more. This was tested on a benchmark, and seemed to make a difference on | 240 // more. This was tested on a benchmark, and seemed to make a difference on |
| 240 // Mac. | 241 // Mac. |
| 241 forms->weak_clear(); | 242 forms->weak_clear(); |
| 242 } | 243 } |
| 243 | 244 |
| 244 // True if the form has no password to be stored in Keychain. | 245 // True if the form has no password to be stored in Keychain. |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 form_a.username_value == form_b.username_value; | 491 form_a.username_value == form_b.username_value; |
| 491 } | 492 } |
| 492 | 493 |
| 493 // Moves entries from |forms| that represent either blacklisted or federated | 494 // Moves entries from |forms| that represent either blacklisted or federated |
| 494 // logins into |extracted|. These two types are stored only in the LoginDatabase | 495 // logins into |extracted|. These two types are stored only in the LoginDatabase |
| 495 // and do not have corresponding Keychain entries. | 496 // and do not have corresponding Keychain entries. |
| 496 void ExtractNonKeychainForms(ScopedVector<autofill::PasswordForm>* forms, | 497 void ExtractNonKeychainForms(ScopedVector<autofill::PasswordForm>* forms, |
| 497 ScopedVector<autofill::PasswordForm>* extracted) { | 498 ScopedVector<autofill::PasswordForm>* extracted) { |
| 498 extracted->reserve(extracted->size() + forms->size()); | 499 extracted->reserve(extracted->size() + forms->size()); |
| 499 ScopedVector<autofill::PasswordForm> remaining; | 500 ScopedVector<autofill::PasswordForm> remaining; |
| 500 MoveAllFormsOut( | 501 MoveAllFormsOut(forms, [&remaining, extracted]( |
| 501 forms, [&remaining, extracted](scoped_ptr<autofill::PasswordForm> form) { | 502 std::unique_ptr<autofill::PasswordForm> form) { |
| 502 if (IsLoginDatabaseOnlyForm(*form)) | 503 if (IsLoginDatabaseOnlyForm(*form)) |
| 503 extracted->push_back(std::move(form)); | 504 extracted->push_back(std::move(form)); |
| 504 else | 505 else |
| 505 remaining.push_back(std::move(form)); | 506 remaining.push_back(std::move(form)); |
| 506 }); | 507 }); |
| 507 forms->swap(remaining); | 508 forms->swap(remaining); |
| 508 } | 509 } |
| 509 | 510 |
| 510 // Takes |keychain_forms| and |database_forms| and moves the following 2 types | 511 // Takes |keychain_forms| and |database_forms| and moves the following 2 types |
| 511 // of forms to |merged_forms|: | 512 // of forms to |merged_forms|: |
| 512 // (1) |database_forms| that by principle never have a corresponding Keychain | 513 // (1) |database_forms| that by principle never have a corresponding Keychain |
| 513 // entry (viz., blacklisted and federated logins), | 514 // entry (viz., blacklisted and federated logins), |
| 514 // (2) |database_forms| which should have and do have a corresponding entry in | 515 // (2) |database_forms| which should have and do have a corresponding entry in |
| 515 // |keychain_forms|. | 516 // |keychain_forms|. |
| 516 // The database forms of type (2) have their password value updated from the | 517 // The database forms of type (2) have their password value updated from the |
| 517 // corresponding keychain form, and all the keychain forms corresponding to some | 518 // corresponding keychain form, and all the keychain forms corresponding to some |
| 518 // database form are removed from |keychain_forms| and deleted. | 519 // database form are removed from |keychain_forms| and deleted. |
| 519 void MergePasswordForms(ScopedVector<autofill::PasswordForm>* keychain_forms, | 520 void MergePasswordForms(ScopedVector<autofill::PasswordForm>* keychain_forms, |
| 520 ScopedVector<autofill::PasswordForm>* database_forms, | 521 ScopedVector<autofill::PasswordForm>* database_forms, |
| 521 ScopedVector<autofill::PasswordForm>* merged_forms) { | 522 ScopedVector<autofill::PasswordForm>* merged_forms) { |
| 522 // Pull out the database blacklist items and federated logins, since they are | 523 // Pull out the database blacklist items and federated logins, since they are |
| 523 // used as-is rather than being merged with keychain forms. | 524 // used as-is rather than being merged with keychain forms. |
| 524 ExtractNonKeychainForms(database_forms, merged_forms); | 525 ExtractNonKeychainForms(database_forms, merged_forms); |
| 525 | 526 |
| 526 // Merge the normal entries. | 527 // Merge the normal entries. |
| 527 ScopedVector<autofill::PasswordForm> unused_database_forms; | 528 ScopedVector<autofill::PasswordForm> unused_database_forms; |
| 528 unused_database_forms.reserve(database_forms->size()); | 529 unused_database_forms.reserve(database_forms->size()); |
| 529 std::set<const autofill::PasswordForm*> used_keychain_forms; | 530 std::set<const autofill::PasswordForm*> used_keychain_forms; |
| 530 // Move all database forms to either |merged_forms| or | 531 // Move all database forms to either |merged_forms| or |
| 531 // |unused_database_forms|, based on whether they have a match in the keychain | 532 // |unused_database_forms|, based on whether they have a match in the keychain |
| 532 // forms or not. If there is a match, add its password to the DB form and | 533 // forms or not. If there is a match, add its password to the DB form and |
| 533 // mark the keychain form as used. | 534 // mark the keychain form as used. |
| 534 MoveAllFormsOut(database_forms, [keychain_forms, &used_keychain_forms, | 535 MoveAllFormsOut( |
| 535 merged_forms, &unused_database_forms]( | 536 database_forms, |
| 536 scoped_ptr<autofill::PasswordForm> form) { | 537 [keychain_forms, &used_keychain_forms, merged_forms, |
| 537 const PasswordForm* best_match = | 538 &unused_database_forms](std::unique_ptr<autofill::PasswordForm> form) { |
| 538 BestKeychainFormForForm(*form, keychain_forms->get()); | 539 const PasswordForm* best_match = |
| 539 if (best_match) { | 540 BestKeychainFormForForm(*form, keychain_forms->get()); |
| 540 used_keychain_forms.insert(best_match); | 541 if (best_match) { |
| 541 form->password_value = best_match->password_value; | 542 used_keychain_forms.insert(best_match); |
| 542 merged_forms->push_back(std::move(form)); | 543 form->password_value = best_match->password_value; |
| 543 } else { | 544 merged_forms->push_back(std::move(form)); |
| 544 unused_database_forms.push_back(std::move(form)); | 545 } else { |
| 545 } | 546 unused_database_forms.push_back(std::move(form)); |
| 546 }); | 547 } |
| 548 }); |
| 547 database_forms->swap(unused_database_forms); | 549 database_forms->swap(unused_database_forms); |
| 548 | 550 |
| 549 // Clear out all the Keychain entries we used. | 551 // Clear out all the Keychain entries we used. |
| 550 ScopedVector<autofill::PasswordForm> unused_keychain_forms; | 552 ScopedVector<autofill::PasswordForm> unused_keychain_forms; |
| 551 unused_keychain_forms.reserve(keychain_forms->size()); | 553 unused_keychain_forms.reserve(keychain_forms->size()); |
| 552 for (auto& keychain_form : *keychain_forms) { | 554 for (auto& keychain_form : *keychain_forms) { |
| 553 if (!ContainsKey(used_keychain_forms, keychain_form)) { | 555 if (!ContainsKey(used_keychain_forms, keychain_form)) { |
| 554 unused_keychain_forms.push_back(keychain_form); | 556 unused_keychain_forms.push_back(keychain_form); |
| 555 keychain_form = nullptr; | 557 keychain_form = nullptr; |
| 556 } | 558 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 ExtractAllKeychainItemAttributesIntoPasswordForms(&keychain_items, | 595 ExtractAllKeychainItemAttributesIntoPasswordForms(&keychain_items, |
| 594 keychain); | 596 keychain); |
| 595 | 597 |
| 596 // Next, compare the attributes of the PasswordForms in |database_forms| | 598 // Next, compare the attributes of the PasswordForms in |database_forms| |
| 597 // against those in |item_form_pairs|, and extract password data for each | 599 // against those in |item_form_pairs|, and extract password data for each |
| 598 // matching PasswordForm using its corresponding SecKeychainItemRef. | 600 // matching PasswordForm using its corresponding SecKeychainItemRef. |
| 599 ScopedVector<autofill::PasswordForm> unused_db_forms; | 601 ScopedVector<autofill::PasswordForm> unused_db_forms; |
| 600 unused_db_forms.reserve(database_forms->size()); | 602 unused_db_forms.reserve(database_forms->size()); |
| 601 // Move database forms with a password stored in |keychain| to |passwords|, | 603 // Move database forms with a password stored in |keychain| to |passwords|, |
| 602 // including the password. The rest is moved to |unused_db_forms|. | 604 // including the password. The rest is moved to |unused_db_forms|. |
| 603 MoveAllFormsOut(database_forms, | 605 MoveAllFormsOut( |
| 604 [&keychain, &item_form_pairs, passwords, &unused_db_forms]( | 606 database_forms, |
| 605 scoped_ptr<autofill::PasswordForm> form) { | 607 [&keychain, &item_form_pairs, passwords, |
| 606 ScopedVector<autofill::PasswordForm> keychain_matches = | 608 &unused_db_forms](std::unique_ptr<autofill::PasswordForm> form) { |
| 607 ExtractPasswordsMergeableWithForm(keychain, item_form_pairs, *form); | 609 ScopedVector<autofill::PasswordForm> keychain_matches = |
| 610 ExtractPasswordsMergeableWithForm(keychain, item_form_pairs, *form); |
| 608 | 611 |
| 609 ScopedVector<autofill::PasswordForm> db_form_container; | 612 ScopedVector<autofill::PasswordForm> db_form_container; |
| 610 db_form_container.push_back(std::move(form)); | 613 db_form_container.push_back(std::move(form)); |
| 611 MergePasswordForms(&keychain_matches, &db_form_container, passwords); | 614 MergePasswordForms(&keychain_matches, &db_form_container, passwords); |
| 612 AppendSecondToFirst(&unused_db_forms, &db_form_container); | 615 AppendSecondToFirst(&unused_db_forms, &db_form_container); |
| 613 }); | 616 }); |
| 614 database_forms->swap(unused_db_forms); | 617 database_forms->swap(unused_db_forms); |
| 615 | 618 |
| 616 STLDeleteContainerPairSecondPointers(item_form_pairs.begin(), | 619 STLDeleteContainerPairSecondPointers(item_form_pairs.begin(), |
| 617 item_form_pairs.end()); | 620 item_form_pairs.end()); |
| 618 for (SecKeychainItemRef item : keychain_items) { | 621 for (SecKeychainItemRef item : keychain_items) { |
| 619 keychain.Free(item); | 622 keychain.Free(item); |
| 620 } | 623 } |
| 621 } | 624 } |
| 622 | 625 |
| 623 // TODO(stuartmorgan): signon_realm for proxies is not yet supported. | 626 // TODO(stuartmorgan): signon_realm for proxies is not yet supported. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 ScopedVector<autofill::PasswordForm> ExtractPasswordsMergeableWithForm( | 681 ScopedVector<autofill::PasswordForm> ExtractPasswordsMergeableWithForm( |
| 679 const AppleKeychain& keychain, | 682 const AppleKeychain& keychain, |
| 680 const std::vector<ItemFormPair>& item_form_pairs, | 683 const std::vector<ItemFormPair>& item_form_pairs, |
| 681 const PasswordForm& query_form) { | 684 const PasswordForm& query_form) { |
| 682 ScopedVector<autofill::PasswordForm> matches; | 685 ScopedVector<autofill::PasswordForm> matches; |
| 683 for (std::vector<ItemFormPair>::const_iterator i = item_form_pairs.begin(); | 686 for (std::vector<ItemFormPair>::const_iterator i = item_form_pairs.begin(); |
| 684 i != item_form_pairs.end(); ++i) { | 687 i != item_form_pairs.end(); ++i) { |
| 685 if (FormIsValidAndMatchesOtherForm(query_form, *(i->second))) { | 688 if (FormIsValidAndMatchesOtherForm(query_form, *(i->second))) { |
| 686 // Create a new object, since the caller is responsible for deleting the | 689 // Create a new object, since the caller is responsible for deleting the |
| 687 // returned forms. | 690 // returned forms. |
| 688 scoped_ptr<PasswordForm> form_with_password(new PasswordForm()); | 691 std::unique_ptr<PasswordForm> form_with_password(new PasswordForm()); |
| 689 FillPasswordFormFromKeychainItem( | 692 FillPasswordFormFromKeychainItem( |
| 690 keychain, *(i->first), form_with_password.get(), | 693 keychain, *(i->first), form_with_password.get(), |
| 691 true); // Load password attributes and data. | 694 true); // Load password attributes and data. |
| 692 // Do not include blacklisted items found in the keychain. | 695 // Do not include blacklisted items found in the keychain. |
| 693 if (!form_with_password->blacklisted_by_user) | 696 if (!form_with_password->blacklisted_by_user) |
| 694 matches.push_back(std::move(form_with_password)); | 697 matches.push_back(std::move(form_with_password)); |
| 695 } | 698 } |
| 696 } | 699 } |
| 697 return matches; | 700 return matches; |
| 698 } | 701 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 void MacKeychainPasswordFormAdapter::SetFindsOnlyOwnedItems( | 834 void MacKeychainPasswordFormAdapter::SetFindsOnlyOwnedItems( |
| 832 bool finds_only_owned) { | 835 bool finds_only_owned) { |
| 833 finds_only_owned_ = finds_only_owned; | 836 finds_only_owned_ = finds_only_owned; |
| 834 } | 837 } |
| 835 | 838 |
| 836 ScopedVector<autofill::PasswordForm> | 839 ScopedVector<autofill::PasswordForm> |
| 837 MacKeychainPasswordFormAdapter::ConvertKeychainItemsToForms( | 840 MacKeychainPasswordFormAdapter::ConvertKeychainItemsToForms( |
| 838 std::vector<SecKeychainItemRef>* items) { | 841 std::vector<SecKeychainItemRef>* items) { |
| 839 ScopedVector<autofill::PasswordForm> forms; | 842 ScopedVector<autofill::PasswordForm> forms; |
| 840 for (SecKeychainItemRef item : *items) { | 843 for (SecKeychainItemRef item : *items) { |
| 841 scoped_ptr<PasswordForm> form(new PasswordForm()); | 844 std::unique_ptr<PasswordForm> form(new PasswordForm()); |
| 842 if (internal_keychain_helpers::FillPasswordFormFromKeychainItem( | 845 if (internal_keychain_helpers::FillPasswordFormFromKeychainItem( |
| 843 *keychain_, item, form.get(), true)) { | 846 *keychain_, item, form.get(), true)) { |
| 844 forms.push_back(std::move(form)); | 847 forms.push_back(std::move(form)); |
| 845 } | 848 } |
| 846 keychain_->Free(item); | 849 keychain_->Free(item); |
| 847 } | 850 } |
| 848 items->clear(); | 851 items->clear(); |
| 849 return forms; | 852 return forms; |
| 850 } | 853 } |
| 851 | 854 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 | 952 |
| 950 OSType MacKeychainPasswordFormAdapter::CreatorCodeForSearch() { | 953 OSType MacKeychainPasswordFormAdapter::CreatorCodeForSearch() { |
| 951 return finds_only_owned_ ? base::mac::CreatorCodeForApplication() : 0; | 954 return finds_only_owned_ ? base::mac::CreatorCodeForApplication() : 0; |
| 952 } | 955 } |
| 953 | 956 |
| 954 #pragma mark - | 957 #pragma mark - |
| 955 | 958 |
| 956 PasswordStoreMac::PasswordStoreMac( | 959 PasswordStoreMac::PasswordStoreMac( |
| 957 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, | 960 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, |
| 958 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, | 961 scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, |
| 959 scoped_ptr<AppleKeychain> keychain) | 962 std::unique_ptr<AppleKeychain> keychain) |
| 960 : password_manager::PasswordStore(main_thread_runner, db_thread_runner), | 963 : password_manager::PasswordStore(main_thread_runner, db_thread_runner), |
| 961 keychain_(std::move(keychain)), | 964 keychain_(std::move(keychain)), |
| 962 login_metadata_db_(nullptr) { | 965 login_metadata_db_(nullptr) { |
| 963 DCHECK(keychain_); | 966 DCHECK(keychain_); |
| 964 } | 967 } |
| 965 | 968 |
| 966 PasswordStoreMac::~PasswordStoreMac() {} | 969 PasswordStoreMac::~PasswordStoreMac() {} |
| 967 | 970 |
| 968 void PasswordStoreMac::InitWithTaskRunner( | 971 void PasswordStoreMac::InitWithTaskRunner( |
| 969 scoped_refptr<base::SingleThreadTaskRunner> background_task_runner) { | 972 scoped_refptr<base::SingleThreadTaskRunner> background_task_runner) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 PasswordStoreChangeList PasswordStoreMac::RemoveLoginsByURLAndTimeImpl( | 1141 PasswordStoreChangeList PasswordStoreMac::RemoveLoginsByURLAndTimeImpl( |
| 1139 const base::Callback<bool(const GURL&)>& url_filter, | 1142 const base::Callback<bool(const GURL&)>& url_filter, |
| 1140 base::Time delete_begin, | 1143 base::Time delete_begin, |
| 1141 base::Time delete_end) { | 1144 base::Time delete_end) { |
| 1142 PasswordStoreChangeList changes; | 1145 PasswordStoreChangeList changes; |
| 1143 ScopedVector<PasswordForm> forms_to_consider; | 1146 ScopedVector<PasswordForm> forms_to_consider; |
| 1144 ScopedVector<PasswordForm> forms_to_remove; | 1147 ScopedVector<PasswordForm> forms_to_remove; |
| 1145 if (login_metadata_db_ && | 1148 if (login_metadata_db_ && |
| 1146 login_metadata_db_->GetLoginsCreatedBetween(delete_begin, delete_end, | 1149 login_metadata_db_->GetLoginsCreatedBetween(delete_begin, delete_end, |
| 1147 &forms_to_consider)) { | 1150 &forms_to_consider)) { |
| 1148 MoveAllFormsOut(&forms_to_consider, | 1151 MoveAllFormsOut( |
| 1149 [this, &url_filter, &forms_to_remove]( | 1152 &forms_to_consider, |
| 1150 scoped_ptr<autofill::PasswordForm> form_to_consider) { | 1153 [this, &url_filter, &forms_to_remove]( |
| 1151 if (url_filter.Run(form_to_consider->origin) && | 1154 std::unique_ptr<autofill::PasswordForm> form_to_consider) { |
| 1152 login_metadata_db_->RemoveLogin(*form_to_consider)) | 1155 if (url_filter.Run(form_to_consider->origin) && |
| 1153 forms_to_remove.push_back(std::move(form_to_consider)); | 1156 login_metadata_db_->RemoveLogin(*form_to_consider)) |
| 1154 }); | 1157 forms_to_remove.push_back(std::move(form_to_consider)); |
| 1158 }); |
| 1155 if (!forms_to_remove.empty()) { | 1159 if (!forms_to_remove.empty()) { |
| 1156 RemoveKeychainForms(forms_to_remove.get()); | 1160 RemoveKeychainForms(forms_to_remove.get()); |
| 1157 CleanOrphanedForms(&forms_to_remove); // Add the orphaned forms. | 1161 CleanOrphanedForms(&forms_to_remove); // Add the orphaned forms. |
| 1158 changes = FormsToRemoveChangeList(forms_to_remove.get()); | 1162 changes = FormsToRemoveChangeList(forms_to_remove.get()); |
| 1159 LogStatsForBulkDeletion(changes.size()); | 1163 LogStatsForBulkDeletion(changes.size()); |
| 1160 } | 1164 } |
| 1161 } | 1165 } |
| 1162 return changes; | 1166 return changes; |
| 1163 } | 1167 } |
| 1164 | 1168 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 if (login_metadata_db_) | 1303 if (login_metadata_db_) |
| 1300 login_metadata_db_->stats_table().AddRow(stats); | 1304 login_metadata_db_->stats_table().AddRow(stats); |
| 1301 } | 1305 } |
| 1302 | 1306 |
| 1303 void PasswordStoreMac::RemoveSiteStatsImpl(const GURL& origin_domain) { | 1307 void PasswordStoreMac::RemoveSiteStatsImpl(const GURL& origin_domain) { |
| 1304 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); | 1308 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); |
| 1305 if (login_metadata_db_) | 1309 if (login_metadata_db_) |
| 1306 login_metadata_db_->stats_table().RemoveRow(origin_domain); | 1310 login_metadata_db_->stats_table().RemoveRow(origin_domain); |
| 1307 } | 1311 } |
| 1308 | 1312 |
| 1309 std::vector<scoped_ptr<password_manager::InteractionsStats>> | 1313 std::vector<std::unique_ptr<password_manager::InteractionsStats>> |
| 1310 PasswordStoreMac::GetSiteStatsImpl(const GURL& origin_domain) { | 1314 PasswordStoreMac::GetSiteStatsImpl(const GURL& origin_domain) { |
| 1311 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); | 1315 DCHECK(GetBackgroundTaskRunner()->BelongsToCurrentThread()); |
| 1312 return login_metadata_db_ | 1316 return login_metadata_db_ |
| 1313 ? login_metadata_db_->stats_table().GetRows(origin_domain) | 1317 ? login_metadata_db_->stats_table().GetRows(origin_domain) |
| 1314 : std::vector<scoped_ptr<password_manager::InteractionsStats>>(); | 1318 : std::vector< |
| 1319 std::unique_ptr<password_manager::InteractionsStats>>(); |
| 1315 } | 1320 } |
| 1316 | 1321 |
| 1317 bool PasswordStoreMac::AddToKeychainIfNecessary(const PasswordForm& form) { | 1322 bool PasswordStoreMac::AddToKeychainIfNecessary(const PasswordForm& form) { |
| 1318 if (IsLoginDatabaseOnlyForm(form)) | 1323 if (IsLoginDatabaseOnlyForm(form)) |
| 1319 return true; | 1324 return true; |
| 1320 MacKeychainPasswordFormAdapter keychainAdapter(keychain_.get()); | 1325 MacKeychainPasswordFormAdapter keychainAdapter(keychain_.get()); |
| 1321 return keychainAdapter.AddPassword(form); | 1326 return keychainAdapter.AddPassword(form); |
| 1322 } | 1327 } |
| 1323 | 1328 |
| 1324 bool PasswordStoreMac::DatabaseHasFormMatchingKeychainForm( | 1329 bool PasswordStoreMac::DatabaseHasFormMatchingKeychainForm( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1340 } | 1345 } |
| 1341 } | 1346 } |
| 1342 return has_match; | 1347 return has_match; |
| 1343 } | 1348 } |
| 1344 | 1349 |
| 1345 void PasswordStoreMac::RemoveDatabaseForms( | 1350 void PasswordStoreMac::RemoveDatabaseForms( |
| 1346 ScopedVector<autofill::PasswordForm>* forms) { | 1351 ScopedVector<autofill::PasswordForm>* forms) { |
| 1347 DCHECK(login_metadata_db_); | 1352 DCHECK(login_metadata_db_); |
| 1348 ScopedVector<autofill::PasswordForm> removed_forms; | 1353 ScopedVector<autofill::PasswordForm> removed_forms; |
| 1349 MoveAllFormsOut(forms, [this, &removed_forms]( | 1354 MoveAllFormsOut(forms, [this, &removed_forms]( |
| 1350 scoped_ptr<autofill::PasswordForm> form) { | 1355 std::unique_ptr<autofill::PasswordForm> form) { |
| 1351 if (login_metadata_db_->RemoveLogin(*form)) | 1356 if (login_metadata_db_->RemoveLogin(*form)) |
| 1352 removed_forms.push_back(std::move(form)); | 1357 removed_forms.push_back(std::move(form)); |
| 1353 }); | 1358 }); |
| 1354 removed_forms.swap(*forms); | 1359 removed_forms.swap(*forms); |
| 1355 } | 1360 } |
| 1356 | 1361 |
| 1357 void PasswordStoreMac::RemoveKeychainForms( | 1362 void PasswordStoreMac::RemoveKeychainForms( |
| 1358 const std::vector<PasswordForm*>& forms) { | 1363 const std::vector<PasswordForm*>& forms) { |
| 1359 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); | 1364 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); |
| 1360 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 1365 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1377 ScopedVector<PasswordForm> forms_with_keychain_entry; | 1382 ScopedVector<PasswordForm> forms_with_keychain_entry; |
| 1378 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, | 1383 internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms, |
| 1379 &forms_with_keychain_entry); | 1384 &forms_with_keychain_entry); |
| 1380 | 1385 |
| 1381 // Clean up any orphaned database entries. | 1386 // Clean up any orphaned database entries. |
| 1382 RemoveDatabaseForms(&database_forms); | 1387 RemoveDatabaseForms(&database_forms); |
| 1383 | 1388 |
| 1384 // Move the orphaned DB forms to the output parameter. | 1389 // Move the orphaned DB forms to the output parameter. |
| 1385 AppendSecondToFirst(orphaned_forms, &database_forms); | 1390 AppendSecondToFirst(orphaned_forms, &database_forms); |
| 1386 } | 1391 } |
| OLD | NEW |