| 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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_editor.h" | 10 #include "chrome/browser/bookmarks/bookmark_editor.h" |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 showFolderMenus_ = NO; | 530 showFolderMenus_ = NO; |
| 531 [self closeAllBookmarkFolders]; | 531 [self closeAllBookmarkFolders]; |
| 532 } | 532 } |
| 533 | 533 |
| 534 - (BOOL)canEditBookmarks { | 534 - (BOOL)canEditBookmarks { |
| 535 PrefService* prefs = browser_->profile()->GetPrefs(); | 535 PrefService* prefs = browser_->profile()->GetPrefs(); |
| 536 return prefs->GetBoolean(prefs::kEditBookmarksEnabled); | 536 return prefs->GetBoolean(prefs::kEditBookmarksEnabled); |
| 537 } | 537 } |
| 538 | 538 |
| 539 - (BOOL)canEditBookmark:(const BookmarkNode*)node { | 539 - (BOOL)canEditBookmark:(const BookmarkNode*)node { |
| 540 // Don't allow edit/delete of the bar node, or of "Other Bookmarks" | 540 // Don't allow edit/delete of the permanent nodes. |
| 541 if (node == nil || | 541 if (node == nil || bookmarkModel_->is_permanent_node(node)) |
| 542 node == bookmarkModel_->bookmark_bar_node() || | |
| 543 node == bookmarkModel_->other_node() || | |
| 544 node == bookmarkModel_->synced_node()) | |
| 545 return NO; | 542 return NO; |
| 546 return YES; | 543 return YES; |
| 547 } | 544 } |
| 548 | 545 |
| 549 #pragma mark Actions | 546 #pragma mark Actions |
| 550 | 547 |
| 551 // Helper methods called on the main thread by runMenuFlashThread. | 548 // Helper methods called on the main thread by runMenuFlashThread. |
| 552 | 549 |
| 553 - (void)setButtonFlashStateOn:(id)sender { | 550 - (void)setButtonFlashStateOn:(id)sender { |
| 554 [sender highlight:YES]; | 551 [sender highlight:YES]; |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 - (IBAction)addFolder:(id)sender { | 789 - (IBAction)addFolder:(id)sender { |
| 793 const BookmarkNode* senderNode = [self nodeFromMenuItem:sender]; | 790 const BookmarkNode* senderNode = [self nodeFromMenuItem:sender]; |
| 794 const BookmarkNode* parent = NULL; | 791 const BookmarkNode* parent = NULL; |
| 795 int newIndex = 0; | 792 int newIndex = 0; |
| 796 // If triggered from the bar, folder or "others" folder - add as a child to | 793 // If triggered from the bar, folder or "others" folder - add as a child to |
| 797 // the end. | 794 // the end. |
| 798 // If triggered from a bookmark, add as next sibling. | 795 // If triggered from a bookmark, add as next sibling. |
| 799 BookmarkNode::Type type = senderNode->type(); | 796 BookmarkNode::Type type = senderNode->type(); |
| 800 if (type == BookmarkNode::BOOKMARK_BAR || | 797 if (type == BookmarkNode::BOOKMARK_BAR || |
| 801 type == BookmarkNode::OTHER_NODE || | 798 type == BookmarkNode::OTHER_NODE || |
| 802 type == BookmarkNode::SYNCED || | 799 type == BookmarkNode::MOBILE || |
| 803 type == BookmarkNode::FOLDER) { | 800 type == BookmarkNode::FOLDER) { |
| 804 parent = senderNode; | 801 parent = senderNode; |
| 805 newIndex = parent->child_count(); | 802 newIndex = parent->child_count(); |
| 806 } else { | 803 } else { |
| 807 parent = senderNode->parent(); | 804 parent = senderNode->parent(); |
| 808 newIndex = parent->GetIndexOf(senderNode) + 1; | 805 newIndex = parent->GetIndexOf(senderNode) + 1; |
| 809 } | 806 } |
| 810 BookmarkNameFolderController* controller = | 807 BookmarkNameFolderController* controller = |
| 811 [[BookmarkNameFolderController alloc] | 808 [[BookmarkNameFolderController alloc] |
| 812 initWithParentWindow:[[self view] window] | 809 initWithParentWindow:[[self view] window] |
| (...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2779 // to minimize touching the object passed in (likely a mock). | 2776 // to minimize touching the object passed in (likely a mock). |
| 2780 - (void)setButtonContextMenu:(id)menu { | 2777 - (void)setButtonContextMenu:(id)menu { |
| 2781 buttonContextMenu_ = menu; | 2778 buttonContextMenu_ = menu; |
| 2782 } | 2779 } |
| 2783 | 2780 |
| 2784 - (void)setIgnoreAnimations:(BOOL)ignore { | 2781 - (void)setIgnoreAnimations:(BOOL)ignore { |
| 2785 ignoreAnimations_ = ignore; | 2782 ignoreAnimations_ = ignore; |
| 2786 } | 2783 } |
| 2787 | 2784 |
| 2788 @end | 2785 @end |
| OLD | NEW |