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" |
(...skipping 121 matching lines...) Loading... |
132 } | 132 } |
133 | 133 |
134 - (void)showIfNeeded { | 134 - (void)showIfNeeded { |
135 if (browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)) | 135 if (browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)) |
136 [self showBookmarkBar:YES immediately:YES]; | 136 [self showBookmarkBar:YES immediately:YES]; |
137 } | 137 } |
138 | 138 |
139 // Position the off-the-side chevron to the left of the otherBookmarks button. | 139 // Position the off-the-side chevron to the left of the otherBookmarks button. |
140 - (void)positionOffTheSideButton { | 140 - (void)positionOffTheSideButton { |
141 NSRect frame = [offTheSideButton_ frame]; | 141 NSRect frame = [offTheSideButton_ frame]; |
142 frame.origin.x = ([otherBookmarksButton_ frame].origin.x - | 142 if (otherBookmarksButton_.get()) { |
143 (frame.size.width + bookmarks::kBookmarkHorizontalPadding)); | 143 frame.origin.x = ([otherBookmarksButton_ frame].origin.x - |
144 [offTheSideButton_ setFrame:frame]; | 144 (frame.size.width + bookmarks::kBookmarkHorizontalPadding)
); |
| 145 [offTheSideButton_ setFrame:frame]; |
| 146 } |
145 } | 147 } |
146 | 148 |
147 // Check if we should enable or disable the off-the-side chevron. | 149 // Check if we should enable or disable the off-the-side chevron. |
148 // Assumes that buttons which don't fit in the parent view are removed | 150 // Assumes that buttons which don't fit in the parent view are removed |
149 // from it. | 151 // from it. |
150 // | 152 // |
151 // TODO(jrg): when we are smarter about creating buttons (e.g. don't | 153 // TODO(jrg): when we are smarter about creating buttons (e.g. don't |
152 // bother creating buttons which aren't visible), we'll have to be | 154 // bother creating buttons which aren't visible), we'll have to be |
153 // smarter here too. | 155 // smarter here too. |
154 - (void)showOrHideOffTheSideButton { | 156 - (void)showOrHideOffTheSideButton { |
(...skipping 642 matching lines...) Loading... |
797 otherBookmarksButton_.reset(button); | 799 otherBookmarksButton_.reset(button); |
798 | 800 |
799 // Peg at right; keep same height as bar. | 801 // Peg at right; keep same height as bar. |
800 [button setAutoresizingMask:(NSViewMinXMargin)]; | 802 [button setAutoresizingMask:(NSViewMinXMargin)]; |
801 [button setCell:cell]; | 803 [button setCell:cell]; |
802 [button setTarget:self]; | 804 [button setTarget:self]; |
803 [button setAction:@selector(openFolderMenuFromButton:)]; | 805 [button setAction:@selector(openFolderMenuFromButton:)]; |
804 [buttonView_ addSubview:button]; | 806 [buttonView_ addSubview:button]; |
805 | 807 |
806 // Now that it's here, move the chevron over. | 808 // Now that it's here, move the chevron over. |
807 NSRect oframe = [offTheSideButton_ frame]; | 809 [self positionOffTheSideButton]; |
808 oframe.origin.x = frame.origin.x - (oframe.size.width + | |
809 bookmarks::kBookmarkHorizontalPadding); | |
810 | 810 |
811 // Force it to be the right size, right now. | 811 // Force it to be the right size, right now. |
812 [self resizeButtons]; | 812 [self resizeButtons]; |
813 } | 813 } |
814 | 814 |
815 // TODO(jrg): for now this is brute force. | 815 // TODO(jrg): for now this is brute force. |
816 - (void)loaded:(BookmarkModel*)model { | 816 - (void)loaded:(BookmarkModel*)model { |
817 DCHECK(model == bookmarkModel_); | 817 DCHECK(model == bookmarkModel_); |
818 if (!model->IsLoaded()) | 818 if (!model->IsLoaded()) |
819 return; | 819 return; |
(...skipping 83 matching lines...) Loading... |
903 | 903 |
904 - (NSButton*)offTheSideButton { | 904 - (NSButton*)offTheSideButton { |
905 return offTheSideButton_; | 905 return offTheSideButton_; |
906 } | 906 } |
907 | 907 |
908 - (NSButton*)otherBookmarksButton { | 908 - (NSButton*)otherBookmarksButton { |
909 return otherBookmarksButton_.get(); | 909 return otherBookmarksButton_.get(); |
910 } | 910 } |
911 | 911 |
912 @end | 912 @end |
OLD | NEW |