Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 const MacKeychain& keychain, std::vector<PasswordForm*>* database_forms) { | 444 const MacKeychain& keychain, std::vector<PasswordForm*>* database_forms) { |
| 445 MacKeychainPasswordFormAdapter keychain_adapter(&keychain); | 445 MacKeychainPasswordFormAdapter keychain_adapter(&keychain); |
| 446 | 446 |
| 447 std::vector<PasswordForm*> merged_forms; | 447 std::vector<PasswordForm*> merged_forms; |
| 448 for (std::vector<PasswordForm*>::iterator i = database_forms->begin(); | 448 for (std::vector<PasswordForm*>::iterator i = database_forms->begin(); |
| 449 i != database_forms->end();) { | 449 i != database_forms->end();) { |
| 450 std::vector<PasswordForm*> db_form_container(1, *i); | 450 std::vector<PasswordForm*> db_form_container(1, *i); |
| 451 std::vector<PasswordForm*> keychain_matches = | 451 std::vector<PasswordForm*> keychain_matches = |
| 452 keychain_adapter.PasswordsMergeableWithForm(**i); | 452 keychain_adapter.PasswordsMergeableWithForm(**i); |
| 453 MergePasswordForms(&keychain_matches, &db_form_container, &merged_forms); | 453 MergePasswordForms(&keychain_matches, &db_form_container, &merged_forms); |
| 454 if (db_form_container.size() == 0) { | 454 if (db_form_container.empty()) { |
| 455 i = database_forms->erase(i); | 455 i = database_forms->erase(i); |
| 456 } else { | 456 } else { |
| 457 ++i; | 457 ++i; |
| 458 } | 458 } |
| 459 STLDeleteElements(&keychain_matches); | 459 STLDeleteElements(&keychain_matches); |
| 460 } | 460 } |
| 461 return merged_forms; | 461 return merged_forms; |
| 462 } | 462 } |
| 463 | 463 |
| 464 } // namespace internal_keychain_helpers | 464 } // namespace internal_keychain_helpers |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 const PasswordForm& query_form) { | 509 const PasswordForm& query_form) { |
| 510 std::string username = UTF16ToUTF8(query_form.username_value); | 510 std::string username = UTF16ToUTF8(query_form.username_value); |
| 511 std::vector<SecKeychainItemRef> matches = | 511 std::vector<SecKeychainItemRef> matches = |
| 512 MatchingKeychainItems(query_form.signon_realm, query_form.scheme, | 512 MatchingKeychainItems(query_form.signon_realm, query_form.scheme, |
| 513 NULL, username.c_str()); | 513 NULL, username.c_str()); |
| 514 for (std::vector<SecKeychainItemRef>::iterator i = matches.begin(); | 514 for (std::vector<SecKeychainItemRef>::iterator i = matches.begin(); |
| 515 i != matches.end(); ++i) { | 515 i != matches.end(); ++i) { |
| 516 keychain_->Free(*i); | 516 keychain_->Free(*i); |
| 517 } | 517 } |
| 518 | 518 |
| 519 return matches.size() != 0; | 519 return matches.size() != 0; |
|
Peter Kasting
2011/03/02 00:02:42
Nit: !empty()
| |
| 520 } | 520 } |
| 521 | 521 |
| 522 std::vector<PasswordForm*> | 522 std::vector<PasswordForm*> |
| 523 MacKeychainPasswordFormAdapter::GetAllPasswordFormPasswords() { | 523 MacKeychainPasswordFormAdapter::GetAllPasswordFormPasswords() { |
| 524 SecAuthenticationType supported_auth_types[] = { | 524 SecAuthenticationType supported_auth_types[] = { |
| 525 kSecAuthenticationTypeHTMLForm, | 525 kSecAuthenticationTypeHTMLForm, |
| 526 kSecAuthenticationTypeHTTPBasic, | 526 kSecAuthenticationTypeHTTPBasic, |
| 527 kSecAuthenticationTypeHTTPDigest, | 527 kSecAuthenticationTypeHTTPDigest, |
| 528 }; | 528 }; |
| 529 | 529 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 619 // Keychain item goes with this form" is always "nothing" for blacklists. | 619 // Keychain item goes with this form" is always "nothing" for blacklists. |
| 620 if (form.blacklisted_by_user) { | 620 if (form.blacklisted_by_user) { |
| 621 return NULL; | 621 return NULL; |
| 622 } | 622 } |
| 623 | 623 |
| 624 std::string path = form.origin.path(); | 624 std::string path = form.origin.path(); |
| 625 std::string username = UTF16ToUTF8(form.username_value); | 625 std::string username = UTF16ToUTF8(form.username_value); |
| 626 std::vector<SecKeychainItemRef> matches = MatchingKeychainItems( | 626 std::vector<SecKeychainItemRef> matches = MatchingKeychainItems( |
| 627 form.signon_realm, form.scheme, path.c_str(), username.c_str()); | 627 form.signon_realm, form.scheme, path.c_str(), username.c_str()); |
| 628 | 628 |
| 629 if (matches.size() == 0) { | 629 if (matches.empty()) { |
| 630 return NULL; | 630 return NULL; |
| 631 } | 631 } |
| 632 // Free all items after the first, since we won't be returning them. | 632 // Free all items after the first, since we won't be returning them. |
| 633 for (std::vector<SecKeychainItemRef>::iterator i = matches.begin() + 1; | 633 for (std::vector<SecKeychainItemRef>::iterator i = matches.begin() + 1; |
| 634 i != matches.end(); ++i) { | 634 i != matches.end(); ++i) { |
| 635 keychain_->Free(*i); | 635 keychain_->Free(*i); |
| 636 } | 636 } |
| 637 return matches[0]; | 637 return matches[0]; |
| 638 } | 638 } |
| 639 | 639 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1004 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 1004 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 1005 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); | 1005 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); |
| 1006 i != forms.end(); ++i) { | 1006 i != forms.end(); ++i) { |
| 1007 owned_keychain_adapter.RemovePassword(**i); | 1007 owned_keychain_adapter.RemovePassword(**i); |
| 1008 } | 1008 } |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 void PasswordStoreMac::CreateNotificationService() { | 1011 void PasswordStoreMac::CreateNotificationService() { |
| 1012 notification_service_.reset(new NotificationService); | 1012 notification_service_.reset(new NotificationService); |
| 1013 } | 1013 } |
| OLD | NEW |