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 "base/mac_util.h" | 5 #include "base/mac_util.h" |
6 #include "base/sys_string_conversions.h" | 6 #include "base/sys_string_conversions.h" |
7 #include "chrome/browser/bookmarks/bookmark_editor.h" | 7 #include "chrome/browser/bookmarks/bookmark_editor.h" |
8 #include "chrome/browser/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
11 #import "chrome/browser/cocoa/bookmark_bar_bridge.h" | 11 #import "chrome/browser/cocoa/bookmark_bar_bridge.h" |
12 #import "chrome/browser/cocoa/bookmark_bar_controller.h" | 12 #import "chrome/browser/cocoa/bookmark_bar_controller.h" |
| 13 #import "chrome/browser/cocoa/bookmark_bar_view.h" |
13 #import "chrome/browser/cocoa/bookmark_button_cell.h" | 14 #import "chrome/browser/cocoa/bookmark_button_cell.h" |
14 #import "chrome/browser/cocoa/bookmark_editor_controller.h" | 15 #import "chrome/browser/cocoa/bookmark_editor_controller.h" |
15 #import "chrome/browser/cocoa/bookmark_name_folder_controller.h" | 16 #import "chrome/browser/cocoa/bookmark_name_folder_controller.h" |
16 #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h" | 17 #import "chrome/browser/cocoa/bookmark_menu_cocoa_controller.h" |
17 #import "chrome/browser/cocoa/event_utils.h" | 18 #import "chrome/browser/cocoa/event_utils.h" |
18 #import "chrome/browser/cocoa/menu_button.h" | 19 #import "chrome/browser/cocoa/menu_button.h" |
19 #import "chrome/browser/cocoa/view_resizer.h" | 20 #import "chrome/browser/cocoa/view_resizer.h" |
20 #include "chrome/browser/cocoa/nsimage_cache.h" | 21 #include "chrome/browser/cocoa/nsimage_cache.h" |
21 #include "chrome/browser/profile.h" | 22 #include "chrome/browser/profile.h" |
22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 initWithParentWindow:[[self view] window] | 435 initWithParentWindow:[[self view] window] |
435 profile:profile_ | 436 profile:profile_ |
436 node:node]; | 437 node:node]; |
437 [controller runAsModalSheet]; | 438 [controller runAsModalSheet]; |
438 | 439 |
439 // runAsModalSheet will run the window as a sheet. The | 440 // runAsModalSheet will run the window as a sheet. The |
440 // BookmarkNameFolderController will release itself when the sheet | 441 // BookmarkNameFolderController will release itself when the sheet |
441 // ends. | 442 // ends. |
442 } | 443 } |
443 | 444 |
444 - (NSView*)buttonView { | 445 - (BookmarkBarView*)buttonView { |
445 return buttonView_; | 446 return buttonView_; |
446 } | 447 } |
447 | 448 |
448 // Delete all bookmarks from the bookmark bar, and reset knowledge of | 449 // Delete all bookmarks from the bookmark bar, and reset knowledge of |
449 // bookmarks. | 450 // bookmarks. |
450 - (void)clearBookmarkBar { | 451 - (void)clearBookmarkBar { |
451 [buttons_ makeObjectsPerformSelector:@selector(removeFromSuperview)]; | 452 [buttons_ makeObjectsPerformSelector:@selector(removeFromSuperview)]; |
452 [buttons_ removeAllObjects]; | 453 [buttons_ removeAllObjects]; |
453 [self clearMenuTagMap]; | 454 [self clearMenuTagMap]; |
454 } | 455 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); | 541 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
541 [urlDelegate_ openBookmarkURL:node->GetURL() disposition:disposition]; | 542 [urlDelegate_ openBookmarkURL:node->GetURL() disposition:disposition]; |
542 } | 543 } |
543 | 544 |
544 // Add all items from the given model to our bookmark bar. | 545 // Add all items from the given model to our bookmark bar. |
545 // | 546 // |
546 // TODO(jrg): write a "build bar" so there is a nice spot for things | 547 // TODO(jrg): write a "build bar" so there is a nice spot for things |
547 // like the contextual menu which is invoked when not over a | 548 // like the contextual menu which is invoked when not over a |
548 // bookmark. On Safari that menu has a "new folder" option. | 549 // bookmark. On Safari that menu has a "new folder" option. |
549 - (void)addNodesToBar:(const BookmarkNode*)node { | 550 - (void)addNodesToBar:(const BookmarkNode*)node { |
| 551 BOOL hidden = (node->GetChildCount() == 0) ? NO : YES; |
| 552 NSView* item = [buttonView_ noItemTextfield]; |
| 553 [item setHidden:hidden]; |
| 554 |
550 int x_offset = 0; | 555 int x_offset = 0; |
551 for (int i = 0; i < node->GetChildCount(); i++) { | 556 for (int i = 0; i < node->GetChildCount(); i++) { |
552 const BookmarkNode* child = node->GetChild(i); | 557 const BookmarkNode* child = node->GetChild(i); |
553 | 558 |
554 NSCell* cell = [self cellForBookmarkNode:child]; | 559 NSCell* cell = [self cellForBookmarkNode:child]; |
555 NSRect frame = [self frameForBookmarkButtonFromCell:cell xOffset:&x_offset]; | 560 NSRect frame = [self frameForBookmarkButtonFromCell:cell xOffset:&x_offset]; |
556 NSButton* button = [[[BookmarkButton alloc] initWithFrame:frame] | 561 NSButton* button = [[[BookmarkButton alloc] initWithFrame:frame] |
557 autorelease]; | 562 autorelease]; |
558 DCHECK(button); | 563 DCHECK(button); |
559 [buttons_ addObject:button]; | 564 [buttons_ addObject:button]; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 | 668 |
664 - (void)setUrlDelegate:(id<BookmarkURLOpener>)urlDelegate { | 669 - (void)setUrlDelegate:(id<BookmarkURLOpener>)urlDelegate { |
665 urlDelegate_ = urlDelegate; | 670 urlDelegate_ = urlDelegate; |
666 } | 671 } |
667 | 672 |
668 - (NSArray*)buttons { | 673 - (NSArray*)buttons { |
669 return buttons_.get(); | 674 return buttons_.get(); |
670 } | 675 } |
671 | 676 |
672 @end | 677 @end |
OLD | NEW |