| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/mac_util.h" | 14 #include "base/mac/mac_util.h" |
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "base/stl_util-inl.h" | 16 #include "base/stl_util-inl.h" |
| 17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 18 #include "base/task.h" | 18 #include "base/task.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "chrome/browser/keychain_mac.h" | 20 #include "chrome/browser/keychain_mac.h" |
| 21 #include "chrome/browser/password_manager/login_database.h" | 21 #include "chrome/browser/password_manager/login_database.h" |
| 22 #include "chrome/browser/password_manager/password_store_change.h" | 22 #include "chrome/browser/password_manager/password_store_change.h" |
| 23 #include "chrome/common/notification_service.h" | 23 #include "chrome/common/notification_service.h" |
| 24 | 24 |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 SecKeychainItemRef new_item = NULL; | 558 SecKeychainItemRef new_item = NULL; |
| 559 OSStatus result = keychain_->AddInternetPassword( | 559 OSStatus result = keychain_->AddInternetPassword( |
| 560 NULL, server.size(), server.c_str(), | 560 NULL, server.size(), server.c_str(), |
| 561 security_domain.size(), security_domain.c_str(), | 561 security_domain.size(), security_domain.c_str(), |
| 562 username.size(), username.c_str(), | 562 username.size(), username.c_str(), |
| 563 path.size(), path.c_str(), | 563 path.size(), path.c_str(), |
| 564 port, protocol, AuthTypeForScheme(form.scheme), | 564 port, protocol, AuthTypeForScheme(form.scheme), |
| 565 password.size(), password.c_str(), &new_item); | 565 password.size(), password.c_str(), &new_item); |
| 566 | 566 |
| 567 if (result == noErr) { | 567 if (result == noErr) { |
| 568 SetKeychainItemCreatorCode(new_item, mac_util::CreatorCodeForApplication()); | 568 SetKeychainItemCreatorCode(new_item, |
| 569 base::mac::CreatorCodeForApplication()); |
| 569 keychain_->Free(new_item); | 570 keychain_->Free(new_item); |
| 570 } else if (result == errSecDuplicateItem) { | 571 } else if (result == errSecDuplicateItem) { |
| 571 // If we collide with an existing item, find and update it instead. | 572 // If we collide with an existing item, find and update it instead. |
| 572 SecKeychainItemRef existing_item = KeychainItemForForm(form); | 573 SecKeychainItemRef existing_item = KeychainItemForForm(form); |
| 573 if (!existing_item) { | 574 if (!existing_item) { |
| 574 return false; | 575 return false; |
| 575 } | 576 } |
| 576 bool changed = SetKeychainItemPassword(existing_item, password); | 577 bool changed = SetKeychainItemPassword(existing_item, password); |
| 577 keychain_->Free(existing_item); | 578 keychain_->Free(existing_item); |
| 578 return changed; | 579 return changed; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 const SecKeychainItemRef& keychain_item, OSType creator_code) { | 716 const SecKeychainItemRef& keychain_item, OSType creator_code) { |
| 716 SecKeychainAttribute attr = { kSecCreatorItemAttr, sizeof(creator_code), | 717 SecKeychainAttribute attr = { kSecCreatorItemAttr, sizeof(creator_code), |
| 717 &creator_code }; | 718 &creator_code }; |
| 718 SecKeychainAttributeList attrList = { 1, &attr }; | 719 SecKeychainAttributeList attrList = { 1, &attr }; |
| 719 OSStatus result = keychain_->ItemModifyAttributesAndData(keychain_item, | 720 OSStatus result = keychain_->ItemModifyAttributesAndData(keychain_item, |
| 720 &attrList, 0, NULL); | 721 &attrList, 0, NULL); |
| 721 return result == noErr; | 722 return result == noErr; |
| 722 } | 723 } |
| 723 | 724 |
| 724 OSType MacKeychainPasswordFormAdapter::CreatorCodeForSearch() { | 725 OSType MacKeychainPasswordFormAdapter::CreatorCodeForSearch() { |
| 725 return finds_only_owned_ ? mac_util::CreatorCodeForApplication() : 0; | 726 return finds_only_owned_ ? base::mac::CreatorCodeForApplication() : 0; |
| 726 } | 727 } |
| 727 | 728 |
| 728 #pragma mark - | 729 #pragma mark - |
| 729 | 730 |
| 730 PasswordStoreMac::PasswordStoreMac(MacKeychain* keychain, | 731 PasswordStoreMac::PasswordStoreMac(MacKeychain* keychain, |
| 731 LoginDatabase* login_db) | 732 LoginDatabase* login_db) |
| 732 : keychain_(keychain), login_metadata_db_(login_db) { | 733 : keychain_(keychain), login_metadata_db_(login_db) { |
| 733 DCHECK(keychain_.get()); | 734 DCHECK(keychain_.get()); |
| 734 DCHECK(login_metadata_db_.get()); | 735 DCHECK(login_metadata_db_.get()); |
| 735 } | 736 } |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); | 1004 owned_keychain_adapter.SetFindsOnlyOwnedItems(true); |
| 1004 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); | 1005 for (std::vector<PasswordForm*>::const_iterator i = forms.begin(); |
| 1005 i != forms.end(); ++i) { | 1006 i != forms.end(); ++i) { |
| 1006 owned_keychain_adapter.RemovePassword(**i); | 1007 owned_keychain_adapter.RemovePassword(**i); |
| 1007 } | 1008 } |
| 1008 } | 1009 } |
| 1009 | 1010 |
| 1010 void PasswordStoreMac::CreateNotificationService() { | 1011 void PasswordStoreMac::CreateNotificationService() { |
| 1011 notification_service_.reset(new NotificationService); | 1012 notification_service_.reset(new NotificationService); |
| 1012 } | 1013 } |
| OLD | NEW |