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

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

Issue 3136003: [Mac] Refactor the fullscreen code to move logic from BWC into FullscreenCont... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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.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.h" 9 #include "app/l10n_util.h"
10 #include "app/l10n_util_mac.h" 10 #include "app/l10n_util_mac.h"
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 - (void)windowDidBecomeMain:(NSNotification*)notification { 439 - (void)windowDidBecomeMain:(NSNotification*)notification {
440 BrowserList::SetLastActive(browser_.get()); 440 BrowserList::SetLastActive(browser_.get());
441 [self saveWindowPositionIfNeeded]; 441 [self saveWindowPositionIfNeeded];
442 442
443 // TODO(dmaclach): Instead of redrawing the whole window, views that care 443 // TODO(dmaclach): Instead of redrawing the whole window, views that care
444 // about the active window state should be registering for notifications. 444 // about the active window state should be registering for notifications.
445 [[self window] setViewsNeedDisplay:YES]; 445 [[self window] setViewsNeedDisplay:YES];
446 446
447 // TODO(viettrungluu): For some reason, the above doesn't suffice. 447 // TODO(viettrungluu): For some reason, the above doesn't suffice.
448 if ([self isFullscreen]) 448 if ([self isFullscreen])
449 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil. 449 [[fullscreenController_ floatingBarBackingView] setNeedsDisplay:YES];
450 } 450 }
451 451
452 - (void)windowDidResignMain:(NSNotification*)notification { 452 - (void)windowDidResignMain:(NSNotification*)notification {
453 // TODO(dmaclach): Instead of redrawing the whole window, views that care 453 // TODO(dmaclach): Instead of redrawing the whole window, views that care
454 // about the active window state should be registering for notifications. 454 // about the active window state should be registering for notifications.
455 [[self window] setViewsNeedDisplay:YES]; 455 [[self window] setViewsNeedDisplay:YES];
456 456
457 // TODO(viettrungluu): For some reason, the above doesn't suffice. 457 // TODO(viettrungluu): For some reason, the above doesn't suffice.
458 if ([self isFullscreen]) 458 if ([self isFullscreen])
459 [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil. 459 [[fullscreenController_ floatingBarBackingView] setNeedsDisplay:YES];
460 } 460 }
461 461
462 // Called when we are activated (when we gain focus). 462 // Called when we are activated (when we gain focus).
463 - (void)windowDidBecomeKey:(NSNotification*)notification { 463 - (void)windowDidBecomeKey:(NSNotification*)notification {
464 // We need to activate the controls (in the "WebView"). To do this, get the 464 // We need to activate the controls (in the "WebView"). To do this, get the
465 // selected TabContents's RenderWidgetHostViewMac and tell it to activate. 465 // selected TabContents's RenderWidgetHostViewMac and tell it to activate.
466 if (TabContents* contents = browser_->GetSelectedTabContents()) { 466 if (TabContents* contents = browser_->GetSelectedTabContents()) {
467 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) 467 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
468 rwhv->SetActive(true); 468 rwhv->SetActive(true);
469 } 469 }
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 1261
1262 // Place the find bar immediately below the toolbar/attached bookmark bar. In 1262 // Place the find bar immediately below the toolbar/attached bookmark bar. In
1263 // fullscreen mode, it hangs off the top of the screen when the bar is hidden. 1263 // fullscreen mode, it hangs off the top of the screen when the bar is hidden.
1264 CGFloat maxY = [self placeBookmarkBarBelowInfoBar] ? 1264 CGFloat maxY = [self placeBookmarkBarBelowInfoBar] ?
1265 NSMinY([[toolbarController_ view] frame]) : 1265 NSMinY([[toolbarController_ view] frame]) :
1266 NSMinY([[bookmarkBarController_ view] frame]); 1266 NSMinY([[bookmarkBarController_ view] frame]);
1267 CGFloat maxWidth = NSWidth([contentView frame]); 1267 CGFloat maxWidth = NSWidth([contentView frame]);
1268 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; 1268 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:maxWidth];
1269 } 1269 }
1270 1270
1271 - (NSWindow*)createFullscreenWindow {
1272 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]]
1273 autorelease];
1274 }
1275
1276 - (NSInteger)numberOfTabs { 1271 - (NSInteger)numberOfTabs {
1277 // count() includes pinned tabs (both live and phantom). 1272 // count() includes pinned tabs (both live and phantom).
1278 return browser_->tabstrip_model()->count(); 1273 return browser_->tabstrip_model()->count();
1279 } 1274 }
1280 1275
1281 - (BOOL)hasLiveTabs { 1276 - (BOOL)hasLiveTabs {
1282 return browser_->tabstrip_model()->HasNonPhantomTabs(); 1277 return browser_->tabstrip_model()->HasNonPhantomTabs();
1283 } 1278 }
1284 1279
1285 - (NSString*)selectedTabTitle { 1280 - (NSString*)selectedTabTitle {
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 scoped_nsobject<NSView> contentView([[window contentView] retain]); 1704 scoped_nsobject<NSView> contentView([[window contentView] retain]);
1710 // Disable autoresizing of subviews while we move views around. This prevents 1705 // Disable autoresizing of subviews while we move views around. This prevents
1711 // spurious renderer resizes. 1706 // spurious renderer resizes.
1712 [contentView setAutoresizesSubviews:NO]; 1707 [contentView setAutoresizesSubviews:NO];
1713 [contentView removeFromSuperview]; 1708 [contentView removeFromSuperview];
1714 1709
1715 NSWindow* destWindow = nil; 1710 NSWindow* destWindow = nil;
1716 if (fullscreen) { 1711 if (fullscreen) {
1717 DCHECK(!savedRegularWindow_); 1712 DCHECK(!savedRegularWindow_);
1718 savedRegularWindow_ = [window retain]; 1713 savedRegularWindow_ = [window retain];
1719 destWindow = [self createFullscreenWindow]; 1714 destWindow = [fullscreenController_ window];
1720 } else { 1715 } else {
1721 DCHECK(savedRegularWindow_); 1716 DCHECK(savedRegularWindow_);
1722 destWindow = [savedRegularWindow_ autorelease]; 1717 destWindow = [savedRegularWindow_ autorelease];
1723 savedRegularWindow_ = nil; 1718 savedRegularWindow_ = nil;
1724 } 1719 }
1725 DCHECK(destWindow); 1720 DCHECK(destWindow);
1726 1721
1727 // Have to do this here, otherwise later calls can crash because the window 1722 // Have to do this here, otherwise later calls can crash because the window
1728 // has no delegate. 1723 // has no delegate.
1729 [window setDelegate:nil]; 1724 [window setDelegate:nil];
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 - (void)resizeFullscreenWindow { 1785 - (void)resizeFullscreenWindow {
1791 DCHECK([self isFullscreen]); 1786 DCHECK([self isFullscreen]);
1792 if (![self isFullscreen]) 1787 if (![self isFullscreen])
1793 return; 1788 return;
1794 1789
1795 NSWindow* window = [self window]; 1790 NSWindow* window = [self window];
1796 [window setFrame:[[window screen] frame] display:YES]; 1791 [window setFrame:[[window screen] frame] display:YES];
1797 [self layoutSubviews]; 1792 [self layoutSubviews];
1798 } 1793 }
1799 1794
1800 - (CGFloat)floatingBarShownFraction { 1795 - (void)floatingBarShownFractionChanged {
1801 return floatingBarShownFraction_;
1802 }
1803
1804 - (void)setFloatingBarShownFraction:(CGFloat)fraction {
1805 floatingBarShownFraction_ = fraction;
1806 [self layoutSubviews]; 1796 [self layoutSubviews];
1807 } 1797 }
1808 1798
1809 - (BOOL)isBarVisibilityLockedForOwner:(id)owner { 1799 - (BOOL)isBarVisibilityLockedForOwner:(id)owner {
1810 DCHECK(owner); 1800 DCHECK(owner);
1811 DCHECK(barVisibilityLocks_); 1801 DCHECK(barVisibilityLocks_);
1812 return [barVisibilityLocks_ containsObject:owner]; 1802 return [barVisibilityLocks_ containsObject:owner];
1813 } 1803 }
1814 1804
1815 - (void)lockBarVisibilityForOwner:(id)owner 1805 - (void)lockBarVisibilityForOwner:(id)owner
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 1880
1891 - (BOOL)supportsBookmarkBar { 1881 - (BOOL)supportsBookmarkBar {
1892 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 1882 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
1893 } 1883 }
1894 1884
1895 - (BOOL)isNormalWindow { 1885 - (BOOL)isNormalWindow {
1896 return browser_->type() == Browser::TYPE_NORMAL; 1886 return browser_->type() == Browser::TYPE_NORMAL;
1897 } 1887 }
1898 1888
1899 @end // @implementation BrowserWindowController(WindowType) 1889 @end // @implementation BrowserWindowController(WindowType)
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.h ('k') | chrome/browser/cocoa/browser_window_controller_private.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698