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

Side by Side Diff: chrome/browser/keychain_mock_mac.cc

Issue 155451: Support individual Keychain item deletion (Closed)
Patch Set: Created 11 years, 5 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 unified diff | Download patch
OLDNEW
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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/time.h" 6 #include "base/time.h"
7 #include "chrome/browser/keychain_mock_mac.h" 7 #include "chrome/browser/keychain_mock_mac.h"
8 8
9 MockKeychain::MockKeychain(unsigned int item_capacity) 9 MockKeychain::MockKeychain(unsigned int item_capacity)
10 : item_capacity_(item_capacity), item_count_(0), search_copy_count_(0), 10 : item_capacity_(item_capacity), item_count_(0), search_copy_count_(0),
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return noErr; 222 return noErr;
223 } 223 }
224 224
225 OSStatus MockKeychain::ItemFreeAttributesAndData( 225 OSStatus MockKeychain::ItemFreeAttributesAndData(
226 SecKeychainAttributeList *attrList, 226 SecKeychainAttributeList *attrList,
227 void *data) const { 227 void *data) const {
228 --attribute_data_copy_count_; 228 --attribute_data_copy_count_;
229 return noErr; 229 return noErr;
230 } 230 }
231 231
232 OSStatus MockKeychain::ItemDelete(SecKeychainItemRef itemRef) const {
233 unsigned int item_index = reinterpret_cast<unsigned int>(itemRef) - 1;
234 // The mock only supports deleting the last item.
235 if (item_index != item_count_ - 1) {
236 NOTIMPLEMENTED();
237 }
238 --item_count_;
239 return noErr;
240 }
241
232 OSStatus MockKeychain::SearchCreateFromAttributes( 242 OSStatus MockKeychain::SearchCreateFromAttributes(
233 CFTypeRef keychainOrArray, SecItemClass itemClass, 243 CFTypeRef keychainOrArray, SecItemClass itemClass,
234 const SecKeychainAttributeList *attrList, 244 const SecKeychainAttributeList *attrList,
235 SecKeychainSearchRef *searchRef) const { 245 SecKeychainSearchRef *searchRef) const {
236 // Figure out which of our mock items matches, and set up the array we'll use 246 // Figure out which of our mock items matches, and set up the array we'll use
237 // to generate results out of SearchCopyNext. 247 // to generate results out of SearchCopyNext.
238 remaining_search_results_.clear(); 248 remaining_search_results_.clear();
239 for (unsigned int mock_item = 0; mock_item < item_count_; ++mock_item) { 249 for (unsigned int mock_item = 0; mock_item < item_count_; ++mock_item) {
240 bool mock_item_matches = true; 250 bool mock_item_matches = true;
241 for (UInt32 search_attr = 0; search_attr < attrList->count; ++search_attr) { 251 for (UInt32 search_attr = 0; search_attr < attrList->count; ++search_attr) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 SetTestDataProtocol(index, item_data.protocol); 380 SetTestDataProtocol(index, item_data.protocol);
371 SetTestDataString(index, kSecPathItemAttr, item_data.path); 381 SetTestDataString(index, kSecPathItemAttr, item_data.path);
372 SetTestDataPort(index, item_data.port); 382 SetTestDataPort(index, item_data.port);
373 SetTestDataString(index, kSecSecurityDomainItemAttr, 383 SetTestDataString(index, kSecSecurityDomainItemAttr,
374 item_data.security_domain); 384 item_data.security_domain);
375 SetTestDataString(index, kSecCreationDateItemAttr, item_data.creation_date); 385 SetTestDataString(index, kSecCreationDateItemAttr, item_data.creation_date);
376 SetTestDataString(index, kSecAccountItemAttr, item_data.username); 386 SetTestDataString(index, kSecAccountItemAttr, item_data.username);
377 SetTestDataPasswordString(index, item_data.password); 387 SetTestDataPasswordString(index, item_data.password);
378 SetTestDataNegativeItem(index, item_data.negative_item); 388 SetTestDataNegativeItem(index, item_data.negative_item);
379 } 389 }
OLDNEW
« no previous file with comments | « chrome/browser/keychain_mock_mac.h ('k') | chrome/browser/password_manager/password_store_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698