| 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 #import "chrome/browser/cocoa/cookies_window_controller.h" | 5 #import "chrome/browser/cocoa/cookies_window_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "app/l10n_util_mac.h" | 9 #include "app/l10n_util_mac.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 if ([children count] == 1U) { | 299 if ([children count] == 1U) { |
| 300 // The node that will expand has one child. Do the user a favor and expand | 300 // The node that will expand has one child. Do the user a favor and expand |
| 301 // that node (saving her a click) if it is non-leaf. | 301 // that node (saving her a click) if it is non-leaf. |
| 302 CocoaCookieTreeNode* child = [children lastObject]; | 302 CocoaCookieTreeNode* child = [children lastObject]; |
| 303 if (![child isLeaf]) { | 303 if (![child isLeaf]) { |
| 304 NSOutlineView* outlineView = [notif object]; | 304 NSOutlineView* outlineView = [notif object]; |
| 305 // Tell the OutlineView to expand the NSTreeNode, not the model object. | 305 // Tell the OutlineView to expand the NSTreeNode, not the model object. |
| 306 children = [item childNodes]; | 306 children = [item childNodes]; |
| 307 DCHECK_EQ([children count], 1U); | 307 DCHECK_EQ([children count], 1U); |
| 308 [outlineView expandItem:[children lastObject]]; | 308 [outlineView expandItem:[children lastObject]]; |
| 309 // Select the first node in that child set. |
| 310 NSTreeNode* folderChild = [children lastObject]; |
| 311 if ([[folderChild childNodes] count] > 0) { |
| 312 NSTreeNode* firstCookieChild = |
| 313 [[folderChild childNodes] objectAtIndex:0]; |
| 314 [treeController_ setSelectionIndexPath:[firstCookieChild indexPath]]; |
| 315 } |
| 309 } | 316 } |
| 310 } | 317 } |
| 311 } | 318 } |
| 312 | 319 |
| 313 - (void)outlineViewSelectionDidChange:(NSNotification*)notif { | 320 - (void)outlineViewSelectionDidChange:(NSNotification*)notif { |
| 314 // Multi-selection should be disabled in the UI, but for sanity, double-check | 321 // Multi-selection should be disabled in the UI, but for sanity, double-check |
| 315 // that they can't do it here. | 322 // that they can't do it here. |
| 316 NSUInteger count = [[treeController_ selectedObjects] count]; | 323 NSUInteger count = [[treeController_ selectedObjects] count]; |
| 317 if (count != 1U) { | 324 if (count != 1U) { |
| 318 DCHECK_LT(count, 1U) << "User was able to select more than 1 cookie node!"; | 325 DCHECK_LT(count, 1U) << "User was able to select more than 1 cookie node!"; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 [icons_ addObject:rb.GetNSImageNamed(IDR_BOOKMARK_BAR_FOLDER)]; | 378 [icons_ addObject:rb.GetNSImageNamed(IDR_BOOKMARK_BAR_FOLDER)]; |
| 372 | 379 |
| 373 // Create the Cocoa model. | 380 // Create the Cocoa model. |
| 374 CookieTreeNode* root = static_cast<CookieTreeNode*>(treeModel_->GetRoot()); | 381 CookieTreeNode* root = static_cast<CookieTreeNode*>(treeModel_->GetRoot()); |
| 375 scoped_nsobject<CocoaCookieTreeNode> model( | 382 scoped_nsobject<CocoaCookieTreeNode> model( |
| 376 [[CocoaCookieTreeNode alloc] initWithNode:root]); | 383 [[CocoaCookieTreeNode alloc] initWithNode:root]); |
| 377 [self setCocoaTreeModel:model.get()]; // Takes ownership. | 384 [self setCocoaTreeModel:model.get()]; // Takes ownership. |
| 378 } | 385 } |
| 379 | 386 |
| 380 @end | 387 @end |
| OLD | NEW |