| Index: chrome/browser/cocoa/bookmark_bar_controller.mm
|
| diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm
|
| index f150334b228d4831aa571e6ed2c77970c0f18934..139bf7cd69e9c69f86b03e13e05c8c26f66dc74f 100644
|
| --- a/chrome/browser/cocoa/bookmark_bar_controller.mm
|
| +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm
|
| @@ -7,6 +7,7 @@
|
| #include "base/mac_util.h"
|
| #include "base/nsimage_cache_mac.h"
|
| #include "base/sys_string_conversions.h"
|
| +#include "chrome/app/chrome_dll_resource.h" // IDC_*
|
| #include "chrome/browser/bookmarks/bookmark_editor.h"
|
| #include "chrome/browser/bookmarks/bookmark_model.h"
|
| #include "chrome/browser/browser.h"
|
| @@ -49,6 +50,7 @@
|
| - (void)tagEmptyMenu:(NSMenu*)menu;
|
| - (void)clearMenuTagMap;
|
| - (int)preferredHeight;
|
| +- (void)greyOutBookmarkBar:(BOOL)doGreyOut;
|
| @end
|
|
|
| namespace {
|
| @@ -72,7 +74,8 @@ const CGFloat kBookmarkHorizontalPadding = 1.0;
|
| initialWidth:(float)initialWidth
|
| compressDelegate:(id<ToolbarCompressable>)compressDelegate
|
| resizeDelegate:(id<ViewResizer>)resizeDelegate
|
| - urlDelegate:(id<BookmarkURLOpener>)urlDelegate {
|
| + urlDelegate:(id<BookmarkURLOpener>)urlDelegate
|
| + commands:(CommandUpdater*)commands {
|
| if ((self = [super initWithNibName:@"BookmarkBar"
|
| bundle:mac_util::MainAppBundle()])) {
|
| browser_ = browser;
|
| @@ -87,6 +90,13 @@ const CGFloat kBookmarkHorizontalPadding = 1.0;
|
|
|
| ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
| folderImage_.reset([rb.GetNSImageNamed(IDR_BOOKMARK_BAR_FOLDER) retain]);
|
| +
|
| + // We grey out if |IDC_BOOKMARK_MENU_CONTENTS| is disabled. Note that the
|
| + // unit tests don't provide a |CommandUpdater|.
|
| + if (commands) {
|
| + commandObserver_.reset(new CommandObserverBridge(self, commands));
|
| + commandObserver_->ObserveCommand(IDC_BOOKMARK_MENU_CONTENTS);
|
| + }
|
| }
|
| return self;
|
| }
|
| @@ -266,6 +276,28 @@ const CGFloat kBookmarkHorizontalPadding = 1.0;
|
| [self updateVisibility];
|
| }
|
|
|
| +// Possibly (un)grey out the bookmark bar (i.e., enable/disable its buttons).
|
| +// Needed for tab-modal sheets.
|
| +- (void)greyOutBookmarkBar:(BOOL)doGreyOut {
|
| + if (barIsGreyedOut_ == doGreyOut)
|
| + return;
|
| +
|
| + barIsGreyedOut_ = doGreyOut;
|
| + for (NSButton* each_button in buttons_.get())
|
| + [each_button setEnabled:!doGreyOut];
|
| + [offTheSideButton_ setEnabled:!doGreyOut];
|
| +}
|
| +
|
| +// Called for state changes in commands (we're only interested in
|
| +// |IDC_BOOKMARK_MENU_CONTENTS|); part (all) of the |CommandObserverProtocol|.
|
| +- (void)enabledStateChangedForCommand:(NSInteger)command enabled:(BOOL)enabled {
|
| + if (command == IDC_BOOKMARK_MENU_CONTENTS) {
|
| + [self greyOutBookmarkBar:!enabled];
|
| + } else {
|
| + NOTREACHED() << "Got state change for command we didn't ask to observe.";
|
| + }
|
| +}
|
| +
|
| // Recursively add the given bookmark node and all its children to
|
| // menu, one menu item per node.
|
| - (void)addNode:(const BookmarkNode*)child toMenu:(NSMenu*)menu {
|
|
|