summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/cookies_window_controller.mm
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-16 01:35:30 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-16 01:35:30 +0000
commitfa08ac4a4f068b054a2048d53c5b2c4b4431eb5b (patch)
treeb0da7e9dacbd2e49e0bf4930de033ae827ac1991 /chrome/browser/cocoa/cookies_window_controller.mm
parent214be467093e9455fb23dafb862cc1476daa5426 (diff)
downloadchromium_src-fa08ac4a4f068b054a2048d53c5b2c4b4431eb5b.zip
chromium_src-fa08ac4a4f068b054a2048d53c5b2c4b4431eb5b.tar.gz
chromium_src-fa08ac4a4f068b054a2048d53c5b2c4b4431eb5b.tar.bz2
[Mac] Fix beta-blocking bugs in the cookies manager
* Auto-expand the Cookies folder after expanding a domain-level folder * XIB change: disable multiple selection (and removal) of cookies to prevent a crash * Auto-select the next cookie after deletion BUG=31678,32002,32022 TEST=Open cookies manager. Expand a domain and Cookies folder should auto-expand. TEST=Open cookies manager. Should not be able to perform multiple selection or deletion. TEST=Open cookies manager. Expand domain with multiple cookies. Delete the first cookie. Second cookie should now be selected. Review URL: http://codereview.chromium.org/542091 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36443 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/cookies_window_controller.mm')
-rw-r--r--chrome/browser/cocoa/cookies_window_controller.mm32
1 files changed, 29 insertions, 3 deletions
diff --git a/chrome/browser/cocoa/cookies_window_controller.mm b/chrome/browser/cocoa/cookies_window_controller.mm
index 41ba73f..25d4120 100644
--- a/chrome/browser/cocoa/cookies_window_controller.mm
+++ b/chrome/browser/cocoa/cookies_window_controller.mm
@@ -184,11 +184,19 @@ CocoaCookieTreeNode* CookiesTreeModelObserverBridge::FindCocoaNode(
}
- (IBAction)deleteCookie:(id)sender {
- scoped_nsobject<NSArray> selection(
- [[treeController_ selectedObjects] retain]);
- for (CocoaCookieTreeNode* node in selection.get()) {
+ NSIndexPath* selectionPath = [treeController_ selectionIndexPath];
+ // N.B.: I suspect that |-selectedObjects| does not retain/autorelease the
+ // return value, which may result in the pointer going to garbage before it
+ // even goes out of scope. Retaining it immediately will fix this.
+ NSArray* selection = [treeController_ selectedObjects];
+ if (selectionPath) {
+ DCHECK_EQ([selection count], 1U);
+ CocoaCookieTreeNode* node = [selection lastObject];
CookieTreeNode* cookie = static_cast<CookieTreeNode*>([node treeNode]);
treeModel_->DeleteCookieNode(cookie);
+ // If there is a next cookie, this will select it because items will slide
+ // up. If there is no next cookie, this is a no-op.
+ [treeController_ setSelectionIndexPath:selectionPath];
}
}
@@ -229,6 +237,24 @@ CocoaCookieTreeNode* CookiesTreeModelObserverBridge::FindCocoaNode(
[(ImageAndTextCell*)cell setImage:icon];
}
+- (void)outlineViewItemDidExpand:(NSNotification*)notif {
+ NSTreeNode* item = [[notif userInfo] objectForKey:@"NSObject"];
+ CocoaCookieTreeNode* node = [item representedObject];
+ NSArray* children = [node children];
+ if ([children count] == 1U) {
+ // The node that will expand has one child. Do the user a favor and expand
+ // that node (saving her a click) if it is non-leaf.
+ CocoaCookieTreeNode* child = [children lastObject];
+ if (![child isLeaf]) {
+ NSOutlineView* outlineView = [notif object];
+ // Tell the OutlineView to expand the NSTreeNode, not the model object.
+ children = [item childNodes];
+ DCHECK_EQ([children count], 1U);
+ [outlineView expandItem:[children lastObject]];
+ }
+ }
+}
+
#pragma mark Unit Testing
- (CookiesTreeModelObserverBridge*)modelObserver {