summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-10 18:05:17 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-10 18:05:17 +0000
commit562dc9544aa2668b51a35793a90ad5cffec97c8f (patch)
tree9bc9eef579afa8105c1c69d92e2ff135db3a2381 /chrome
parentd2ee25b6cb2cd1dd4267eb2a8972ef4a951caa29 (diff)
downloadchromium_src-562dc9544aa2668b51a35793a90ad5cffec97c8f.zip
chromium_src-562dc9544aa2668b51a35793a90ad5cffec97c8f.tar.gz
chromium_src-562dc9544aa2668b51a35793a90ad5cffec97c8f.tar.bz2
Fix bookmark bar chevron not being pinned to right when launch with bar open.
TEST=\ Make browser window thin (e.g. 400pix wide). Show bookmark bar. Quit. Relaunch. Make sure the "off the side" chevron on the bookmark bar is pinned to the right of the window. Resize width wider and thinner a little; make sure chevron stays pinned. Make browser window wide (e.g. 1000pix wide). Quit. Relaunch. Make sure chevron is pinned to the right of the window. Repeat all these tests but close the bookmark bar before quitting so it starts life closed. Review URL: http://codereview.chromium.org/165207 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22926 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/cocoa/bookmark_bar_controller.h4
-rw-r--r--chrome/browser/cocoa/bookmark_bar_controller.mm9
-rw-r--r--chrome/browser/cocoa/toolbar_controller.mm5
-rw-r--r--chrome/browser/cocoa/toolbar_controller_unittest.mm25
4 files changed, 40 insertions, 3 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.h b/chrome/browser/cocoa/bookmark_bar_controller.h
index 23b211c..8948510 100644
--- a/chrome/browser/cocoa/bookmark_bar_controller.h
+++ b/chrome/browser/cocoa/bookmark_bar_controller.h
@@ -79,6 +79,10 @@ class PrefService;
resizeDelegate:(id<ViewResizer>)resizeDelegate
urlDelegate:(id<BookmarkURLOpener>)urlDelegate;
+// Tell the bar to show itself if needed (e.g. if the kShowBookmarkBar
+// is set). Called once after the controller is first created.
+- (void)showIfNeeded;
+
// Returns whether or not the bookmark bar is visible.
- (BOOL)isBookmarkBarVisible;
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm
index 8fede00..ebba2f3 100644
--- a/chrome/browser/cocoa/bookmark_bar_controller.mm
+++ b/chrome/browser/cocoa/bookmark_bar_controller.mm
@@ -72,10 +72,8 @@ const CGFloat kBookmarkHorizontalPadding = 1.0;
// expects. We will resize ourselves open later if needed.
[[self view] setFrame:NSMakeRect(0, 0, initialWidth_, 0)];
- // Be sure to enable the bar before trying to show it...
+ // We are enabled by default.
barIsEnabled_ = YES;
- if (profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar))
- [self showBookmarkBar:YES immediately:YES];
// Don't pass ourself along (as 'self') until our init is completely
// done. Thus, this call is (almost) last.
@@ -91,6 +89,11 @@ const CGFloat kBookmarkHorizontalPadding = 1.0;
object:[self view]];
}
+- (void)showIfNeeded {
+ if (profile_->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar))
+ [self showBookmarkBar:YES immediately:YES];
+}
+
// Check if we should enable the off-the-side button.
// TODO(jrg): when we are smarter about creating buttons (e.g. don't
// bother creating buttons which aren't visible), we'll have to be
diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm
index acddc8b..04c7e5e0 100644
--- a/chrome/browser/cocoa/toolbar_controller.mm
+++ b/chrome/browser/cocoa/toolbar_controller.mm
@@ -126,6 +126,11 @@ class PrefObserverBridge : public NotificationObserver {
// position and resize properties don't need to be set.
[[self view] addSubview:[bookmarkBarController_ view]];
+ // We don't want to try and show the bar before it gets placed in
+ // it's parent view, so this step shoudn't be inside the bookmark
+ // bar controller's awakeFromNib.
+ [bookmarkBarController_ showIfNeeded];
+
// Create the controllers for the back/forward menus.
backMenuController_.reset([[BackForwardMenuController alloc]
initWithBrowser:browser_
diff --git a/chrome/browser/cocoa/toolbar_controller_unittest.mm b/chrome/browser/cocoa/toolbar_controller_unittest.mm
index aa053bc..aa0257193 100644
--- a/chrome/browser/cocoa/toolbar_controller_unittest.mm
+++ b/chrome/browser/cocoa/toolbar_controller_unittest.mm
@@ -223,4 +223,29 @@ TEST_F(ToolbarControllerTest, BookmarkBarResizes) {
EXPECT_EQ(6, NSHeight([bookmarkBarView frame]));
}
+// Make sure, by default, the bookmark bar is the full width of the
+// toolbar.
+TEST_F(ToolbarControllerTest, BookmarkBarIsFullWidth) {
+ // Set the pref to the bookmark bar is visible when the toolbar is
+ // first created.
+ helper_.profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true);
+
+ // Create a new bar (after the pref is set)
+ Browser* browser = helper_.browser();
+ bar_.reset(
+ [[ToolbarController alloc] initWithModel:browser->toolbar_model()
+ commands:browser->command_updater()
+ profile:helper_.profile()
+ browser:browser
+ resizeDelegate:resizeDelegate_.get()
+ bookmarkDelegate:nil]);
+ EXPECT_TRUE([bar_ view]);
+
+ // Make sure the bookmark bar is the same width as the toolbar
+ NSView* bookmarkBarView = [[bar_ bookmarkBarController] view];
+ EXPECT_EQ([[bar_ view] frame].size.width,
+ [bookmarkBarView frame].size.width);
+ EXPECT_TRUE([bookmarkBarView isDescendantOf:[bar_ view]]);
+}
+
} // namespace