Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: chrome/browser/password_manager/password_store_mac.cc

Issue 6646051: Fix DCHECK, memory leak, and refactor PasswordStore to use CancelableRequest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git try works all platforms now. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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;
890 internal_keychain_helpers::MergePasswordForms(&keychain_forms, 889 internal_keychain_helpers::MergePasswordForms(&keychain_forms,
891 &database_forms, 890 &database_forms,
892 &merged_forms); 891 &request->value);
James Hawkins 2011/03/16 22:39:35 You use |request->value| three times in this metho
stuartmorgan 2011/03/16 23:25:20 Since you use this several times, maybe declare an
Sheridan Rawlins 2011/03/20 08:13:11 Done.
893 892
894 // Strip any blacklist entries out of the unused Keychain array, then take 893 // 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). 894 // all the entries that are left (which we can use as imported passwords).
896 std::vector<PasswordForm*> keychain_blacklist_forms = 895 std::vector<PasswordForm*> keychain_blacklist_forms =
897 internal_keychain_helpers::ExtractBlacklistForms(&keychain_forms); 896 internal_keychain_helpers::ExtractBlacklistForms(&keychain_forms);
898 merged_forms.insert(merged_forms.end(), keychain_forms.begin(), 897 request->value.insert(request->value.end(), keychain_forms.begin(),
899 keychain_forms.end()); 898 keychain_forms.end());
900 keychain_forms.clear(); 899 keychain_forms.clear();
901 STLDeleteElements(&keychain_blacklist_forms); 900 STLDeleteElements(&keychain_blacklist_forms);
902 901
903 // Clean up any orphaned database entries. 902 // Clean up any orphaned database entries.
904 RemoveDatabaseForms(database_forms); 903 RemoveDatabaseForms(database_forms);
905 STLDeleteElements(&database_forms); 904 STLDeleteElements(&database_forms);
906 905
907 NotifyConsumer(request, merged_forms); 906 ForwardLoginsResult(request);
908 } 907 }
909 908
910 void PasswordStoreMac::GetBlacklistLoginsImpl(GetLoginsRequest* request) { 909 void PasswordStoreMac::GetBlacklistLoginsImpl(GetLoginsRequest* request) {
911 std::vector<PasswordForm*> database_forms; 910 FillBlacklistLogins(&request->value);
912 FillBlacklistLogins(&database_forms); 911 ForwardLoginsResult(request);
913 NotifyConsumer(request, database_forms);
914 } 912 }
915 913
916 void PasswordStoreMac::GetAutofillableLoginsImpl(GetLoginsRequest* request) { 914 void PasswordStoreMac::GetAutofillableLoginsImpl(GetLoginsRequest* request) {
917 std::vector<PasswordForm*> database_forms; 915 FillAutofillableLogins(&request->value);
918 FillAutofillableLogins(&database_forms); 916 ForwardLoginsResult(request);
919 NotifyConsumer(request, database_forms);
920 } 917 }
921 918
922 bool PasswordStoreMac::FillAutofillableLogins( 919 bool PasswordStoreMac::FillAutofillableLogins(
923 std::vector<PasswordForm*>* forms) { 920 std::vector<PasswordForm*>* forms) {
924 DCHECK(thread_->message_loop() == MessageLoop::current()); 921 DCHECK(thread_->message_loop() == MessageLoop::current());
925 922
926 std::vector<PasswordForm*> database_forms; 923 std::vector<PasswordForm*> database_forms;
927 login_metadata_db_->GetAutofillableLogins(&database_forms); 924 login_metadata_db_->GetAutofillableLogins(&database_forms);
928 925
929 std::vector<PasswordForm*> merged_forms = 926 std::vector<PasswordForm*> merged_forms =
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); 1001 owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
1005 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); 1002 for (std::vector<PasswordForm*>::const_iterator i = forms.begin();
1006 i != forms.end(); ++i) { 1003 i != forms.end(); ++i) {
1007 owned_keychain_adapter.RemovePassword(**i); 1004 owned_keychain_adapter.RemovePassword(**i);
1008 } 1005 }
1009 } 1006 }
1010 1007
1011 void PasswordStoreMac::CreateNotificationService() { 1008 void PasswordStoreMac::CreateNotificationService() {
1012 notification_service_.reset(new NotificationService); 1009 notification_service_.reset(new NotificationService);
1013 } 1010 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698