diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 20:37:43 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 20:37:43 +0000 |
commit | 9775eb1e54557b55e5d49c305a41d64fd5c32e6d (patch) | |
tree | 6beea6972fbe6a2972e96c0de3e36d2950a50196 | |
parent | 1e032f0d7ab21e849aab5099fa88b8dcad2940a9 (diff) | |
download | chromium_src-9775eb1e54557b55e5d49c305a41d64fd5c32e6d.zip chromium_src-9775eb1e54557b55e5d49c305a41d64fd5c32e6d.tar.gz chromium_src-9775eb1e54557b55e5d49c305a41d64fd5c32e6d.tar.bz2 |
Mac: Empty bookmark bar should show IDS_BOOKMARKS_NO_ITEMS.
TEST=BookmarkBarControllerTest.DisplaysHelpMessageOnEmpty
TEST=BookmarkBarControllerTest.HidesHelpMessageWithBookmark
BUG=17360
Review URL: http://codereview.chromium.org/216052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26853 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/nibs/BookmarkBar.xib | 105 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.h | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.mm | 7 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller_unittest.mm | 18 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_view.h | 10 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_view.mm | 4 |
6 files changed, 133 insertions, 15 deletions
diff --git a/chrome/app/nibs/BookmarkBar.xib b/chrome/app/nibs/BookmarkBar.xib index c2b1784..bc2e350 100644 --- a/chrome/app/nibs/BookmarkBar.xib +++ b/chrome/app/nibs/BookmarkBar.xib @@ -8,10 +8,10 @@ <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="1"/> - <integer value="75"/> <integer value="4"/> <integer value="18"/> + <integer value="1"/> + <integer value="75"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -65,6 +65,45 @@ <object class="NSCustomView" id="610146462"> <reference key="NSNextResponder" ref="620641226"/> <int key="NSvFlags">274</int> + <object class="NSMutableArray" key="NSSubviews"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSTextField" id="1013234954"> + <reference key="NSNextResponder" ref="610146462"/> + <int key="NSvFlags">-2147483382</int> + <string key="NSFrame">{{5, 122}, {582, 17}}</string> + <reference key="NSSuperview" ref="610146462"/> + <bool key="NSEnabled">YES</bool> + <object class="NSTextFieldCell" key="NSCell" id="458754719"> + <int key="NSCellFlags">68288064</int> + <int key="NSCellFlags2">272630784</int> + <string key="NSContents">^IDS_BOOKMARKS_NO_ITEMS</string> + <object class="NSFont" key="NSSupport"> + <string key="NSName">LucidaGrande</string> + <double key="NSSize">1.300000e+01</double> + <int key="NSfFlags">1044</int> + </object> + <reference key="NSControlView" ref="1013234954"/> + <object class="NSColor" key="NSBackgroundColor"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">controlColor</string> + <object class="NSColor" key="NSColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes> + </object> + </object> + <object class="NSColor" key="NSTextColor"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">controlTextColor</string> + <object class="NSColor" key="NSColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MAA</bytes> + </object> + </object> + </object> + </object> + </object> <string key="NSFrameSize">{584, 144}</string> <reference key="NSSuperview" ref="620641226"/> <string key="NSClassName">BookmarkBarView</string> @@ -548,6 +587,22 @@ </object> <int key="connectionID">81</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">owner_</string> + <reference key="source" ref="849863465"/> + <reference key="destination" ref="1001"/> + </object> + <int key="connectionID">86</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">noItemTextfield_</string> + <reference key="source" ref="610146462"/> + <reference key="destination" ref="1013234954"/> + </object> + <int key="connectionID">87</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -753,6 +808,10 @@ <object class="IBObjectRecord"> <int key="objectID">62</int> <reference key="object" ref="610146462"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="1013234954"/> + </object> <reference key="parent" ref="620641226"/> </object> <object class="IBObjectRecord"> @@ -789,6 +848,20 @@ <reference key="object" ref="582055256"/> <reference key="parent" ref="190917733"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">82</int> + <reference key="object" ref="1013234954"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="458754719"/> + </object> + <reference key="parent" ref="610146462"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">83</int> + <reference key="object" ref="458754719"/> + <reference key="parent" ref="1013234954"/> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -836,6 +909,8 @@ <string>75.IBPluginDependency</string> <string>76.IBPluginDependency</string> <string>8.IBPluginDependency</string> + <string>82.IBPluginDependency</string> + <string>83.IBPluginDependency</string> <string>9.IBPluginDependency</string> </object> <object class="NSMutableArray" key="dict.values"> @@ -843,7 +918,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{96, 477}, {600, 144}}</string> + <string>{{793, 486}, {600, 144}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -852,7 +927,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{380, 543}, {365, 213}}</string> + <string>{{1047, 789}, {365, 213}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -866,7 +941,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{370, 543}, {375, 213}}</string> + <string>{{489, 789}, {375, 213}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -882,6 +957,8 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> </object> </object> <object class="NSMutableDictionary" key="unlocalizedProperties"> @@ -904,7 +981,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">81</int> + <int key="maxID">87</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -926,7 +1003,6 @@ <string>openBookmarkInNewForegroundTab:</string> <string>openBookmarkInNewWindow:</string> <string>openFolderMenuFromButton:</string> - <string>openOffTheSideMenuFromButton:</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -940,7 +1016,6 @@ <string>id</string> <string>id</string> <string>id</string> - <string>id</string> </object> </object> <object class="NSMutableDictionary" key="outlets"> @@ -956,7 +1031,7 @@ <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> <string>NSMenu</string> - <string>NSView</string> + <string>BookmarkBarView</string> <string>MenuButton</string> <string>id</string> <string>id</string> @@ -970,12 +1045,24 @@ <object class="IBPartialClassDescription"> <string key="className">BookmarkBarView</string> <string key="superclassName">NSView</string> + <object class="NSMutableDictionary" key="outlets"> + <string key="NS.key.0">noItemTextfield_</string> + <string key="NS.object.0">NSTextField</string> + </object> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> <string key="minorKey">browser/cocoa/bookmark_bar_view.h</string> </object> </object> <object class="IBPartialClassDescription"> + <string key="className">BookmarkBarView</string> + <string key="superclassName">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBUserSource</string> + <string key="minorKey"/> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">ChromeUILocalizer</string> <string key="superclassName">GTMUILocalizer</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> 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 |