Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: chrome/browser/cocoa/browser_window_controller_private.mm

Issue 2475002: Initial cut at scaffolding for mac sidetabs. No visible changes to browser wi... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #import "chrome/browser/cocoa/browser_window_controller_private.h" 5 #import "chrome/browser/cocoa/browser_window_controller_private.h"
6 6
7 #include "base/mac_util.h" 7 #include "base/mac_util.h"
8 #import "base/scoped_nsobject.h" 8 #import "base/scoped_nsobject.h"
9 #include "chrome/browser/browser.h" 9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/browser_list.h" 10 #include "chrome/browser/browser_list.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/browser_theme_provider.h" 12 #include "chrome/browser/browser_theme_provider.h"
13 #import "chrome/browser/cocoa/chrome_browser_window.h" 13 #import "chrome/browser/cocoa/chrome_browser_window.h"
14 #import "chrome/browser/cocoa/fast_resize_view.h" 14 #import "chrome/browser/cocoa/fast_resize_view.h"
15 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h" 15 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h"
16 #import "chrome/browser/cocoa/floating_bar_backing_view.h" 16 #import "chrome/browser/cocoa/floating_bar_backing_view.h"
17 #import "chrome/browser/cocoa/fullscreen_controller.h" 17 #import "chrome/browser/cocoa/fullscreen_controller.h"
18 #import "chrome/browser/cocoa/side_tabs_toolbar_controller.h"
18 #import "chrome/browser/cocoa/tab_strip_controller.h" 19 #import "chrome/browser/cocoa/tab_strip_controller.h"
19 #import "chrome/browser/cocoa/tab_strip_view.h" 20 #import "chrome/browser/cocoa/tab_strip_view.h"
20 #import "chrome/browser/cocoa/toolbar_controller.h" 21 #import "chrome/browser/cocoa/toolbar_controller.h"
21 #include "chrome/browser/pref_service.h" 22 #include "chrome/browser/pref_service.h"
22 #include "chrome/browser/profile.h" 23 #include "chrome/browser/profile.h"
23 #include "chrome/browser/renderer_host/render_widget_host_view.h" 24 #include "chrome/browser/renderer_host/render_widget_host_view.h"
24 #include "chrome/browser/tab_contents/tab_contents.h" 25 #include "chrome/browser/tab_contents/tab_contents.h"
25 #include "chrome/browser/tab_contents/tab_contents_view.h" 26 #include "chrome/browser/tab_contents/tab_contents_view.h"
26 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
27 28
28 29
29 namespace { 30 namespace {
30 31
31 // Space between the incognito badge and the right edge of the window. 32 // Space between the incognito badge and the right edge of the window.
32 const CGFloat kIncognitoBadgeOffset = 4; 33 const CGFloat kIncognitoBadgeOffset = 4;
33 34
34 // Insets for the location bar, used when the full toolbar is hidden. 35 // Insets for the location bar, used when the full toolbar is hidden.
35 // TODO(viettrungluu): We can argue about the "correct" insetting; I like the 36 // TODO(viettrungluu): We can argue about the "correct" insetting; I like the
36 // following best, though arguably 0 inset is better/more correct. 37 // following best, though arguably 0 inset is better/more correct.
37 const CGFloat kLocBarLeftRightInset = 1; 38 const CGFloat kLocBarLeftRightInset = 1;
38 const CGFloat kLocBarTopInset = 0; 39 const CGFloat kLocBarTopInset = 0;
39 const CGFloat kLocBarBottomInset = 1; 40 const CGFloat kLocBarBottomInset = 1;
40 41
41 } // end namespace 42 } // end namespace
42 43
43 44
44 @implementation BrowserWindowController(Private) 45 @implementation BrowserWindowController(Private)
45 46
47 - (BOOL)useVerticalTabs {
48 return browser_->tabstrip_model()->delegate()->UseVerticalTabs();
49 }
50
46 - (void)saveWindowPositionIfNeeded { 51 - (void)saveWindowPositionIfNeeded {
47 if (browser_ != BrowserList::GetLastActive()) 52 if (browser_ != BrowserList::GetLastActive())
48 return; 53 return;
49 54
50 if (!g_browser_process || !g_browser_process->local_state() || 55 if (!g_browser_process || !g_browser_process->local_state() ||
51 !browser_->ShouldSaveWindowPlacement()) 56 !browser_->ShouldSaveWindowPlacement())
52 return; 57 return;
53 58
54 [self saveWindowPositionToPrefs:g_browser_process->local_state()]; 59 [self saveWindowPositionToPrefs:g_browser_process->local_state()];
55 } 60 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 134 }
130 135
131 - (void)layoutSubviews { 136 - (void)layoutSubviews {
132 // With the exception of the tab strip, the subviews which we lay out are 137 // With the exception of the tab strip, the subviews which we lay out are
133 // subviews of the content view, so we mainly work in the content view's 138 // subviews of the content view, so we mainly work in the content view's
134 // coordinate system. Note, however, that the content view's coordinate system 139 // coordinate system. Note, however, that the content view's coordinate system
135 // and the window's base coordinate system should coincide. 140 // and the window's base coordinate system should coincide.
136 NSWindow* window = [self window]; 141 NSWindow* window = [self window];
137 NSView* contentView = [window contentView]; 142 NSView* contentView = [window contentView];
138 NSRect contentBounds = [contentView bounds]; 143 NSRect contentBounds = [contentView bounds];
144 CGFloat minX = NSMinX(contentBounds);
139 CGFloat minY = NSMinY(contentBounds); 145 CGFloat minY = NSMinY(contentBounds);
140 CGFloat width = NSWidth(contentBounds); 146 CGFloat width = NSWidth(contentBounds);
141 147
142 // Suppress title drawing if necessary. 148 // Suppress title drawing if necessary.
143 if ([window respondsToSelector:@selector(setShouldHideTitle:)]) 149 if ([window respondsToSelector:@selector(setShouldHideTitle:)])
144 [(id)window setShouldHideTitle:![self hasTitleBar]]; 150 [(id)window setShouldHideTitle:![self hasTitleBar]];
145 151
146 BOOL isFullscreen = [self isFullscreen]; 152 BOOL isFullscreen = [self isFullscreen];
147 CGFloat floatingBarHeight = [self floatingBarHeight]; 153 CGFloat floatingBarHeight = [self floatingBarHeight];
148 // In fullscreen mode, |yOffset| accounts for the sliding position of the 154 // In fullscreen mode, |yOffset| accounts for the sliding position of the
149 // floating bar and the extra offset needed to dodge the menu bar. 155 // floating bar and the extra offset needed to dodge the menu bar.
150 CGFloat yOffset = isFullscreen ? 156 CGFloat yOffset = isFullscreen ?
151 (floor((1 - floatingBarShownFraction_) * floatingBarHeight) - 157 (floor((1 - floatingBarShownFraction_) * floatingBarHeight) -
152 [fullscreenController_ floatingBarVerticalOffset]) : 0; 158 [fullscreenController_ floatingBarVerticalOffset]) : 0;
153 CGFloat maxY = NSMaxY(contentBounds) + yOffset; 159 CGFloat maxY = NSMaxY(contentBounds) + yOffset;
154 CGFloat startMaxY = maxY; 160 CGFloat startMaxY = maxY;
155 161
156 if ([self hasTabStrip]) { 162 if ([self hasTabStrip]) {
157 // If we need to lay out the tab strip, replace |maxY| and |startMaxY| with 163 // If we need to lay out the tab strip, replace |maxY| and |startMaxY| with
158 // higher values, and then lay out the tab strip. 164 // higher values, and then lay out the tab strip.
159 NSRect windowFrame = [contentView convertRect:[window frame] fromView:nil]; 165 NSRect windowFrame = [contentView convertRect:[window frame] fromView:nil];
160 startMaxY = maxY = NSHeight(windowFrame) + yOffset; 166 startMaxY = maxY = NSHeight(windowFrame) + yOffset;
161 maxY = [self layoutTabStripAtMaxY:maxY width:width fullscreen:isFullscreen]; 167 maxY = [self layoutTabStripAtMaxY:maxY width:width fullscreen:isFullscreen];
162 } 168 }
163 169
164 // Sanity-check |maxY|. 170 // Sanity-check |maxY|.
165 DCHECK_GE(maxY, minY); 171 DCHECK_GE(maxY, minY);
166 DCHECK_LE(maxY, NSMaxY(contentBounds) + yOffset); 172 DCHECK_LE(maxY, NSMaxY(contentBounds) + yOffset);
167 173
168 // Place the toolbar at the top of the reserved area. 174 // Place the toolbar at the top of the reserved area. Even with vertical
175 // tabs enabled, the toolbar takes up the entire top width.
rohitrao (ping after 24h) 2010/06/02 13:45:56 Looking at the mocks you sent me, I'd argue that t
169 maxY = [self layoutToolbarAtMaxY:maxY width:width]; 176 maxY = [self layoutToolbarAtMaxY:maxY width:width];
170 177
178 // Position the vertical tab strip on the left, taking up the entire remaining
179 // height.
180 // TODO(pinkerton): Make width not fixed.
181 const CGFloat kSidebarWidth = 200.0;
182 if ([self useVerticalTabs]) {
183 // XXXPINK position the side bar at |minX|.
rohitrao (ping after 24h) 2010/06/02 13:45:56 TODO?
184
185 // Push everything else over to the right.
186 minX += kSidebarWidth;
187 width -= kSidebarWidth;
188 }
189
171 // If we're not displaying the bookmark bar below the infobar, then it goes 190 // If we're not displaying the bookmark bar below the infobar, then it goes
172 // immediately below the toolbar. 191 // immediately below the toolbar.
173 BOOL placeBookmarkBarBelowInfoBar = [self placeBookmarkBarBelowInfoBar]; 192 BOOL placeBookmarkBarBelowInfoBar = [self placeBookmarkBarBelowInfoBar];
174 if (!placeBookmarkBarBelowInfoBar) 193 if (!placeBookmarkBarBelowInfoBar)
175 maxY = [self layoutBookmarkBarAtMaxY:maxY width:width]; 194 maxY = [self layoutBookmarkBarAtMinX:minX maxY:maxY width:width];
176 195
177 // The floating bar backing view doesn't actually add any height. 196 // The floating bar backing view doesn't actually add any height.
rohitrao (ping after 24h) 2010/06/02 13:45:56 This is fine for now, but we'll probably end up re
178 [self layoutFloatingBarBackingViewAtY:maxY 197 NSRect floatingBarBackingRect =
179 width:width 198 NSMakeRect(minX, minY, width, floatingBarHeight);
180 height:floatingBarHeight 199 [self layoutFloatingBarBackingView:floatingBarBackingRect
181 fullscreen:isFullscreen]; 200 fullscreen:isFullscreen];
182 201
183 // Place the find bar immediately below the toolbar/attached bookmark bar. In 202 // Place the find bar immediately below the toolbar/attached bookmark bar. In
184 // fullscreen mode, it hangs off the top of the screen when the bar is hidden. 203 // fullscreen mode, it hangs off the top of the screen when the bar is hidden.
204 // The find bar is unaffected by the side tab positioning.
185 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:width]; 205 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:width];
186 206
187 // If in fullscreen mode, reset |maxY| to top of screen, so that the floating 207 // If in fullscreen mode, reset |maxY| to top of screen, so that the floating
188 // bar slides over the things which appear to be in the content area. 208 // bar slides over the things which appear to be in the content area.
189 if (isFullscreen) 209 if (isFullscreen)
190 maxY = NSMaxY(contentBounds); 210 maxY = NSMaxY(contentBounds);
191 211
192 // Also place the infobar container immediate below the toolbar, except in 212 // Also place the infobar container immediate below the toolbar, except in
193 // fullscreen mode in which case it's at the top of the visual content area. 213 // fullscreen mode in which case it's at the top of the visual content area.
194 maxY = [self layoutInfoBarAtMaxY:maxY width:width]; 214 maxY = [self layoutInfoBarAtMinX:minX maxY:maxY width:width];
195 215
196 // If the bookmark bar is detached, place it next in the visual content area. 216 // If the bookmark bar is detached, place it next in the visual content area.
197 if (placeBookmarkBarBelowInfoBar) 217 if (placeBookmarkBarBelowInfoBar)
198 maxY = [self layoutBookmarkBarAtMaxY:maxY width:width]; 218 maxY = [self layoutBookmarkBarAtMinX:minX maxY:maxY width:width];
199 219
200 // Place the download shelf, if any, at the bottom of the view. 220 // Place the download shelf, if any, at the bottom of the view.
201 minY = [self layoutDownloadShelfAtMinY:minY width:width]; 221 minY = [self layoutDownloadShelfAtMinX:minX minY:minY width:width];
202 222
203 // Finally, the content area takes up all of the remaining space. 223 // Finally, the content area takes up all of the remaining space.
204 [self layoutTabContentAreaAtMinY:minY maxY:maxY width:width]; 224 NSRect contentAreaRect = NSMakeRect(minX, minY, width, maxY - minY);
225 [self layoutTabContentArea:contentAreaRect];
205 226
206 // Place the status bubble at the bottom of the content area. 227 // Place the status bubble at the bottom of the content area.
207 verticalOffsetForStatusBubble_ = minY; 228 verticalOffsetForStatusBubble_ = minY;
208 229
209 // Normally, we don't need to tell the toolbar whether or not to show the 230 // Normally, we don't need to tell the toolbar whether or not to show the
210 // divider, but things break down during animation. 231 // divider, but things break down during animation.
211 [toolbarController_ 232 [toolbarController_
212 setDividerOpacity:[bookmarkBarController_ toolbarDividerOpacity]]; 233 setDividerOpacity:[bookmarkBarController_ toolbarDividerOpacity]];
213 } 234 }
214 235
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 319
299 - (BOOL)placeBookmarkBarBelowInfoBar { 320 - (BOOL)placeBookmarkBarBelowInfoBar {
300 // If we are currently displaying the NTP detached bookmark bar or animating 321 // If we are currently displaying the NTP detached bookmark bar or animating
301 // to/from it (from/to anything else), we display the bookmark bar below the 322 // to/from it (from/to anything else), we display the bookmark bar below the
302 // infobar. 323 // infobar.
303 return [bookmarkBarController_ isInState:bookmarks::kDetachedState] || 324 return [bookmarkBarController_ isInState:bookmarks::kDetachedState] ||
304 [bookmarkBarController_ isAnimatingToState:bookmarks::kDetachedState] || 325 [bookmarkBarController_ isAnimatingToState:bookmarks::kDetachedState] ||
305 [bookmarkBarController_ isAnimatingFromState:bookmarks::kDetachedState]; 326 [bookmarkBarController_ isAnimatingFromState:bookmarks::kDetachedState];
306 } 327 }
307 328
308 - (CGFloat)layoutBookmarkBarAtMaxY:(CGFloat)maxY width:(CGFloat)width { 329 - (CGFloat)layoutBookmarkBarAtMinX:(CGFloat)minX
330 maxY:(CGFloat)maxY
331 width:(CGFloat)width {
309 NSView* bookmarkBarView = [bookmarkBarController_ view]; 332 NSView* bookmarkBarView = [bookmarkBarController_ view];
310 NSRect bookmarkBarFrame = [bookmarkBarView frame]; 333 NSRect bookmarkBarFrame = [bookmarkBarView frame];
311 BOOL oldHidden = [bookmarkBarView isHidden]; 334 BOOL oldHidden = [bookmarkBarView isHidden];
312 BOOL newHidden = ![self isBookmarkBarVisible]; 335 BOOL newHidden = ![self isBookmarkBarVisible];
313 if (oldHidden != newHidden) 336 if (oldHidden != newHidden)
314 [bookmarkBarView setHidden:newHidden]; 337 [bookmarkBarView setHidden:newHidden];
338 bookmarkBarFrame.origin.x = minX;
315 bookmarkBarFrame.origin.y = maxY - NSHeight(bookmarkBarFrame); 339 bookmarkBarFrame.origin.y = maxY - NSHeight(bookmarkBarFrame);
316 bookmarkBarFrame.size.width = width; 340 bookmarkBarFrame.size.width = width;
317 [bookmarkBarView setFrame:bookmarkBarFrame]; 341 [bookmarkBarView setFrame:bookmarkBarFrame];
318 maxY -= NSHeight(bookmarkBarFrame); 342 maxY -= NSHeight(bookmarkBarFrame);
319 343
320 // TODO(viettrungluu): Does this really belong here? Calling it shouldn't be 344 // TODO(viettrungluu): Does this really belong here? Calling it shouldn't be
321 // necessary in the non-NTP case. 345 // necessary in the non-NTP case.
322 [bookmarkBarController_ layoutSubviews]; 346 [bookmarkBarController_ layoutSubviews];
323 347
324 return maxY; 348 return maxY;
325 } 349 }
326 350
327 - (void)layoutFloatingBarBackingViewAtY:(CGFloat)y 351 - (void)layoutFloatingBarBackingView:(NSRect)frame
328 width:(CGFloat)width 352 fullscreen:(BOOL)fullscreen {
329 height:(CGFloat)height
330 fullscreen:(BOOL)fullscreen {
331 // Only display when in fullscreen mode. 353 // Only display when in fullscreen mode.
332 if (fullscreen) { 354 if (fullscreen) {
333 // For certain window types such as app windows (e.g., the dev tools 355 // For certain window types such as app windows (e.g., the dev tools
334 // window), there's no actual overlay. (Displaying one would result in an 356 // window), there's no actual overlay. (Displaying one would result in an
335 // overly sliding in only under the menu, which gives an ugly effect.) 357 // overly sliding in only under the menu, which gives an ugly effect.)
336 NSRect frame = NSMakeRect(0, y, width, height);
337 if (floatingBarBackingView_.get()) { 358 if (floatingBarBackingView_.get()) {
338 BOOL aboveBookmarkBar = [self placeBookmarkBarBelowInfoBar]; 359 BOOL aboveBookmarkBar = [self placeBookmarkBarBelowInfoBar];
339 360
340 // Insert it into the view hierarchy if necessary. 361 // Insert it into the view hierarchy if necessary.
341 if (![floatingBarBackingView_ superview] || 362 if (![floatingBarBackingView_ superview] ||
342 aboveBookmarkBar != floatingBarAboveBookmarkBar_) { 363 aboveBookmarkBar != floatingBarAboveBookmarkBar_) {
343 NSView* contentView = [[self window] contentView]; 364 NSView* contentView = [[self window] contentView];
344 // z-order gets messed up unless we explicitly remove the floatingbar 365 // z-order gets messed up unless we explicitly remove the floatingbar
345 // view and re-add it. 366 // view and re-add it.
346 [floatingBarBackingView_ removeFromSuperview]; 367 [floatingBarBackingView_ removeFromSuperview];
(...skipping 10 matching lines...) Expand all
357 378
358 // But we want the logic to work as usual (for show/hide/etc. purposes). 379 // But we want the logic to work as usual (for show/hide/etc. purposes).
359 [fullscreenController_ overlayFrameChanged:frame]; 380 [fullscreenController_ overlayFrameChanged:frame];
360 } else { 381 } else {
361 // Okay to call even if |floatingBarBackingView_| is nil. 382 // Okay to call even if |floatingBarBackingView_| is nil.
362 if ([floatingBarBackingView_ superview]) 383 if ([floatingBarBackingView_ superview])
363 [floatingBarBackingView_ removeFromSuperview]; 384 [floatingBarBackingView_ removeFromSuperview];
364 } 385 }
365 } 386 }
366 387
367 - (CGFloat)layoutInfoBarAtMaxY:(CGFloat)maxY width:(CGFloat)width { 388 - (CGFloat)layoutInfoBarAtMinX:(CGFloat)minX
389 maxY:(CGFloat)maxY
390 width:(CGFloat)width {
368 NSView* infoBarView = [infoBarContainerController_ view]; 391 NSView* infoBarView = [infoBarContainerController_ view];
369 NSRect infoBarFrame = [infoBarView frame]; 392 NSRect infoBarFrame = [infoBarView frame];
393 infoBarFrame.origin.x = minX;
370 infoBarFrame.origin.y = maxY - NSHeight(infoBarFrame); 394 infoBarFrame.origin.y = maxY - NSHeight(infoBarFrame);
371 infoBarFrame.size.width = width; 395 infoBarFrame.size.width = width;
372 [infoBarView setFrame:infoBarFrame]; 396 [infoBarView setFrame:infoBarFrame];
373 maxY -= NSHeight(infoBarFrame); 397 maxY -= NSHeight(infoBarFrame);
374 return maxY; 398 return maxY;
375 } 399 }
376 400
377 - (CGFloat)layoutDownloadShelfAtMinY:(CGFloat)minY width:(CGFloat)width { 401 - (CGFloat)layoutDownloadShelfAtMinX:(CGFloat)minX
402 minY:(CGFloat)minY
403 width:(CGFloat)width {
378 if (downloadShelfController_.get()) { 404 if (downloadShelfController_.get()) {
379 NSView* downloadView = [downloadShelfController_ view]; 405 NSView* downloadView = [downloadShelfController_ view];
380 NSRect downloadFrame = [downloadView frame]; 406 NSRect downloadFrame = [downloadView frame];
407 downloadFrame.origin.x = minX;
381 downloadFrame.origin.y = minY; 408 downloadFrame.origin.y = minY;
382 downloadFrame.size.width = width; 409 downloadFrame.size.width = width;
383 [downloadView setFrame:downloadFrame]; 410 [downloadView setFrame:downloadFrame];
384 minY += NSHeight(downloadFrame); 411 minY += NSHeight(downloadFrame);
385 } 412 }
386 return minY; 413 return minY;
387 } 414 }
388 415
389 - (void)layoutTabContentAreaAtMinY:(CGFloat)minY 416 - (void)layoutTabContentArea:(NSRect)newFrame {
390 maxY:(CGFloat)maxY
391 width:(CGFloat)width {
392 NSView* tabContentView = [self tabContentArea]; 417 NSView* tabContentView = [self tabContentArea];
393 NSRect tabContentFrame = [tabContentView frame]; 418 NSRect tabContentFrame = [tabContentView frame];
394 419
395 bool contentShifted = NSMaxY(tabContentFrame) != maxY; 420 bool contentShifted = NSMaxY(tabContentFrame) != NSMaxY(newFrame);
rohitrao (ping after 24h) 2010/06/02 13:45:56 Do you know the difference between "==" and "NSEqu
396 421
397 tabContentFrame.origin.y = minY; 422 tabContentFrame = newFrame;
398 tabContentFrame.size.height = maxY - minY;
399 tabContentFrame.size.width = width;
400 [tabContentView setFrame:tabContentFrame]; 423 [tabContentView setFrame:tabContentFrame];
401 424
402 // If the relayout shifts the content area up or down, let the renderer know. 425 // If the relayout shifts the content area up or down, let the renderer know.
403 if (contentShifted) { 426 if (contentShifted) {
404 if (TabContents* contents = browser_->GetSelectedTabContents()) { 427 if (TabContents* contents = browser_->GetSelectedTabContents()) {
405 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 428 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
406 rwhv->WindowFrameChanged(); 429 rwhv->WindowFrameChanged();
407 } 430 }
408 } 431 }
409 } 432 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 487
465 - (void)disableBarVisibilityUpdates { 488 - (void)disableBarVisibilityUpdates {
466 // Early escape if there's nothing to do. 489 // Early escape if there's nothing to do.
467 if (!barVisibilityUpdatesEnabled_) 490 if (!barVisibilityUpdatesEnabled_)
468 return; 491 return;
469 492
470 barVisibilityUpdatesEnabled_ = NO; 493 barVisibilityUpdatesEnabled_ = NO;
471 [fullscreenController_ cancelAnimationAndTimers]; 494 [fullscreenController_ cancelAnimationAndTimers];
472 } 495 }
473 496
497 // Removes existing toolbar and re-creates the appropriate toolbar controller
498 // based on if vertical tabs are enabled.
499 - (void)initializeToolbarWithBrowser:(Browser*)browser {
500 // Remove existing view.
501 [[toolbarController_ view] removeFromSuperview];
502 toolbarController_.reset(nil);
503
504 // Create appropriate toolbar controller.
505 if ([self useVerticalTabs]) {
506 toolbarController_.reset([[SideTabsToolbarController alloc]
507 initWithModel:browser->toolbar_model()
508 commands:browser->command_updater()
509 profile:browser->profile()
510 browser:browser
511 resizeDelegate:self]);
512 } else {
513 toolbarController_.reset([[ToolbarController alloc]
514 initWithModel:browser->toolbar_model()
515 commands:browser->command_updater()
516 profile:browser->profile()
517 browser:browser
518 resizeDelegate:self]);
519 }
520 [toolbarController_ setHasToolbar:[self hasToolbar]
521 hasLocationBar:[self hasLocationBar]];
522 [[[self window] contentView] addSubview:[toolbarController_ view]];
523 }
524
474 @end // @implementation BrowserWindowController(Private) 525 @end // @implementation BrowserWindowController(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698