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 #include <stack> | 5 #include <stack> |
6 | 6 |
7 #import "chrome/browser/cocoa/bookmark_editor_base_controller.h" | 7 #import "chrome/browser/cocoa/bookmark_editor_base_controller.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "app/l10n_util_mac.h" | 9 #include "app/l10n_util_mac.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 // If the tree is not showing then we use the original parent. | 325 // If the tree is not showing then we use the original parent. |
326 selectedNode = parentNode_; | 326 selectedNode = parentNode_; |
327 } | 327 } |
328 return selectedNode; | 328 return selectedNode; |
329 } | 329 } |
330 | 330 |
331 - (NSArray*)folderTreeArray { | 331 - (NSArray*)folderTreeArray { |
332 return folderTreeArray_.get(); | 332 return folderTreeArray_.get(); |
333 } | 333 } |
334 | 334 |
335 - (void)setFolderTreeArray:(NSArray*)folderTreeArray { | |
336 folderTreeArray_.reset([folderTreeArray retain]); | |
337 } | |
338 | |
339 - (NSArray*)tableSelectionPaths { | 335 - (NSArray*)tableSelectionPaths { |
340 return tableSelectionPaths_.get(); | 336 return tableSelectionPaths_.get(); |
341 } | 337 } |
342 | 338 |
343 - (void)setTableSelectionPath:(NSIndexPath*)tableSelectionPath { | 339 - (void)setTableSelectionPath:(NSIndexPath*)tableSelectionPath { |
344 [self setTableSelectionPaths:[NSArray arrayWithObject:tableSelectionPath]]; | 340 [self setTableSelectionPaths:[NSArray arrayWithObject:tableSelectionPath]]; |
345 } | 341 } |
346 | 342 |
347 - (void)setTableSelectionPaths:(NSArray*)tableSelectionPaths { | 343 - (void)setTableSelectionPaths:(NSArray*)tableSelectionPaths { |
348 tableSelectionPaths_.reset([tableSelectionPaths retain]); | 344 tableSelectionPaths_.reset([tableSelectionPaths retain]); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 } | 409 } |
414 return childFolders; | 410 return childFolders; |
415 } | 411 } |
416 | 412 |
417 - (void)buildFolderTree { | 413 - (void)buildFolderTree { |
418 // Build up a tree of the current folder configuration. | 414 // Build up a tree of the current folder configuration. |
419 BookmarkModel* model = profile_->GetBookmarkModel(); | 415 BookmarkModel* model = profile_->GetBookmarkModel(); |
420 const BookmarkNode* rootNode = model->root_node(); | 416 const BookmarkNode* rootNode = model->root_node(); |
421 NSMutableArray* baseArray = [self addChildFoldersFromNode:rootNode]; | 417 NSMutableArray* baseArray = [self addChildFoldersFromNode:rootNode]; |
422 DCHECK(baseArray); | 418 DCHECK(baseArray); |
423 [self setFolderTreeArray:baseArray]; | 419 folderTreeArray_.reset([baseArray retain]); |
424 } | 420 } |
425 | 421 |
426 - (void)modelChangedPreserveSelection:(BOOL)preserve { | 422 - (void)modelChangedPreserveSelection:(BOOL)preserve { |
427 const BookmarkNode* selectedNode = [self selectedNode]; | 423 const BookmarkNode* selectedNode = [self selectedNode]; |
428 [self buildFolderTree]; | 424 [self buildFolderTree]; |
429 if (preserve && | 425 if (preserve && |
430 selectedNode && | 426 selectedNode && |
431 configuration_ == BookmarkEditor::SHOW_TREE) | 427 configuration_ == BookmarkEditor::SHOW_TREE) |
432 [self selectNodeInBrowser:selectedNode]; | 428 [self selectNodeInBrowser:selectedNode]; |
433 } | 429 } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 } | 588 } |
593 | 589 |
594 // Implementing isEqual: allows the NSTreeController to preserve the selection | 590 // Implementing isEqual: allows the NSTreeController to preserve the selection |
595 // and open/shut state of outline items when the data changes. | 591 // and open/shut state of outline items when the data changes. |
596 - (BOOL)isEqual:(id)other { | 592 - (BOOL)isEqual:(id)other { |
597 return [other isKindOfClass:[BookmarkFolderInfo class]] && | 593 return [other isKindOfClass:[BookmarkFolderInfo class]] && |
598 folderNode_ == [(BookmarkFolderInfo*)other folderNode]; | 594 folderNode_ == [(BookmarkFolderInfo*)other folderNode]; |
599 } | 595 } |
600 | 596 |
601 @end | 597 @end |
OLD | NEW |