| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 | 879 |
| 880 void PasswordStoreMac::GetLoginsImpl(GetLoginsRequest* request, | 880 void PasswordStoreMac::GetLoginsImpl(GetLoginsRequest* request, |
| 881 const webkit_glue::PasswordForm& form) { | 881 const webkit_glue::PasswordForm& form) { |
| 882 MacKeychainPasswordFormAdapter keychain_adapter(keychain_.get()); | 882 MacKeychainPasswordFormAdapter keychain_adapter(keychain_.get()); |
| 883 std::vector<PasswordForm*> keychain_forms = | 883 std::vector<PasswordForm*> keychain_forms = |
| 884 keychain_adapter.PasswordsFillingForm(form); | 884 keychain_adapter.PasswordsFillingForm(form); |
| 885 | 885 |
| 886 std::vector<PasswordForm*> database_forms; | 886 std::vector<PasswordForm*> database_forms; |
| 887 login_metadata_db_->GetLogins(form, &database_forms); | 887 login_metadata_db_->GetLogins(form, &database_forms); |
| 888 | 888 |
| 889 std::vector<PasswordForm*> merged_forms; | 889 std::vector<PasswordForm*>& merged_forms = request->value; |
| 890 internal_keychain_helpers::MergePasswordForms(&keychain_forms, | 890 internal_keychain_helpers::MergePasswordForms(&keychain_forms, |
| 891 &database_forms, | 891 &database_forms, |
| 892 &merged_forms); | 892 &merged_forms); |
| 893 | 893 |
| 894 // Strip any blacklist entries out of the unused Keychain array, then take | 894 // Strip any blacklist entries out of the unused Keychain array, then take |
| 895 // all the entries that are left (which we can use as imported passwords). | 895 // all the entries that are left (which we can use as imported passwords). |
| 896 std::vector<PasswordForm*> keychain_blacklist_forms = | 896 std::vector<PasswordForm*> keychain_blacklist_forms = |
| 897 internal_keychain_helpers::ExtractBlacklistForms(&keychain_forms); | 897 internal_keychain_helpers::ExtractBlacklistForms(&keychain_forms); |
| 898 merged_forms.insert(merged_forms.end(), keychain_forms.begin(), | 898 merged_forms.insert(merged_forms.end(), keychain_forms.begin(), |
| 899 keychain_forms.end()); | 899 keychain_forms.end()); |
| 900 keychain_forms.clear(); | 900 keychain_forms.clear(); |
| 901 STLDeleteElements(&keychain_blacklist_forms); | 901 STLDeleteElements(&keychain_blacklist_forms); |
| 902 | 902 |
| 903 // Clean up any orphaned database entries. | 903 // Clean up any orphaned database entries. |
| 904 RemoveDatabaseForms(database_forms); | 904 RemoveDatabaseForms(database_forms); |
| 905 STLDeleteElements(&database_forms); | 905 STLDeleteElements(&database_forms); |
| 906 | 906 |
| 907 NotifyConsumer(request, merged_forms); | 907 ForwardLoginsResult(request); |
| 908 } | 908 } |
| 909 | 909 |
| 910 void PasswordStoreMac::GetBlacklistLoginsImpl(GetLoginsRequest* request) { | 910 void PasswordStoreMac::GetBlacklistLoginsImpl(GetLoginsRequest* request) { |
| 911 std::vector<PasswordForm*> database_forms; | 911 FillBlacklistLogins(&request->value); |
| 912 FillBlacklistLogins(&database_forms); | 912 ForwardLoginsResult(request); |
| 913 NotifyConsumer(request, database_forms); | |
| 914 } | 913 } |
| 915 | 914 |
| 916 void PasswordStoreMac::GetAutofillableLoginsImpl(GetLoginsRequest* request) { | 915 void PasswordStoreMac::GetAutofillableLoginsImpl(GetLoginsRequest* request) { |
| 917 std::vector<PasswordForm*> database_forms; | 916 FillAutofillableLogins(&request->value); |
| 918 FillAutofillableLogins(&database_forms); | 917 ForwardLoginsResult(request); |
| 919 NotifyConsumer(request, database_forms); | |
| 920 } | 918 } |
| 921 | 919 |
| 922 bool PasswordStoreMac::FillAutofillableLogins( | 920 bool PasswordStoreMac::FillAutofillableLogins( |
| 923 std::vector<PasswordForm*>* forms) { | 921 std::vector<PasswordForm*>* forms) { |
| 924 DCHECK(thread_->message_loop() == MessageLoop::current()); | 922 DCHECK(thread_->message_loop() == MessageLoop::current()); |
| 925 | 923 |
| 926 std::vector<PasswordForm*> database_forms; | 924 std::vector<PasswordForm*> database_forms; |
| 927 login_metadata_db_->GetAutofillableLogins(&database_forms); | 925 login_metadata_db_->GetAutofillableLogins(&database_forms); |
| 928 | 926 |
| 929 std::vector<PasswordForm*> merged_forms = | 927 std::vector<PasswordForm*> merged_forms = |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 1002 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 1005 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); | 1003 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); |
| 1006 i != forms.end(); ++i) { | 1004 i != forms.end(); ++i) { |
| 1007 owned_keychain_adapter.RemovePassword(**i); | 1005 owned_keychain_adapter.RemovePassword(**i); |
| 1008 } | 1006 } |
| 1009 } | 1007 } |
| 1010 | 1008 |
| 1011 void PasswordStoreMac::CreateNotificationService() { | 1009 void PasswordStoreMac::CreateNotificationService() { |
| 1012 notification_service_.reset(new NotificationService); | 1010 notification_service_.reset(new NotificationService); |
| 1013 } | 1011 } |
| OLD | NEW |