summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/cocoa/cookie_tree_node.h4
-rw-r--r--chrome/browser/cocoa/cookie_tree_node.mm22
-rw-r--r--chrome/browser/cocoa/cookies_window_controller.mm7
-rw-r--r--chrome/browser/cocoa/cookies_window_controller_unittest.mm2
4 files changed, 23 insertions, 12 deletions
diff --git a/chrome/browser/cocoa/cookie_tree_node.h b/chrome/browser/cocoa/cookie_tree_node.h
index 5ff6695..1f161d5 100644
--- a/chrome/browser/cocoa/cookie_tree_node.h
+++ b/chrome/browser/cocoa/cookie_tree_node.h
@@ -12,6 +12,8 @@
@interface CocoaCookieTreeNode : NSObject {
scoped_nsobject<NSString> title_;
scoped_nsobject<NSMutableArray> children_;
+ // We lazily create children, so we need to know if we are a leaf.
+ BOOL isLeaf_;
// The platform-independent model node.
CookieTreeNode* treeNode_; // weak
@@ -39,7 +41,7 @@
// Getters.
- (NSString*)title;
// |-children| is mutable so that the CookiesTreeModelObserverBridge can
-// operate on the children.
+// operate on the children. Note that this lazily creates children.
- (NSMutableArray*)children;
- (TreeModelNode*)treeNode;
diff --git a/chrome/browser/cocoa/cookie_tree_node.mm b/chrome/browser/cocoa/cookie_tree_node.mm
index 00ef5bc..53b7bab 100644
--- a/chrome/browser/cocoa/cookie_tree_node.mm
+++ b/chrome/browser/cocoa/cookie_tree_node.mm
@@ -15,15 +15,7 @@
if ((self = [super init])) {
DCHECK(node);
treeNode_ = node;
-
- const int childCount = node->GetChildCount();
- children_.reset([[NSMutableArray alloc] initWithCapacity:childCount]);
- for (int i = 0; i < childCount; ++i) {
- CookieTreeNode* child = node->GetChild(i);
- scoped_nsobject<CocoaCookieTreeNode> childNode(
- [[CocoaCookieTreeNode alloc] initWithNode:child]);
- [children_ addObject:childNode.get()];
- }
+ isLeaf_ = (node->GetChildCount() == 0);
[self rebuild];
}
@@ -67,7 +59,7 @@
}
- (BOOL)isLeaf {
- return ([children_ count] == 0);
+ return isLeaf_;
}
- (NSString*)title {
@@ -75,6 +67,16 @@
}
- (NSMutableArray*)children {
+ if (!children_.get()) {
+ const int childCount = treeNode_->GetChildCount();
+ children_.reset([[NSMutableArray alloc] initWithCapacity:childCount]);
+ for (int i = 0; i < childCount; ++i) {
+ CookieTreeNode* child = treeNode_->GetChild(i);
+ scoped_nsobject<CocoaCookieTreeNode> childNode(
+ [[CocoaCookieTreeNode alloc] initWithNode:child]);
+ [children_ addObject:childNode.get()];
+ }
+ }
return children_.get();
}
diff --git a/chrome/browser/cocoa/cookies_window_controller.mm b/chrome/browser/cocoa/cookies_window_controller.mm
index c997537..9ac09b7 100644
--- a/chrome/browser/cocoa/cookies_window_controller.mm
+++ b/chrome/browser/cocoa/cookies_window_controller.mm
@@ -306,6 +306,13 @@ bool CookiesTreeModelObserverBridge::HasCocoaModel() {
children = [item childNodes];
DCHECK_EQ([children count], 1U);
[outlineView expandItem:[children lastObject]];
+ // Select the first node in that child set.
+ NSTreeNode* folderChild = [children lastObject];
+ if ([[folderChild childNodes] count] > 0) {
+ NSTreeNode* firstCookieChild =
+ [[folderChild childNodes] objectAtIndex:0];
+ [treeController_ setSelectionIndexPath:[firstCookieChild indexPath]];
+ }
}
}
}
diff --git a/chrome/browser/cocoa/cookies_window_controller_unittest.mm b/chrome/browser/cocoa/cookies_window_controller_unittest.mm
index d3a729c..f1f9e1a 100644
--- a/chrome/browser/cocoa/cookies_window_controller_unittest.mm
+++ b/chrome/browser/cocoa/cookies_window_controller_unittest.mm
@@ -54,7 +54,7 @@
@end
@implementation CocoaCookieTreeNode (UglyHacks)
- (NSMutableArray*)childs {
- return children_.get();
+ return (NSMutableArray*)[self children];
}
@end