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

Side by Side Diff: chrome/browser/cocoa/bookmark_tree_controller.mm

Issue 555169: Merge 37521 - Mac bookmark manager: Crash after deleting folder in left pane... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/307/src/
Patch Set: Created 10 years, 10 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 | Annotate | Revision Log
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 #import "chrome/browser/cocoa/bookmark_tree_controller.h" 5 #import "chrome/browser/cocoa/bookmark_tree_controller.h"
6 6
7 #include "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #import "chrome/browser/cocoa/bookmark_item.h" 9 #import "chrome/browser/cocoa/bookmark_item.h"
10 #import "chrome/browser/cocoa/bookmark_manager_controller.h" 10 #import "chrome/browser/cocoa/bookmark_manager_controller.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 } 242 }
243 243
244 - (IBAction)editTitle:(id)sender { 244 - (IBAction)editTitle:(id)sender {
245 NSArray* items = [self actionItems]; 245 NSArray* items = [self actionItems];
246 if ([items count] == 1) 246 if ([items count] == 1)
247 [self editTitleOfItem:[items objectAtIndex:0]]; 247 [self editTitleOfItem:[items objectAtIndex:0]];
248 else 248 else
249 NSBeep(); 249 NSBeep();
250 } 250 }
251 251
252 - (IBAction)newFolder:(id)sender { 252 - (BookmarkItem*)newFolderWithTitle:(NSString*)title {
253 BookmarkItem* parent; 253 BookmarkItem* parent;
254 NSUInteger index; 254 NSUInteger index;
255 if (![self getInsertionParent:&parent index:&index]) { 255 if (![self getInsertionParent:&parent index:&index]) {
256 NSBeep(); 256 NSBeep();
257 return; 257 return nil;
258 } 258 }
259 // Create the folder, then select it and make the title editable: 259 // Create the folder, then select it and make the title editable:
260 BookmarkItem* folder = [parent addFolderWithTitle:@"" atIndex:index]; 260 BookmarkItem* folder = [parent addFolderWithTitle:title atIndex:index];
261 [self expandItem:folder]; 261 [self revealItem:folder];
262 [self editTitleOfItem:folder]; 262 return folder;
263 }
264
265 - (IBAction)newFolder:(id)sender {
266 BookmarkItem* folder = [self newFolderWithTitle:@""];
267 if (folder)
268 [self editTitleOfItem:folder];
263 } 269 }
264 270
265 - (IBAction)revealSelectedItem:(id)sender { 271 - (IBAction)revealSelectedItem:(id)sender {
266 NSArray* selItems = [self actionItems]; 272 NSArray* selItems = [self actionItems];
267 if ([selItems count] != 1 || 273 if ([selItems count] != 1 ||
268 ![manager_ revealItem:[selItems objectAtIndex:0]]) 274 ![manager_ revealItem:[selItems objectAtIndex:0]])
269 NSBeep(); 275 NSBeep();
270 [[outline_ window] makeFirstResponder:outline_]; 276 [[outline_ window] makeFirstResponder:outline_];
271 } 277 }
272 278
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 457
452 // Show special folders (Bookmarks Bar, Others, Recents, Search) in bold. 458 // Show special folders (Bookmarks Bar, Others, Recents, Search) in bold.
453 static NSFont* sBoldFont = [[NSFont boldSystemFontOfSize: 459 static NSFont* sBoldFont = [[NSFont boldSystemFontOfSize:
454 [NSFont smallSystemFontSize]] retain]; 460 [NSFont smallSystemFontSize]] retain];
455 static NSFont* sPlainFont = [[NSFont systemFontOfSize: 461 static NSFont* sPlainFont = [[NSFont systemFontOfSize:
456 [NSFont smallSystemFontSize]] retain]; 462 [NSFont smallSystemFontSize]] retain];
457 [cell setFont:[item isFixed] ? sBoldFont : sPlainFont]; 463 [cell setFont:[item isFixed] ? sBoldFont : sPlainFont];
458 } 464 }
459 465
460 // Updates the tree after the data model has changed. 466 // Updates the tree after the data model has changed.
461 - (void)itemChanged:(id)nodeItem childrenChanged:(BOOL)childrenChanged { 467 - (void)itemChanged:(BookmarkItem*)nodeItem
468 childrenChanged:(BOOL)childrenChanged {
462 if (nodeItem == group_) 469 if (nodeItem == group_)
463 nodeItem = nil; 470 nodeItem = nil;
464 NSArray* sel = [self selectedItems]; 471 NSArray* sel = [self selectedItems];
465 [outline_ reloadItem:nodeItem reloadChildren:childrenChanged]; 472 [outline_ reloadItem:nodeItem reloadChildren:childrenChanged];
466 [self setSelectedItems:sel]; 473 [self setSelectedItems:sel];
467 } 474 }
468 475
469 @end 476 @end
470 477
471 478
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } 530 }
524 } 531 }
525 [super keyDown:event]; 532 [super keyDown:event];
526 } 533 }
527 534
528 - (NSMenu*)menu { 535 - (NSMenu*)menu {
529 return [[self bookmarkController] menu]; 536 return [[self bookmarkController] menu];
530 } 537 }
531 538
532 @end 539 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_tree_controller.h ('k') | chrome/browser/cocoa/bookmark_tree_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698