| 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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 void PasswordStoreMac::ReportMetricsImpl() { | 763 void PasswordStoreMac::ReportMetricsImpl() { |
| 764 login_metadata_db_->ReportMetrics(); | 764 login_metadata_db_->ReportMetrics(); |
| 765 } | 765 } |
| 766 | 766 |
| 767 void PasswordStoreMac::AddLoginImpl(const PasswordForm& form) { | 767 void PasswordStoreMac::AddLoginImpl(const PasswordForm& form) { |
| 768 if (AddToKeychainIfNecessary(form)) { | 768 if (AddToKeychainIfNecessary(form)) { |
| 769 if (login_metadata_db_->AddLogin(form)) { | 769 if (login_metadata_db_->AddLogin(form)) { |
| 770 PasswordStoreChangeList changes; | 770 PasswordStoreChangeList changes; |
| 771 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); | 771 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); |
| 772 NotificationService::current()->Notify( | 772 NotificationService::current()->Notify( |
| 773 NotificationType::LOGINS_CHANGED, | 773 chrome::LOGINS_CHANGED, |
| 774 Source<PasswordStore>(this), | 774 Source<PasswordStore>(this), |
| 775 Details<PasswordStoreChangeList>(&changes)); | 775 Details<PasswordStoreChangeList>(&changes)); |
| 776 } | 776 } |
| 777 } | 777 } |
| 778 } | 778 } |
| 779 | 779 |
| 780 void PasswordStoreMac::UpdateLoginImpl(const PasswordForm& form) { | 780 void PasswordStoreMac::UpdateLoginImpl(const PasswordForm& form) { |
| 781 int update_count = 0; | 781 int update_count = 0; |
| 782 if (!login_metadata_db_->UpdateLogin(form, &update_count)) | 782 if (!login_metadata_db_->UpdateLogin(form, &update_count)) |
| 783 return; | 783 return; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 798 if (login_metadata_db_->AddLogin(form)) { | 798 if (login_metadata_db_->AddLogin(form)) { |
| 799 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, | 799 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, |
| 800 form)); | 800 form)); |
| 801 } | 801 } |
| 802 } else { | 802 } else { |
| 803 changes.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, | 803 changes.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, |
| 804 form)); | 804 form)); |
| 805 } | 805 } |
| 806 if (!changes.empty()) { | 806 if (!changes.empty()) { |
| 807 NotificationService::current()->Notify( | 807 NotificationService::current()->Notify( |
| 808 NotificationType::LOGINS_CHANGED, | 808 chrome::LOGINS_CHANGED, |
| 809 Source<PasswordStore>(this), | 809 Source<PasswordStore>(this), |
| 810 Details<PasswordStoreChangeList>(&changes)); | 810 Details<PasswordStoreChangeList>(&changes)); |
| 811 } | 811 } |
| 812 } | 812 } |
| 813 } | 813 } |
| 814 | 814 |
| 815 void PasswordStoreMac::RemoveLoginImpl(const PasswordForm& form) { | 815 void PasswordStoreMac::RemoveLoginImpl(const PasswordForm& form) { |
| 816 if (login_metadata_db_->RemoveLogin(form)) { | 816 if (login_metadata_db_->RemoveLogin(form)) { |
| 817 // See if we own a Keychain item associated with this item. We can do an | 817 // See if we own a Keychain item associated with this item. We can do an |
| 818 // exact search rather than messing around with trying to do fuzzy matching | 818 // exact search rather than messing around with trying to do fuzzy matching |
| (...skipping 10 matching lines...) Expand all Loading... |
| 829 // If we don't have other forms using it (i.e., a form differing only by | 829 // If we don't have other forms using it (i.e., a form differing only by |
| 830 // the names of the form elements), delete the keychain entry. | 830 // the names of the form elements), delete the keychain entry. |
| 831 if (!DatabaseHasFormMatchingKeychainForm(form)) { | 831 if (!DatabaseHasFormMatchingKeychainForm(form)) { |
| 832 owned_keychain_adapter.RemovePassword(form); | 832 owned_keychain_adapter.RemovePassword(form); |
| 833 } | 833 } |
| 834 } | 834 } |
| 835 | 835 |
| 836 PasswordStoreChangeList changes; | 836 PasswordStoreChangeList changes; |
| 837 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); | 837 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); |
| 838 NotificationService::current()->Notify( | 838 NotificationService::current()->Notify( |
| 839 NotificationType::LOGINS_CHANGED, | 839 chrome::LOGINS_CHANGED, |
| 840 Source<PasswordStore>(this), | 840 Source<PasswordStore>(this), |
| 841 Details<PasswordStoreChangeList>(&changes)); | 841 Details<PasswordStoreChangeList>(&changes)); |
| 842 } | 842 } |
| 843 } | 843 } |
| 844 | 844 |
| 845 void PasswordStoreMac::RemoveLoginsCreatedBetweenImpl( | 845 void PasswordStoreMac::RemoveLoginsCreatedBetweenImpl( |
| 846 const base::Time& delete_begin, const base::Time& delete_end) { | 846 const base::Time& delete_begin, const base::Time& delete_end) { |
| 847 std::vector<PasswordForm*> forms; | 847 std::vector<PasswordForm*> forms; |
| 848 if (login_metadata_db_->GetLoginsCreatedBetween(delete_begin, delete_end, | 848 if (login_metadata_db_->GetLoginsCreatedBetween(delete_begin, delete_end, |
| 849 &forms)) { | 849 &forms)) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 863 RemoveKeychainForms(orphan_keychain_forms); | 863 RemoveKeychainForms(orphan_keychain_forms); |
| 864 STLDeleteElements(&orphan_keychain_forms); | 864 STLDeleteElements(&orphan_keychain_forms); |
| 865 | 865 |
| 866 PasswordStoreChangeList changes; | 866 PasswordStoreChangeList changes; |
| 867 for (std::vector<PasswordForm*>::const_iterator it = forms.begin(); | 867 for (std::vector<PasswordForm*>::const_iterator it = forms.begin(); |
| 868 it != forms.end(); ++it) { | 868 it != forms.end(); ++it) { |
| 869 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, | 869 changes.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, |
| 870 **it)); | 870 **it)); |
| 871 } | 871 } |
| 872 NotificationService::current()->Notify( | 872 NotificationService::current()->Notify( |
| 873 NotificationType::LOGINS_CHANGED, | 873 chrome::LOGINS_CHANGED, |
| 874 Source<PasswordStore>(this), | 874 Source<PasswordStore>(this), |
| 875 Details<PasswordStoreChangeList>(&changes)); | 875 Details<PasswordStoreChangeList>(&changes)); |
| 876 } | 876 } |
| 877 } | 877 } |
| 878 } | 878 } |
| 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 = |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 1002 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 1003 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); | 1003 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); |
| 1004 i != forms.end(); ++i) { | 1004 i != forms.end(); ++i) { |
| 1005 owned_keychain_adapter.RemovePassword(**i); | 1005 owned_keychain_adapter.RemovePassword(**i); |
| 1006 } | 1006 } |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 void PasswordStoreMac::CreateNotificationService() { | 1009 void PasswordStoreMac::CreateNotificationService() { |
| 1010 notification_service_.reset(new NotificationService); | 1010 notification_service_.reset(new NotificationService); |
| 1011 } | 1011 } |
| OLD | NEW |