| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| 11 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
| 12 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_all_tabs_controller.h" | 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_all_tabs_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_cell_single_line.h" |
| 16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" | 17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" |
| 17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_tree_browser_cell.h" | 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_tree_browser_cell.h" |
| 18 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 19 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "ui/base/l10n/l10n_util_mac.h" | 22 #include "ui/base/l10n/l10n_util_mac.h" |
| 22 | 23 |
| 23 @interface BookmarkEditorBaseController () | 24 @interface BookmarkEditorBaseController () |
| 24 | 25 |
| 25 // Return the folder tree object for the given path. | 26 // Return the folder tree object for the given path. |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 [self didChangeValueForKey:@"folderTreeArray"]; | 558 [self didChangeValueForKey:@"folderTreeArray"]; |
| 558 | 559 |
| 559 // Expose the parent folder children. | 560 // Expose the parent folder children. |
| 560 [folderTreeView_ expandItem:parentInfo]; | 561 [folderTreeView_ expandItem:parentInfo]; |
| 561 | 562 |
| 562 // Select the new folder node and put the folder name into edit mode. | 563 // Select the new folder node and put the folder name into edit mode. |
| 563 selection = [selection indexPathByAddingIndex:[children count] - 1]; | 564 selection = [selection indexPathByAddingIndex:[children count] - 1]; |
| 564 [self setTableSelectionPath:selection]; | 565 [self setTableSelectionPath:selection]; |
| 565 NSInteger row = [folderTreeView_ selectedRow]; | 566 NSInteger row = [folderTreeView_ selectedRow]; |
| 566 DCHECK(row >= 0); | 567 DCHECK(row >= 0); |
| 568 |
| 569 // Put the cell into single-line mode before putting it into edit mode. |
| 570 NSCell* folderCell = [folderTreeView_ preparedCellAtColumn:0 row:row]; |
| 571 if ([folderCell |
| 572 respondsToSelector:@selector(setUsesSingleLineMode:)]) { |
| 573 [folderCell setUsesSingleLineMode:YES]; |
| 574 } |
| 575 |
| 567 [folderTreeView_ editColumn:0 row:row withEvent:nil select:YES]; | 576 [folderTreeView_ editColumn:0 row:row withEvent:nil select:YES]; |
| 568 } | 577 } |
| 569 } | 578 } |
| 570 | 579 |
| 571 - (void)createNewFolders { | 580 - (void)createNewFolders { |
| 572 AutoReset<BOOL> creatingNewFoldersSetter(&creatingNewFolders_, YES); | 581 AutoReset<BOOL> creatingNewFoldersSetter(&creatingNewFolders_, YES); |
| 573 // Scan the tree looking for nodes marked 'newFolder' and create those nodes. | 582 // Scan the tree looking for nodes marked 'newFolder' and create those nodes. |
| 574 NSArray* folderTreeArray = [self folderTreeArray]; | 583 NSArray* folderTreeArray = [self folderTreeArray]; |
| 575 for (BookmarkFolderInfo *folderInfo in folderTreeArray) { | 584 for (BookmarkFolderInfo *folderInfo in folderTreeArray) { |
| 576 [self createNewFoldersForFolder:folderInfo | 585 [self createNewFoldersForFolder:folderInfo |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 } | 658 } |
| 650 | 659 |
| 651 // Implementing isEqual: allows the NSTreeController to preserve the selection | 660 // Implementing isEqual: allows the NSTreeController to preserve the selection |
| 652 // and open/shut state of outline items when the data changes. | 661 // and open/shut state of outline items when the data changes. |
| 653 - (BOOL)isEqual:(id)other { | 662 - (BOOL)isEqual:(id)other { |
| 654 return [other isKindOfClass:[BookmarkFolderInfo class]] && | 663 return [other isKindOfClass:[BookmarkFolderInfo class]] && |
| 655 folderNode_ == [(BookmarkFolderInfo*)other folderNode]; | 664 folderNode_ == [(BookmarkFolderInfo*)other folderNode]; |
| 656 } | 665 } |
| 657 | 666 |
| 658 @end | 667 @end |
| OLD | NEW |