| OLD | NEW |
| 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 #include "app/l10n_util_mac.h" | 5 #include "app/l10n_util_mac.h" |
| 6 #include "app/resource_bundle.h" | 6 #include "app/resource_bundle.h" |
| 7 #include "base/mac_util.h" | 7 #include "base/mac_util.h" |
| 8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_editor.h" | 9 #include "chrome/browser/bookmarks/bookmark_editor.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 11 #include "chrome/browser/browser.h" | 11 #include "chrome/browser/browser.h" |
| 12 #include "chrome/browser/browser_list.h" | 12 #include "chrome/browser/browser_list.h" |
| 13 #import "chrome/browser/cocoa/background_gradient_view.h" | 13 #import "chrome/browser/cocoa/background_gradient_view.h" |
| 14 #import "chrome/browser/cocoa/bookmark_bar_bridge.h" | 14 #import "chrome/browser/cocoa/bookmark_bar_bridge.h" |
| 15 #import "chrome/browser/cocoa/bookmark_bar_constants.h" | 15 #import "chrome/browser/cocoa/bookmark_bar_constants.h" |
| 16 #import "chrome/browser/cocoa/bookmark_bar_controller.h" | 16 #import "chrome/browser/cocoa/bookmark_bar_controller.h" |
| 17 #import "chrome/browser/cocoa/bookmark_bar_toolbar_view.h" | 17 #import "chrome/browser/cocoa/bookmark_bar_toolbar_view.h" |
| 18 #import "chrome/browser/cocoa/bookmark_bar_view.h" | 18 #import "chrome/browser/cocoa/bookmark_bar_view.h" |
| 19 #import "chrome/browser/cocoa/bookmark_button_cell.h" | 19 #import "chrome/browser/cocoa/bookmark_button_cell.h" |
| 20 #import "chrome/browser/cocoa/bookmark_editor_controller.h" | 20 #import "chrome/browser/cocoa/bookmark_editor_controller.h" |
| 21 #import "chrome/browser/cocoa/bookmark_name_folder_controller.h" | 21 #import "chrome/browser/cocoa/bookmark_name_folder_controller.h" |
| 22 #import "chrome/browser/cocoa/bookmark_menu.h" |
| 22 #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h" | 23 #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h" |
| 23 #import "chrome/browser/cocoa/event_utils.h" | 24 #import "chrome/browser/cocoa/event_utils.h" |
| 24 #import "chrome/browser/cocoa/menu_button.h" | 25 #import "chrome/browser/cocoa/menu_button.h" |
| 25 #import "chrome/browser/cocoa/toolbar_controller.h" | 26 #import "chrome/browser/cocoa/toolbar_controller.h" |
| 26 #import "chrome/browser/cocoa/view_resizer.h" | 27 #import "chrome/browser/cocoa/view_resizer.h" |
| 27 #include "chrome/browser/metrics/user_metrics.h" | 28 #include "chrome/browser/metrics/user_metrics.h" |
| 28 #include "chrome/browser/profile.h" | 29 #include "chrome/browser/profile.h" |
| 29 #include "chrome/browser/tab_contents/tab_contents.h" | 30 #include "chrome/browser/tab_contents/tab_contents.h" |
| 30 #include "chrome/browser/tab_contents/tab_contents_view.h" | 31 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 31 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // NSButton ignores them. | 112 // NSButton ignores them. |
| 112 @interface BookmarkButton : NSButton | 113 @interface BookmarkButton : NSButton |
| 113 @end | 114 @end |
| 114 | 115 |
| 115 @implementation BookmarkButton | 116 @implementation BookmarkButton |
| 116 - (void)otherMouseUp:(NSEvent*) event { | 117 - (void)otherMouseUp:(NSEvent*) event { |
| 117 [self performClick:self]; | 118 [self performClick:self]; |
| 118 } | 119 } |
| 119 @end | 120 @end |
| 120 | 121 |
| 122 |
| 121 @interface BookmarkBarController(Private) | 123 @interface BookmarkBarController(Private) |
| 122 // Determines the appropriate state for the given situation. | 124 // Determines the appropriate state for the given situation. |
| 123 + (bookmarks::VisualState)visualStateToShowNormalBar:(BOOL)showNormalBar | 125 + (bookmarks::VisualState)visualStateToShowNormalBar:(BOOL)showNormalBar |
| 124 showDetachedBar:(BOOL)showDetachedBar; | 126 showDetachedBar:(BOOL)showDetachedBar; |
| 125 | 127 |
| 126 // Moves to the given next state (from the current state), possibly animating. | 128 // Moves to the given next state (from the current state), possibly animating. |
| 127 // If |animate| is NO, it will stop any running animation and jump to the given | 129 // If |animate| is NO, it will stop any running animation and jump to the given |
| 128 // state. If YES, it may either (depending on implementation) jump to the end of | 130 // state. If YES, it may either (depending on implementation) jump to the end of |
| 129 // the current animation and begin the next one, or stop the current animation | 131 // the current animation and begin the next one, or stop the current animation |
| 130 // mid-flight and animate to the next state. | 132 // mid-flight and animate to the next state. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 150 - (void)addNode:(const BookmarkNode*)child toMenu:(NSMenu*)menu; | 152 - (void)addNode:(const BookmarkNode*)child toMenu:(NSMenu*)menu; |
| 151 - (void)addFolderNode:(const BookmarkNode*)node toMenu:(NSMenu*)menu; | 153 - (void)addFolderNode:(const BookmarkNode*)node toMenu:(NSMenu*)menu; |
| 152 - (void)tagEmptyMenu:(NSMenu*)menu; | 154 - (void)tagEmptyMenu:(NSMenu*)menu; |
| 153 - (void)clearMenuTagMap; | 155 - (void)clearMenuTagMap; |
| 154 - (int)preferredHeight; | 156 - (int)preferredHeight; |
| 155 - (void)addNonBookmarkButtonsToView; | 157 - (void)addNonBookmarkButtonsToView; |
| 156 - (void)addButtonsToView; | 158 - (void)addButtonsToView; |
| 157 - (void)resizeButtons; | 159 - (void)resizeButtons; |
| 158 - (void)centerNoItemsLabel; | 160 - (void)centerNoItemsLabel; |
| 159 - (NSImage*)getFavIconForNode:(const BookmarkNode*)node; | 161 - (NSImage*)getFavIconForNode:(const BookmarkNode*)node; |
| 162 - (void)setNodeForBarMenu; |
| 160 @end | 163 @end |
| 161 | 164 |
| 162 @implementation BookmarkBarController | 165 @implementation BookmarkBarController |
| 163 | 166 |
| 164 @synthesize visualState = visualState_; | 167 @synthesize visualState = visualState_; |
| 165 @synthesize lastVisualState = lastVisualState_; | 168 @synthesize lastVisualState = lastVisualState_; |
| 166 @synthesize delegate = delegate_; | 169 @synthesize delegate = delegate_; |
| 167 | 170 |
| 168 - (id)initWithBrowser:(Browser*)browser | 171 - (id)initWithBrowser:(Browser*)browser |
| 169 initialWidth:(float)initialWidth | 172 initialWidth:(float)initialWidth |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // We default to NOT open, which means height=0. | 211 // We default to NOT open, which means height=0. |
| 209 DCHECK([[self view] isHidden]); // Hidden so it's OK to change. | 212 DCHECK([[self view] isHidden]); // Hidden so it's OK to change. |
| 210 | 213 |
| 211 // Set our initial height to zero, since that is what the superview | 214 // Set our initial height to zero, since that is what the superview |
| 212 // expects. We will resize ourselves open later if needed. | 215 // expects. We will resize ourselves open later if needed. |
| 213 [[self view] setFrame:NSMakeRect(0, 0, initialWidth_, 0)]; | 216 [[self view] setFrame:NSMakeRect(0, 0, initialWidth_, 0)]; |
| 214 | 217 |
| 215 // We are enabled by default. | 218 // We are enabled by default. |
| 216 barIsEnabled_ = YES; | 219 barIsEnabled_ = YES; |
| 217 | 220 |
| 218 // Don't pass ourself along (as 'self') until our init is completely | |
| 219 // done. Thus, this call is (almost) last. | |
| 220 bridge_.reset(new BookmarkBarBridge(self, bookmarkModel_)); | |
| 221 | |
| 222 DCHECK([offTheSideButton_ attachedMenu]); | 221 DCHECK([offTheSideButton_ attachedMenu]); |
| 223 | 222 |
| 224 // To make life happier when the bookmark bar is floating, the chevron is a | 223 // To make life happier when the bookmark bar is floating, the chevron is a |
| 225 // child of the button view. | 224 // child of the button view. |
| 226 [offTheSideButton_ removeFromSuperview]; | 225 [offTheSideButton_ removeFromSuperview]; |
| 227 [buttonView_ addSubview:offTheSideButton_]; | 226 [buttonView_ addSubview:offTheSideButton_]; |
| 228 | 227 |
| 228 // Copy the bar menu so we know if it's from the bar or a folder. |
| 229 // Then we set its represented item to be the bookmark bar. |
| 230 buttonFolderContextMenu_.reset([[[self view] menu] copy]); |
| 231 |
| 229 // When resized we may need to add new buttons, or remove them (if | 232 // When resized we may need to add new buttons, or remove them (if |
| 230 // no longer visible), or add/remove the "off the side" menu. | 233 // no longer visible), or add/remove the "off the side" menu. |
| 231 [[self view] setPostsFrameChangedNotifications:YES]; | 234 [[self view] setPostsFrameChangedNotifications:YES]; |
| 232 [[NSNotificationCenter defaultCenter] | 235 [[NSNotificationCenter defaultCenter] |
| 233 addObserver:self | 236 addObserver:self |
| 234 selector:@selector(frameDidChange) | 237 selector:@selector(frameDidChange) |
| 235 name:NSViewFrameDidChangeNotification | 238 name:NSViewFrameDidChangeNotification |
| 236 object:[self view]]; | 239 object:[self view]]; |
| 240 |
| 241 // Don't pass ourself along (as 'self') until our init is completely |
| 242 // done. Thus, this call is (almost) last. |
| 243 bridge_.reset(new BookmarkBarBridge(self, bookmarkModel_)); |
| 237 } | 244 } |
| 238 | 245 |
| 239 // (Private) Method is the same as [self view], but is provided to be explicit. | 246 // (Private) Method is the same as [self view], but is provided to be explicit. |
| 240 - (BackgroundGradientView*)backgroundGradientView { | 247 - (BackgroundGradientView*)backgroundGradientView { |
| 241 DCHECK([[self view] isKindOfClass:[BackgroundGradientView class]]); | 248 DCHECK([[self view] isKindOfClass:[BackgroundGradientView class]]); |
| 242 return (BackgroundGradientView*)[self view]; | 249 return (BackgroundGradientView*)[self view]; |
| 243 } | 250 } |
| 244 | 251 |
| 245 // (Private) Method is the same as [self view], but is provided to be explicit. | 252 // (Private) Method is the same as [self view], but is provided to be explicit. |
| 246 - (AnimatableView*)animatableView { | 253 - (AnimatableView*)animatableView { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 - (int)currentTabContentsHeight { | 469 - (int)currentTabContentsHeight { |
| 463 return browser_->GetSelectedTabContents() ? | 470 return browser_->GetSelectedTabContents() ? |
| 464 browser_->GetSelectedTabContents()->view()->GetContainerSize().height() : | 471 browser_->GetSelectedTabContents()->view()->GetContainerSize().height() : |
| 465 0; | 472 0; |
| 466 } | 473 } |
| 467 | 474 |
| 468 - (ThemeProvider*)themeProvider { | 475 - (ThemeProvider*)themeProvider { |
| 469 return browser_->profile()->GetThemeProvider(); | 476 return browser_->profile()->GetThemeProvider(); |
| 470 } | 477 } |
| 471 | 478 |
| 472 // Return nil if menuItem has no delegate. | |
| 473 - (BookmarkNode*)nodeFromMenuItem:(id)menuItem { | |
| 474 NSCell* cell = reinterpret_cast<NSCell*>([[menuItem menu] delegate]); | |
| 475 if (!cell) | |
| 476 return nil; | |
| 477 BookmarkNode* node = static_cast<BookmarkNode*>( | |
| 478 [[cell representedObject] pointerValue]); | |
| 479 return node; | |
| 480 } | |
| 481 | |
| 482 - (BookmarkNode*)nodeFromButton:(id)button { | 479 - (BookmarkNode*)nodeFromButton:(id)button { |
| 483 NSCell* cell = [button cell]; | 480 NSCell* cell = [button cell]; |
| 484 BookmarkNode* node = static_cast<BookmarkNode*>( | 481 BookmarkNode* node = static_cast<BookmarkNode*>( |
| 485 [[cell representedObject] pointerValue]); | 482 [[cell representedObject] pointerValue]); |
| 486 DCHECK(node); | 483 DCHECK(node); |
| 487 return node; | 484 return node; |
| 488 } | 485 } |
| 489 | 486 |
| 490 // At this time, the only items which ever get disabled are the "Open All | 487 // Enable or disable items. We are the menu delegate for both the bar |
| 491 // Bookmarks" options. | 488 // and for bookmark folder buttons. |
| 492 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { | 489 - (BOOL)validateUserInterfaceItem:(id)item { |
| 490 if (![item isKindOfClass:[NSMenuItem class]]) |
| 491 return YES; |
| 492 |
| 493 BookmarkNode* node = [self nodeFromMenuItem:item]; |
| 494 |
| 495 // If this is the bar menu, we only have things to do if there are |
| 496 // buttons. If this is a folder button menu, we only have things to |
| 497 // do if the folder has items. |
| 498 NSMenu* menu = [item menu]; |
| 499 BOOL thingsToDo = NO; |
| 500 if (menu == [[self view] menu]) { |
| 501 thingsToDo = [buttons_ count] ? YES : NO; |
| 502 } else { |
| 503 if (node && node->is_folder() && node->GetChildCount()) { |
| 504 thingsToDo = YES; |
| 505 } |
| 506 } |
| 507 |
| 508 // Disable openAll* if we have nothing to do. |
| 493 SEL action = [item action]; | 509 SEL action = [item action]; |
| 494 if (((action == @selector(openAllBookmarks:)) || | 510 if ((!thingsToDo) && |
| 511 ((action == @selector(openAllBookmarks:)) || |
| 495 (action == @selector(openAllBookmarksNewWindow:)) || | 512 (action == @selector(openAllBookmarksNewWindow:)) || |
| 496 (action == @selector(openAllBookmarksIncognitoWindow:))) && | 513 (action == @selector(openAllBookmarksIncognitoWindow:)))) { |
| 497 (![buttons_ count])) { | |
| 498 return NO; | 514 return NO; |
| 499 } | 515 } |
| 516 |
| 517 if ((action == @selector(editBookmark:)) || |
| 518 (action == @selector(deleteBookmark:))) { |
| 519 // Don't allow edit/delete of the bar node, or of "Other Bookmarks" |
| 520 if ((node == nil) || |
| 521 (node == bookmarkModel_->other_node()) || |
| 522 (node == bookmarkModel_->GetBookmarkBarNode())) { |
| 523 return NO; |
| 524 } |
| 525 } |
| 526 |
| 527 // Enabled by default. |
| 500 return YES; | 528 return YES; |
| 501 } | 529 } |
| 502 | 530 |
| 503 // Actually open the URL. This is the last chance for a unit test to | 531 // Actually open the URL. This is the last chance for a unit test to |
| 504 // override. | 532 // override. |
| 505 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition { | 533 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition { |
| 506 BrowserList::GetLastActive()->OpenURL(url, GURL(), disposition, | 534 BrowserList::GetLastActive()->OpenURL(url, GURL(), disposition, |
| 507 PageTransition::AUTO_BOOKMARK); | 535 PageTransition::AUTO_BOOKMARK); |
| 508 } | 536 } |
| 509 | 537 |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 [self openURL:child->GetURL() disposition:disposition]; | 744 [self openURL:child->GetURL() disposition:disposition]; |
| 717 // We revert to a basic disposition in case the initial | 745 // We revert to a basic disposition in case the initial |
| 718 // disposition opened a new window. | 746 // disposition opened a new window. |
| 719 disposition = NEW_BACKGROUND_TAB; | 747 disposition = NEW_BACKGROUND_TAB; |
| 720 } else { | 748 } else { |
| 721 [self openBookmarkNodesRecursive:child disposition:disposition]; | 749 [self openBookmarkNodesRecursive:child disposition:disposition]; |
| 722 } | 750 } |
| 723 } | 751 } |
| 724 } | 752 } |
| 725 | 753 |
| 754 // Return the BookmarkNode associated with the given NSMenuItem. |
| 755 - (BookmarkNode*)nodeFromMenuItem:(id)sender { |
| 756 BookmarkMenu* menu = (BookmarkMenu*)[sender menu]; |
| 757 if ([menu isKindOfClass:[BookmarkMenu class]]) |
| 758 return const_cast<BookmarkNode*>([menu node]); |
| 759 return NULL; |
| 760 } |
| 761 |
| 726 - (IBAction)openAllBookmarks:(id)sender { | 762 - (IBAction)openAllBookmarks:(id)sender { |
| 727 // TODO(jrg): | 763 BookmarkNode* node = [self nodeFromMenuItem:sender]; |
| 728 // Is there an easier way to get a non-const root node for the bookmark bar? | |
| 729 // I can't iterate over them unless it's non-const. | |
| 730 BookmarkNode* node = const_cast<BookmarkNode*>( | |
| 731 bookmarkModel_->GetBookmarkBarNode()); | |
| 732 [self openBookmarkNodesRecursive:node disposition:NEW_FOREGROUND_TAB]; | 764 [self openBookmarkNodesRecursive:node disposition:NEW_FOREGROUND_TAB]; |
| 733 UserMetrics::RecordAction(L"OpenAllBookmarks", browser_->profile()); | 765 UserMetrics::RecordAction(L"OpenAllBookmarks", browser_->profile()); |
| 734 } | 766 } |
| 735 | 767 |
| 736 - (IBAction)openAllBookmarksNewWindow:(id)sender { | 768 - (IBAction)openAllBookmarksNewWindow:(id)sender { |
| 737 BookmarkNode* node = const_cast<BookmarkNode*>( | 769 BookmarkNode* node = [self nodeFromMenuItem:sender]; |
| 738 bookmarkModel_->GetBookmarkBarNode()); | |
| 739 [self openBookmarkNodesRecursive:node disposition:NEW_WINDOW]; | 770 [self openBookmarkNodesRecursive:node disposition:NEW_WINDOW]; |
| 740 UserMetrics::RecordAction(L"OpenAllBookmarksNewWindow", browser_->profile()); | 771 UserMetrics::RecordAction(L"OpenAllBookmarksNewWindow", browser_->profile()); |
| 741 } | 772 } |
| 742 | 773 |
| 743 - (IBAction)openAllBookmarksIncognitoWindow:(id)sender { | 774 - (IBAction)openAllBookmarksIncognitoWindow:(id)sender { |
| 744 BookmarkNode* node = const_cast<BookmarkNode*>( | 775 BookmarkNode* node = [self nodeFromMenuItem:sender]; |
| 745 bookmarkModel_->GetBookmarkBarNode()); | |
| 746 [self openBookmarkNodesRecursive:node disposition:OFF_THE_RECORD]; | 776 [self openBookmarkNodesRecursive:node disposition:OFF_THE_RECORD]; |
| 747 UserMetrics::RecordAction(L"OpenAllBookmarksIncognitoWindow", browser_->profil
e()); | 777 UserMetrics::RecordAction(L"OpenAllBookmarksIncognitoWindow", browser_->profil
e()); |
| 748 } | 778 } |
| 749 | 779 |
| 750 // May be called from the bar or from a folder button. | 780 // May be called from the bar or from a folder button. |
| 751 // If called from a button, that button becomes the parent. | 781 // If called from a button, that button becomes the parent. |
| 752 - (IBAction)addPage:(id)sender { | 782 - (IBAction)addPage:(id)sender { |
| 753 const BookmarkNode* parent = [self nodeFromMenuItem:sender]; | 783 const BookmarkNode* parent = [self nodeFromMenuItem:sender]; |
| 754 if (!parent) | 784 if (!parent) |
| 755 parent = bookmarkModel_->GetBookmarkBarNode(); | 785 parent = bookmarkModel_->GetBookmarkBarNode(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 - (NSCell*)cellForBookmarkNode:(const BookmarkNode*)node { | 818 - (NSCell*)cellForBookmarkNode:(const BookmarkNode*)node { |
| 789 NSString* title = base::SysWideToNSString(node->GetTitle()); | 819 NSString* title = base::SysWideToNSString(node->GetTitle()); |
| 790 BookmarkButtonCell* cell = | 820 BookmarkButtonCell* cell = |
| 791 [[[BookmarkButtonCell alloc] initTextCell:nil] autorelease]; | 821 [[[BookmarkButtonCell alloc] initTextCell:nil] autorelease]; |
| 792 DCHECK(cell); | 822 DCHECK(cell); |
| 793 [cell setRepresentedObject:[NSValue valueWithPointer:node]]; | 823 [cell setRepresentedObject:[NSValue valueWithPointer:node]]; |
| 794 | 824 |
| 795 NSImage* image = [self getFavIconForNode:node]; | 825 NSImage* image = [self getFavIconForNode:node]; |
| 796 [cell setBookmarkCellText:title image:image]; | 826 [cell setBookmarkCellText:title image:image]; |
| 797 if (node->is_folder()) | 827 if (node->is_folder()) |
| 798 [cell setMenu:[[self view] menu]]; | 828 [cell setMenu:buttonFolderContextMenu_]; |
| 799 else | 829 else |
| 800 [cell setMenu:buttonContextMenu_]; | 830 [cell setMenu:buttonContextMenu_]; |
| 801 return cell; | 831 return cell; |
| 802 } | 832 } |
| 803 | 833 |
| 804 // Return an appropriate width for the given bookmark button cell. | 834 // Return an appropriate width for the given bookmark button cell. |
| 805 // The "+2" is needed because, sometimes, Cocoa is off by a tad. | 835 // The "+2" is needed because, sometimes, Cocoa is off by a tad. |
| 806 // Example: for a bookmark named "Moma" or "SFGate", it is one pixel | 836 // Example: for a bookmark named "Moma" or "SFGate", it is one pixel |
| 807 // too small. For "FBL" it is 2 pixels too small. | 837 // too small. For "FBL" it is 2 pixels too small. |
| 808 // For a bookmark named "SFGateFooWoo", it is just fine. | 838 // For a bookmark named "SFGateFooWoo", it is just fine. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 // Else brute force nuke and build. | 1038 // Else brute force nuke and build. |
| 1009 const BookmarkNode* node = model->GetBookmarkBarNode(); | 1039 const BookmarkNode* node = model->GetBookmarkBarNode(); |
| 1010 [self clearBookmarkBar]; | 1040 [self clearBookmarkBar]; |
| 1011 [self addNodesToButtonList:node]; | 1041 [self addNodesToButtonList:node]; |
| 1012 [self createOtherBookmarksButton]; | 1042 [self createOtherBookmarksButton]; |
| 1013 [self resizeButtons]; | 1043 [self resizeButtons]; |
| 1014 [self positionOffTheSideButton]; | 1044 [self positionOffTheSideButton]; |
| 1015 [self addNonBookmarkButtonsToView]; | 1045 [self addNonBookmarkButtonsToView]; |
| 1016 [self addButtonsToView]; | 1046 [self addButtonsToView]; |
| 1017 [self showOrHideOffTheSideButton]; | 1047 [self showOrHideOffTheSideButton]; |
| 1048 [self setNodeForBarMenu]; |
| 1049 } |
| 1050 |
| 1051 // Now that the model is loaded, set the bookmark bar root as the node |
| 1052 // represented by the bookmark bar (default, background) menu. |
| 1053 - (void)setNodeForBarMenu { |
| 1054 const BookmarkNode* node = bookmarkModel_->GetBookmarkBarNode(); |
| 1055 BookmarkMenu* menu = static_cast<BookmarkMenu*>([[self view] menu]); |
| 1056 [menu setRepresentedObject:[NSValue valueWithPointer:node]]; |
| 1018 } | 1057 } |
| 1019 | 1058 |
| 1020 - (void)beingDeleted:(BookmarkModel*)model { | 1059 - (void)beingDeleted:(BookmarkModel*)model { |
| 1021 [self clearBookmarkBar]; | 1060 [self clearBookmarkBar]; |
| 1022 } | 1061 } |
| 1023 | 1062 |
| 1024 // TODO(jrg): for now this is brute force. | 1063 // TODO(jrg): for now this is brute force. |
| 1025 - (void)nodeMoved:(BookmarkModel*)model | 1064 - (void)nodeMoved:(BookmarkModel*)model |
| 1026 oldParent:(const BookmarkNode*)oldParent oldIndex:(int)oldIndex | 1065 oldParent:(const BookmarkNode*)oldParent oldIndex:(int)oldIndex |
| 1027 newParent:(const BookmarkNode*)newParent newIndex:(int)newIndex { | 1066 newParent:(const BookmarkNode*)newParent newIndex:(int)newIndex { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 [[self animatableView] stopAnimation]; | 1235 [[self animatableView] stopAnimation]; |
| 1197 } | 1236 } |
| 1198 | 1237 |
| 1199 // Delegate method for |AnimatableView| (a superclass of | 1238 // Delegate method for |AnimatableView| (a superclass of |
| 1200 // |BookmarkBarToolbarView|). | 1239 // |BookmarkBarToolbarView|). |
| 1201 - (void)animationDidEnd:(NSAnimation*)animation { | 1240 - (void)animationDidEnd:(NSAnimation*)animation { |
| 1202 [self finalizeVisualState]; | 1241 [self finalizeVisualState]; |
| 1203 } | 1242 } |
| 1204 | 1243 |
| 1205 @end | 1244 @end |
| OLD | NEW |