summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/bookmark_bar_controller.h4
-rw-r--r--chrome/browser/cocoa/bookmark_bar_controller.mm7
-rw-r--r--chrome/browser/cocoa/bookmark_bar_controller_unittest.mm18
-rw-r--r--chrome/browser/cocoa/bookmark_bar_view.h10
-rw-r--r--chrome/browser/cocoa/bookmark_bar_view.mm4
5 files changed, 37 insertions, 6 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.h b/chrome/browser/cocoa/bookmark_bar_controller.h
index 548210e..cecdb3b 100644
--- a/chrome/browser/cocoa/bookmark_bar_controller.h
+++ b/chrome/browser/cocoa/bookmark_bar_controller.h
@@ -68,7 +68,7 @@ class PrefService;
// Delegate that can open URLs for us.
id<BookmarkURLOpener> urlDelegate_; // weak
- IBOutlet NSView* buttonView_;
+ IBOutlet BookmarkBarView* buttonView_;
IBOutlet MenuButton* offTheSideButton_;
IBOutlet NSMenu* buttonContextMenu_;
}
@@ -139,7 +139,7 @@ class PrefService;
// Set the delegate for a unit test.
- (void)setUrlDelegate:(id<BookmarkURLOpener>)urlDelegate;
- (void)clearBookmarkBar;
-- (NSView*)buttonView;
+- (BookmarkBarView*)buttonView;
- (NSArray*)buttons;
- (NSRect)frameForBookmarkButtonFromCell:(NSCell*)cell xOffset:(int*)xOffset;
- (void)checkForBookmarkButtonGrowth:(NSButton*)button;
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm
index 457138e..a591422 100644
--- a/chrome/browser/cocoa/bookmark_bar_controller.mm
+++ b/chrome/browser/cocoa/bookmark_bar_controller.mm
@@ -10,6 +10,7 @@
#include "chrome/browser/browser_list.h"
#import "chrome/browser/cocoa/bookmark_bar_bridge.h"
#import "chrome/browser/cocoa/bookmark_bar_controller.h"
+#import "chrome/browser/cocoa/bookmark_bar_view.h"
#import "chrome/browser/cocoa/bookmark_button_cell.h"
#import "chrome/browser/cocoa/bookmark_editor_controller.h"
#import "chrome/browser/cocoa/bookmark_name_folder_controller.h"
@@ -441,7 +442,7 @@ const CGFloat kBookmarkHorizontalPadding = 1.0;
// ends.
}
-- (NSView*)buttonView {
+- (BookmarkBarView*)buttonView {
return buttonView_;
}
@@ -547,6 +548,10 @@ const CGFloat kBookmarkHorizontalPadding = 1.0;
// like the contextual menu which is invoked when not over a
// bookmark. On Safari that menu has a "new folder" option.
- (void)addNodesToBar:(const BookmarkNode*)node {
+ BOOL hidden = (node->GetChildCount() == 0) ? NO : YES;
+ NSView* item = [buttonView_ noItemTextfield];
+ [item setHidden:hidden];
+
int x_offset = 0;
for (int i = 0; i < node->GetChildCount(); i++) {
const BookmarkNode* child = node->GetChild(i);
diff --git a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm
index 7799e5c..bc72e65 100644
--- a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm
+++ b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/scoped_nsobject.h"
#import "chrome/browser/cocoa/bookmark_bar_controller.h"
+#import "chrome/browser/cocoa/bookmark_bar_view.h"
#include "chrome/browser/cocoa/browser_test_helper.h"
#import "chrome/browser/cocoa/cocoa_test_helper.h"
#include "chrome/browser/cocoa/test_event_utils.h"
@@ -567,6 +568,23 @@ TEST_F(BookmarkBarControllerTest, TestBuildOffTheSideMenu) {
EXPECT_EQ(1, [menu numberOfItems]);
}
+TEST_F(BookmarkBarControllerTest, DisplaysHelpMessageOnEmpty) {
+ BookmarkModel* model = helper_.profile()->GetBookmarkModel();
+ [bar_ loaded:model];
+ EXPECT_FALSE([[[bar_ buttonView] noItemTextfield] isHidden]);
+}
+
+TEST_F(BookmarkBarControllerTest, HidesHelpMessageWithBookmark) {
+ BookmarkModel* model = helper_.profile()->GetBookmarkModel();
+
+ const BookmarkNode* parent = model->GetBookmarkBarNode();
+ model->AddURL(parent, parent->GetChildCount(),
+ L"title", GURL("http://one.com"));
+
+ [bar_ loaded:model];
+ EXPECT_TRUE([[[bar_ buttonView] noItemTextfield] isHidden]);
+}
+
// Cannot test these methods since they simply call a single static
// method, BookmarkEditor::Show(), which is impossible to mock.
// editBookmark:, addPage:
diff --git a/chrome/browser/cocoa/bookmark_bar_view.h b/chrome/browser/cocoa/bookmark_bar_view.h
index 9828113..9bd94d2 100644
--- a/chrome/browser/cocoa/bookmark_bar_view.h
+++ b/chrome/browser/cocoa/bookmark_bar_view.h
@@ -10,8 +10,12 @@
#import <Cocoa/Cocoa.h>
-@interface BookmarkBarView : NSView
-@end
+@interface BookmarkBarView : NSView {
+ IBOutlet NSTextField* noItemTextfield_;
+}
-#endif // CHROME_BROWSER_COCOA_BOOKMARK_BAR_VIEW_H_
+-(NSTextField*)noItemTextfield;
+@end
+
+#endif // CHROME_BROWSER_COCOA_BOOKMARK_BAR_VIEW_H_
diff --git a/chrome/browser/cocoa/bookmark_bar_view.mm b/chrome/browser/cocoa/bookmark_bar_view.mm
index a7d550f0..eb5f17b 100644
--- a/chrome/browser/cocoa/bookmark_bar_view.mm
+++ b/chrome/browser/cocoa/bookmark_bar_view.mm
@@ -12,4 +12,8 @@
return NO;
}
+-(NSTextField*)noItemTextfield {
+ return noItemTextfield_;
+}
+
@end // @implementation BookmarkBarView