OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stack> | 5 #include <stack> |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_base_controller.h" | 7 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_base_controller.h" |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 releaseBarVisibilityForOwner:self withAnimation:YES delay:NO]; | 335 releaseBarVisibilityForOwner:self withAnimation:YES delay:NO]; |
336 } | 336 } |
337 | 337 |
338 - (void)windowWillClose:(NSNotification*)notification { | 338 - (void)windowWillClose:(NSNotification*)notification { |
339 [self autorelease]; | 339 [self autorelease]; |
340 } | 340 } |
341 | 341 |
342 #pragma mark Folder Tree Management | 342 #pragma mark Folder Tree Management |
343 | 343 |
344 - (BookmarkModel*)bookmarkModel { | 344 - (BookmarkModel*)bookmarkModel { |
345 return BookmarkModelFactory::GetForProfile(profile_); | 345 return BookmarkModelFactory::GetForBrowserContext(profile_); |
346 } | 346 } |
347 | 347 |
348 - (Profile*)profile { | 348 - (Profile*)profile { |
349 return profile_; | 349 return profile_; |
350 } | 350 } |
351 | 351 |
352 - (const BookmarkNode*)parentNode { | 352 - (const BookmarkNode*)parentNode { |
353 return parentNode_; | 353 return parentNode_; |
354 } | 354 } |
355 | 355 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 [self willChangeValueForKey:kOkEnabledName]; | 474 [self willChangeValueForKey:kOkEnabledName]; |
475 [self setTableSelectionPath:selectionPath]; | 475 [self setTableSelectionPath:selectionPath]; |
476 [self didChangeValueForKey:kOkEnabledName]; | 476 [self didChangeValueForKey:kOkEnabledName]; |
477 } | 477 } |
478 | 478 |
479 - (NSIndexPath*)selectionPathForNode:(const BookmarkNode*)desiredNode { | 479 - (NSIndexPath*)selectionPathForNode:(const BookmarkNode*)desiredNode { |
480 // Back up the parent chain for desiredNode, building up a stack | 480 // Back up the parent chain for desiredNode, building up a stack |
481 // of ancestor nodes. Then crawl down the folderTreeArray looking | 481 // of ancestor nodes. Then crawl down the folderTreeArray looking |
482 // for each ancestor in order while building up the selectionPath. | 482 // for each ancestor in order while building up the selectionPath. |
483 std::stack<const BookmarkNode*> nodeStack; | 483 std::stack<const BookmarkNode*> nodeStack; |
484 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_); | 484 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile_); |
485 const BookmarkNode* rootNode = model->root_node(); | 485 const BookmarkNode* rootNode = model->root_node(); |
486 const BookmarkNode* node = desiredNode; | 486 const BookmarkNode* node = desiredNode; |
487 while (node != rootNode) { | 487 while (node != rootNode) { |
488 DCHECK(node); | 488 DCHECK(node); |
489 nodeStack.push(node); | 489 nodeStack.push(node); |
490 node = node->parent(); | 490 node = node->parent(); |
491 } | 491 } |
492 NSUInteger stackSize = nodeStack.size(); | 492 NSUInteger stackSize = nodeStack.size(); |
493 | 493 |
494 NSIndexPath* path = nil; | 494 NSIndexPath* path = nil; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 childFolders = [NSMutableArray arrayWithObject:folderInfo]; | 532 childFolders = [NSMutableArray arrayWithObject:folderInfo]; |
533 else | 533 else |
534 [childFolders addObject:folderInfo]; | 534 [childFolders addObject:folderInfo]; |
535 } | 535 } |
536 } | 536 } |
537 return childFolders; | 537 return childFolders; |
538 } | 538 } |
539 | 539 |
540 - (void)buildFolderTree { | 540 - (void)buildFolderTree { |
541 // Build up a tree of the current folder configuration. | 541 // Build up a tree of the current folder configuration. |
542 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile_); | 542 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile_); |
543 const BookmarkNode* rootNode = model->root_node(); | 543 const BookmarkNode* rootNode = model->root_node(); |
544 NSMutableArray* baseArray = [self addChildFoldersFromNode:rootNode]; | 544 NSMutableArray* baseArray = [self addChildFoldersFromNode:rootNode]; |
545 DCHECK(baseArray); | 545 DCHECK(baseArray); |
546 [self willChangeValueForKey:@"folderTreeArray"]; | 546 [self willChangeValueForKey:@"folderTreeArray"]; |
547 folderTreeArray_.reset([baseArray retain]); | 547 folderTreeArray_.reset([baseArray retain]); |
548 [self didChangeValueForKey:@"folderTreeArray"]; | 548 [self didChangeValueForKey:@"folderTreeArray"]; |
549 } | 549 } |
550 | 550 |
551 - (void)modelChangedPreserveSelection:(BOOL)preserve { | 551 - (void)modelChangedPreserveSelection:(BOOL)preserve { |
552 if (creatingNewFolders_) | 552 if (creatingNewFolders_) |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 [super dealloc]; | 727 [super dealloc]; |
728 } | 728 } |
729 | 729 |
730 // Implementing isEqual: allows the NSTreeController to preserve the selection | 730 // Implementing isEqual: allows the NSTreeController to preserve the selection |
731 // and open/shut state of outline items when the data changes. | 731 // and open/shut state of outline items when the data changes. |
732 - (BOOL)isEqual:(id)other { | 732 - (BOOL)isEqual:(id)other { |
733 return [other isKindOfClass:[BookmarkFolderInfo class]] && | 733 return [other isKindOfClass:[BookmarkFolderInfo class]] && |
734 folderNode_ == [(BookmarkFolderInfo*)other folderNode]; | 734 folderNode_ == [(BookmarkFolderInfo*)other folderNode]; |
735 } | 735 } |
736 @end | 736 @end |
OLD | NEW |