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

Unified Diff: chrome/browser/password_manager/password_store_mac.cc

Issue 164332: Use real creator code for Keychain items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/importer/importer.cc ('k') | chrome/browser/password_manager/password_store_mac_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/password_manager/password_store_mac.cc
===================================================================
--- chrome/browser/password_manager/password_store_mac.cc (revision 23061)
+++ chrome/browser/password_manager/password_store_mac.cc (working copy)
@@ -10,6 +10,7 @@
#include <vector>
#include "base/logging.h"
+#include "base/mac_util.h"
#include "base/stl_util-inl.h"
#include "base/string_util.h"
#include "chrome/browser/keychain_mac.h"
@@ -17,8 +18,6 @@
using webkit_glue::PasswordForm;
-static const OSType kChromeKeychainCreatorCode = 'rimZ';
-
// Utility class to handle the details of constructing and running a keychain
// search from a set of attributes.
class KeychainSearch {
@@ -438,7 +437,7 @@
std::vector<PasswordForm*> GetPasswordsForForms(
const MacKeychain& keychain, std::vector<PasswordForm*>* database_forms) {
MacKeychainPasswordFormAdapter keychain_adapter(&keychain);
-
+
std::vector<PasswordForm*> merged_forms;
for (std::vector<PasswordForm*>::iterator i = database_forms->begin();
i != database_forms->end();) {
@@ -507,13 +506,12 @@
kSecAuthenticationTypeHTTPBasic,
kSecAuthenticationTypeHTTPDigest,
};
- OSType creator = finds_only_owned_ ? kChromeKeychainCreatorCode : 0;
std::vector<SecKeychainItemRef> matches;
for (unsigned int i = 0; i < arraysize(supported_auth_types); ++i) {
KeychainSearch keychain_search(*keychain_);
keychain_search.Init(NULL, 0, kSecProtocolTypeAny, supported_auth_types[i],
- NULL, NULL, NULL, creator);
+ NULL, NULL, NULL, CreatorCodeForSearch());
keychain_search.FindMatchingItems(&matches);
}
@@ -547,7 +545,7 @@
password.size(), password.c_str(), &new_item);
if (result == noErr) {
- SetKeychainItemCreatorCode(new_item, kChromeKeychainCreatorCode);
+ SetKeychainItemCreatorCode(new_item, mac_util::CreatorCodeForApplication());
keychain_->Free(new_item);
} else if (result == errSecDuplicateItem) {
// If we collide with an existing item, find and update it instead.
@@ -641,11 +639,9 @@
SecAuthenticationType auth_type = AuthTypeForScheme(scheme);
const char* auth_domain = (scheme == PasswordForm::SCHEME_HTML) ?
NULL : security_domain.c_str();
- OSType creator = finds_only_owned_ ? kChromeKeychainCreatorCode : 0;
-
KeychainSearch keychain_search(*keychain_);
keychain_search.Init(server.c_str(), port, protocol, auth_type,
- auth_domain, path, username, creator);
+ auth_domain, path, username, CreatorCodeForSearch());
keychain_search.FindMatchingItems(&matches);
return matches;
}
@@ -705,6 +701,10 @@
return result == noErr;
}
+OSType MacKeychainPasswordFormAdapter::CreatorCodeForSearch() {
+ return finds_only_owned_ ? mac_util::CreatorCodeForApplication() : 0;
+}
+
#pragma mark -
PasswordStoreMac::PasswordStoreMac(MacKeychain* keychain,
@@ -813,15 +813,15 @@
void PasswordStoreMac::GetAutofillableLoginsImpl(GetLoginsRequest* request) {
std::vector<PasswordForm*> database_forms;
login_metadata_db_->GetAutofillableLogins(&database_forms);
-
+
std::vector<PasswordForm*> merged_forms =
internal_keychain_helpers::GetPasswordsForForms(*keychain_,
&database_forms);
-
+
// Clean up any orphaned database entries.
RemoveDatabaseForms(database_forms);
STLDeleteElements(&database_forms);
-
+
NotifyConsumer(request, merged_forms);
}
@@ -853,12 +853,12 @@
std::vector<PasswordForm*> PasswordStoreMac::GetUnusedKeychainForms() {
std::vector<PasswordForm*> database_forms;
login_metadata_db_->GetAutofillableLogins(&database_forms);
-
+
MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_.get());
owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
std::vector<PasswordForm*> owned_keychain_forms =
owned_keychain_adapter.GetAllPasswordFormPasswords();
-
+
// Run a merge; anything left in owned_keychain_forms when we are done no
// longer has a matching database entry.
std::vector<PasswordForm*> merged_forms;
« no previous file with comments | « chrome/browser/importer/importer.cc ('k') | chrome/browser/password_manager/password_store_mac_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698