OLD | NEW |
---|---|
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.h" | 5 #import "chrome/browser/cocoa/browser_window_controller.h" |
6 | 6 |
7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
8 | 8 |
9 #include "app/l10n_util_mac.h" | 9 #include "app/l10n_util_mac.h" |
10 #include "base/mac_util.h" | 10 #include "base/mac_util.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 | 226 |
227 windowShim_->SetBounds(windowRect); | 227 windowShim_->SetBounds(windowRect); |
228 | 228 |
229 // Puts the incognito badge on the window frame, if necessary. | 229 // Puts the incognito badge on the window frame, if necessary. |
230 [self installIncognitoBadge]; | 230 [self installIncognitoBadge]; |
231 | 231 |
232 // Create a controller for the tab strip, giving it the model object for | 232 // Create a controller for the tab strip, giving it the model object for |
233 // this window's Browser and the tab strip view. The controller will handle | 233 // this window's Browser and the tab strip view. The controller will handle |
234 // registering for the appropriate tab notifications from the back-end and | 234 // registering for the appropriate tab notifications from the back-end and |
235 // managing the creation of new tabs. | 235 // managing the creation of new tabs. |
236 tabStripController_.reset([[TabStripController alloc] | 236 if (![self useVerticalTabs]) { |
237 initWithView:[self tabStripView] | 237 tabStripController_.reset([[TabStripController alloc] |
238 switchView:[self tabContentArea] | 238 initWithView:[self tabStripView] |
239 browser:browser_.get()]); | 239 switchView:[self tabContentArea] |
240 browser:browser_.get()]); | |
241 } else { | |
242 // XXXPINK: load SideTabController when written and add it to the | |
rohitrao (ping after 24h)
2010/06/02 13:45:56
Is this a TODO or a DO NOT SUBMIT?
| |
243 // contentView. | |
244 } | |
240 | 245 |
241 // Create the infobar container view, so we can pass it to the | 246 // Create the infobar container view, so we can pass it to the |
242 // ToolbarController. | 247 // ToolbarController. |
243 infoBarContainerController_.reset( | 248 infoBarContainerController_.reset( |
244 [[InfoBarContainerController alloc] | 249 [[InfoBarContainerController alloc] |
245 initWithTabStripModel:(browser_->tabstrip_model()) | 250 initWithTabStripModel:(browser_->tabstrip_model()) |
246 resizeDelegate:self]); | 251 resizeDelegate:self]); |
247 [[[self window] contentView] addSubview:[infoBarContainerController_ view]]; | 252 [[[self window] contentView] addSubview:[infoBarContainerController_ view]]; |
248 | 253 |
249 // Create a controller for the toolbar, giving it the toolbar model object | 254 // Create a controller for the toolbar, giving it the toolbar model object |
250 // and the toolbar view from the nib. The controller will handle | 255 // and the toolbar view from the nib. The controller will handle |
251 // registering for the appropriate command state changes from the back-end. | 256 // registering for the appropriate command state changes from the back-end. |
252 toolbarController_.reset([[ToolbarController alloc] | 257 // Adds the toolbar to the content area. |
253 initWithModel:browser->toolbar_model() | 258 [self initializeToolbarWithBrowser:browser]; |
254 commands:browser->command_updater() | |
255 profile:browser->profile() | |
256 browser:browser | |
257 resizeDelegate:self]); | |
258 [toolbarController_ setHasToolbar:[self hasToolbar] | |
259 hasLocationBar:[self hasLocationBar]]; | |
260 [[[self window] contentView] addSubview:[toolbarController_ view]]; | |
261 | 259 |
262 // Create a sub-controller for the bookmark bar. | 260 // Create a sub-controller for the bookmark bar. |
263 bookmarkBarController_.reset( | 261 bookmarkBarController_.reset( |
264 [[BookmarkBarController alloc] | 262 [[BookmarkBarController alloc] |
265 initWithBrowser:browser_.get() | 263 initWithBrowser:browser_.get() |
266 initialWidth:NSWidth([[[self window] contentView] frame]) | 264 initialWidth:NSWidth([[[self window] contentView] frame]) |
267 delegate:self | 265 delegate:self |
268 resizeDelegate:self]); | 266 resizeDelegate:self]); |
269 | 267 |
270 // Add bookmark bar to the view hierarchy, which also triggers the nib load. | 268 // Add bookmark bar to the view hierarchy, which also triggers the nib load. |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1282 return base::SysUTF16ToNSString(contents->GetTitle()); | 1280 return base::SysUTF16ToNSString(contents->GetTitle()); |
1283 } | 1281 } |
1284 | 1282 |
1285 - (NSRect)regularWindowFrame { | 1283 - (NSRect)regularWindowFrame { |
1286 return [self isFullscreen] ? [savedRegularWindow_ frame] : | 1284 return [self isFullscreen] ? [savedRegularWindow_ frame] : |
1287 [[self window] frame]; | 1285 [[self window] frame]; |
1288 } | 1286 } |
1289 | 1287 |
1290 // (Override of |TabWindowController| method.) | 1288 // (Override of |TabWindowController| method.) |
1291 - (BOOL)hasTabStrip { | 1289 - (BOOL)hasTabStrip { |
1290 if ([self useVerticalTabs]) | |
1291 return NO; | |
1292 return [self supportsWindowFeature:Browser::FEATURE_TABSTRIP]; | 1292 return [self supportsWindowFeature:Browser::FEATURE_TABSTRIP]; |
1293 } | 1293 } |
1294 | 1294 |
1295 - (void)selectTabWithContents:(TabContents*)newContents | 1295 - (void)selectTabWithContents:(TabContents*)newContents |
1296 previousContents:(TabContents*)oldContents | 1296 previousContents:(TabContents*)oldContents |
1297 atIndex:(NSInteger)index | 1297 atIndex:(NSInteger)index |
1298 userGesture:(bool)wasUserGesture { | 1298 userGesture:(bool)wasUserGesture { |
1299 DCHECK(oldContents != newContents); | 1299 DCHECK(oldContents != newContents); |
1300 | 1300 |
1301 // Update various elements that are interested in knowing the current | 1301 // Update various elements that are interested in knowing the current |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1618 [controller getDesiredToolbarHeightCompression]]; | 1618 [controller getDesiredToolbarHeightCompression]]; |
1619 } | 1619 } |
1620 | 1620 |
1621 // (Private/TestingAPI) | 1621 // (Private/TestingAPI) |
1622 - (void)resetWindowGrowthState { | 1622 - (void)resetWindowGrowthState { |
1623 windowTopGrowth_ = 0; | 1623 windowTopGrowth_ = 0; |
1624 windowBottomGrowth_ = 0; | 1624 windowBottomGrowth_ = 0; |
1625 isShrinkingFromZoomed_ = NO; | 1625 isShrinkingFromZoomed_ = NO; |
1626 } | 1626 } |
1627 | 1627 |
1628 - (void)tabStripDisplayModeChanged { | |
1629 //XXXPINK re-initialize tab strip | |
rohitrao (ping after 24h)
2010/06/02 13:45:56
TODO?
This method is only half written, right? W
| |
1630 // [self initTabStrip:browser_->tabstrip_model()]; | |
1631 [[self tabStripView] removeFromSuperview]; | |
1632 [self initializeToolbarWithBrowser:browser_.get()]; | |
1633 | |
1634 [self layoutSubviews]; | |
1635 } | |
1636 | |
1628 @end // @implementation BrowserWindowController | 1637 @end // @implementation BrowserWindowController |
1629 | 1638 |
1630 | 1639 |
1631 @implementation BrowserWindowController(Fullscreen) | 1640 @implementation BrowserWindowController(Fullscreen) |
1632 | 1641 |
1633 - (void)setFullscreen:(BOOL)fullscreen { | 1642 - (void)setFullscreen:(BOOL)fullscreen { |
1634 // The logic in this function is a bit complicated and very carefully | 1643 // The logic in this function is a bit complicated and very carefully |
1635 // arranged. See the below comments for more details. | 1644 // arranged. See the below comments for more details. |
1636 | 1645 |
1637 if (fullscreen == [self isFullscreen]) | 1646 if (fullscreen == [self isFullscreen]) |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1846 | 1855 |
1847 - (BOOL)supportsBookmarkBar { | 1856 - (BOOL)supportsBookmarkBar { |
1848 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 1857 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
1849 } | 1858 } |
1850 | 1859 |
1851 - (BOOL)isNormalWindow { | 1860 - (BOOL)isNormalWindow { |
1852 return browser_->type() == Browser::TYPE_NORMAL; | 1861 return browser_->type() == Browser::TYPE_NORMAL; |
1853 } | 1862 } |
1854 | 1863 |
1855 @end // @implementation BrowserWindowController(WindowType) | 1864 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |