OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/mac_util.h" | 13 #include "base/mac_util.h" |
14 #include "base/stl_util-inl.h" | 14 #include "base/stl_util-inl.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome/browser/keychain_mac.h" | 17 #include "chrome/browser/keychain_mac.h" |
18 #include "chrome/browser/password_manager/login_database_mac.h" | 18 #include "chrome/browser/password_manager/login_database.h" |
19 | 19 |
20 using webkit_glue::PasswordForm; | 20 using webkit_glue::PasswordForm; |
21 | 21 |
22 // Utility class to handle the details of constructing and running a keychain | 22 // Utility class to handle the details of constructing and running a keychain |
23 // search from a set of attributes. | 23 // search from a set of attributes. |
24 class KeychainSearch { | 24 class KeychainSearch { |
25 public: | 25 public: |
26 explicit KeychainSearch(const MacKeychain& keychain); | 26 explicit KeychainSearch(const MacKeychain& keychain); |
27 ~KeychainSearch(); | 27 ~KeychainSearch(); |
28 | 28 |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 return result == noErr; | 702 return result == noErr; |
703 } | 703 } |
704 | 704 |
705 OSType MacKeychainPasswordFormAdapter::CreatorCodeForSearch() { | 705 OSType MacKeychainPasswordFormAdapter::CreatorCodeForSearch() { |
706 return finds_only_owned_ ? mac_util::CreatorCodeForApplication() : 0; | 706 return finds_only_owned_ ? mac_util::CreatorCodeForApplication() : 0; |
707 } | 707 } |
708 | 708 |
709 #pragma mark - | 709 #pragma mark - |
710 | 710 |
711 PasswordStoreMac::PasswordStoreMac(MacKeychain* keychain, | 711 PasswordStoreMac::PasswordStoreMac(MacKeychain* keychain, |
712 LoginDatabaseMac* login_db) | 712 LoginDatabase* login_db) |
713 : keychain_(keychain), login_metadata_db_(login_db) { | 713 : keychain_(keychain), login_metadata_db_(login_db) { |
714 DCHECK(keychain_.get()); | 714 DCHECK(keychain_.get()); |
715 DCHECK(login_metadata_db_.get()); | 715 DCHECK(login_metadata_db_.get()); |
716 } | 716 } |
717 | 717 |
718 PasswordStoreMac::~PasswordStoreMac() {} | 718 PasswordStoreMac::~PasswordStoreMac() {} |
719 | 719 |
720 void PasswordStoreMac::AddLoginImpl(const PasswordForm& form) { | 720 void PasswordStoreMac::AddLoginImpl(const PasswordForm& form) { |
721 if (AddToKeychainIfNecessary(form)) { | 721 if (AddToKeychainIfNecessary(form)) { |
722 login_metadata_db_->AddLogin(form); | 722 login_metadata_db_->AddLogin(form); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 | 882 |
883 void PasswordStoreMac::RemoveKeychainForms( | 883 void PasswordStoreMac::RemoveKeychainForms( |
884 const std::vector<PasswordForm*>& forms) { | 884 const std::vector<PasswordForm*>& forms) { |
885 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); | 885 MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get()); |
886 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 886 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
887 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); | 887 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); |
888 i != forms.end(); ++i) { | 888 i != forms.end(); ++i) { |
889 owned_keychain_adapter.RemovePassword(**i); | 889 owned_keychain_adapter.RemovePassword(**i); |
890 } | 890 } |
891 } | 891 } |
OLD | NEW |