diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-29 23:56:11 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-29 23:56:11 +0000 |
commit | 893a5ccce13082aa85686ad142c0d8be0fb5cd70 (patch) | |
tree | 018c75351b722e9ae8258dcff804a53d6c422d65 /chrome/browser | |
parent | c3a7368e76527e15c1f2d2f06801a371bb5374e3 (diff) | |
download | chromium_src-893a5ccce13082aa85686ad142c0d8be0fb5cd70.zip chromium_src-893a5ccce13082aa85686ad142c0d8be0fb5cd70.tar.gz chromium_src-893a5ccce13082aa85686ad142c0d8be0fb5cd70.tar.bz2 |
Mac fullscreen mode (with pkasting).
TEST=Launch Chrome. Create a 2nd tab. Close bookmark bar.
Cmd-F11 to enter fullscreen; make sure content is centered and both
bookmark bar and toolbar are gone. Make sure menubar gone.
Cmd-Opt-arrows to switch tabs; make sure still OK.
Cmd-F11 to go back; make sure things look normal.
Open bookmark bar.
Cmd-F11; make sure gone. Cmd-F11 again; make sure it comes back.
Confirm View-->Fullscreen menu item works.
While in fullscreen, Cmd-T to create new tab and click on a fav tile.
Make sure page loads.
While in fullscreen, try window hotkeys (Cmd-N and Cmd-W) to make sure
they work. Cmd-` to switch windows; switch back, then Cmd-F11 to
undo fullscreen.
Move the mouse to to the top of the screen; make sure menubar appears.
Move the mouse down; make sure menubar goes away.
Review URL: http://codereview.chromium.org/126294
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19559 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.h | 20 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.mm | 71 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.mm | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa_unittest.mm | 30 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.h | 11 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 108 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller_unittest.mm | 27 | ||||
-rw-r--r-- | chrome/browser/cocoa/fullscreen_window.h | 19 | ||||
-rw-r--r-- | chrome/browser/cocoa/fullscreen_window.mm | 43 | ||||
-rw-r--r-- | chrome/browser/cocoa/fullscreen_window_unittest.mm | 27 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_contents_controller.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/tab_contents_controller.mm | 8 |
12 files changed, 320 insertions, 52 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.h b/chrome/browser/cocoa/bookmark_bar_controller.h index 87ac43e..d7a93d4 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.h +++ b/chrome/browser/cocoa/bookmark_bar_controller.h @@ -16,6 +16,7 @@ class BookmarkModel; class BookmarkNode; @class BookmarkBarView; class Profile; +class PrefService; // The interface for an object which can open URLs for a bookmark. @protocol BookmarkURLOpener @@ -30,12 +31,18 @@ class Profile; @private BookmarkModel* bookmarkModel_; // weak; part of the profile owned by the // top-level Browser object. + PrefService* preferences_; // (ditto) - // Currently these two are always the same, but they mean slightly - // different things. contentAreaHasOffset_ is an implementation - // detail of bookmark bar visibility. + // Currently these two are always the same when not in fullscreen + // mode, but they mean slightly different things. + // contentAreaHasOffset_ is an implementation detail of bookmark bar + // show state. BOOL contentViewHasOffset_; - BOOL barIsVisible_; + BOOL barShouldBeShown_; + + // If the bar is disabled, we hide it and ignore show/hide commands. + // Set when using fullscreen mode. + BOOL barIsEnabled_; // The view of the bookmark bar itself. // Not made into a scoped_nsobject since I may move it into a nib. @@ -70,6 +77,11 @@ class Profile; // Toggle the state of the bookmark bar. - (void)toggleBookmarkBar; +// Turn on or off the bookmark bar and prevent or reallow its +// appearance. On disable, toggle off if shown. On enable, show only +// if needed. For fullscreen mode. +- (void)setBookmarkBarEnabled:(BOOL)enabled; + @end // Redirects from BookmarkBarBridge, the C++ object which glues us to diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm index e3a4bed..d2805ec 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -16,9 +16,9 @@ #include "skia/ext/skia_utils_mac.h" @interface BookmarkBarController(Private) -- (void)applyContentAreaOffset:(BOOL)apply; +- (void)applyContentAreaOffset:(BOOL)apply immediately:(BOOL)immediately; - (void)positionBar; -- (void)showBookmarkBar:(BOOL)enable; +- (void)showBookmarkBar:(BOOL)enable immediately:(BOOL)immediately; @end namespace { @@ -38,13 +38,16 @@ const CGFloat kBookmarkHorizontalPadding = 8.0; bookmarkModel_ = profile->GetBookmarkModel(); contentView_ = content; delegate_ = delegate; + // Be sure to enable the bar before trying to show it... + barIsEnabled_ = YES; // Create and initialize the view's position. Show it if appropriate. // TODO(jrg): put it in a nib if necessary. NSRect frame = NSMakeRect(0, 0, 0, 30); bookmarkBarView_ = [[BookmarkBarView alloc] initWithFrame:frame]; [self positionBar]; - if (profile->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar)) - [self showBookmarkBar:YES]; + preferences_ = profile->GetPrefs(); + if (preferences_->GetBoolean(prefs::kShowBookmarkBar)) + [self showBookmarkBar:YES immediately:NO]; [[[contentView_ window] contentView] addSubview:bookmarkBarView_]; } // Don't pass ourself along until our init is done. @@ -64,7 +67,7 @@ const CGFloat kBookmarkHorizontalPadding = 8.0; - (void)positionBar { // Hide or show bar based on initial visibility and set the resize flags. [bookmarkBarView_ setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin]; - [bookmarkBarView_ setHidden:!barIsVisible_]; + [bookmarkBarView_ setHidden:!barShouldBeShown_]; // Set the bar's height to zero and position it at the top of the // content area, within the window's content view (as opposed to the @@ -86,16 +89,21 @@ const CGFloat kBookmarkHorizontalPadding = 8.0; [bookmarkBarView_ setFrame:barFrame]; } -// Show or hide the bar based on the value of |enable|. Handles animating the -// resize of the content view. -- (void)showBookmarkBar:(BOOL)enable { - contentViewHasOffset_ = enable; - [bookmarkBarView_ setHidden:enable ? NO : YES]; - [self applyContentAreaOffset:enable]; - - barIsVisible_ = enable; - if (enable) { - [self loaded:bookmarkModel_]; +// Show or hide the bar based on the value of |show|. Handles +// animating the resize of the content view. if |immediately| is YES, +// make changes immediately instead of using an animator. If the bar +// is disabled, do absolutely nothing. The routine which enables the +// bar will show it if relevant using other mechanisms (the pref) to +// determine desired state. +- (void)showBookmarkBar:(BOOL)show immediately:(BOOL)immediately { + if (barIsEnabled_) { + contentViewHasOffset_ = show; + [bookmarkBarView_ setHidden:show ? NO : YES]; + [self applyContentAreaOffset:show immediately:immediately]; + barShouldBeShown_ = show; + if (show) { + [self loaded:bookmarkModel_]; + } } } @@ -103,7 +111,7 @@ const CGFloat kBookmarkHorizontalPadding = 8.0; // bookmark bar. If apply==YES, always make room (the contentView_ is // "full size"). If apply==NO we are trying to undo an offset. If no // offset there is nothing to undo. -- (void)applyContentAreaOffset:(BOOL)apply { +- (void)applyContentAreaOffset:(BOOL)apply immediately:(BOOL)immediately { if (bookmarkBarView_ == nil) { // We're too early, but awakeFromNib will call me again. return; @@ -119,20 +127,41 @@ const CGFloat kBookmarkHorizontalPadding = 8.0; else frame.size.height += kBookmarkBarHeight; - [[contentView_ animator] setFrame:frame]; + if (immediately) { + [contentView_ setFrame:frame]; + [contentView_ setNeedsDisplay:YES]; + } else { + [[contentView_ animator] setFrame:frame]; + } + [bookmarkBarView_ setNeedsDisplay:YES]; [contentView_ setNeedsDisplay:YES]; } - (BOOL)isBookmarkBarVisible { - return barIsVisible_; + return barShouldBeShown_; } // We don't change a preference; we only change visibility. // Preference changing (global state) is handled in // BrowserWindowCocoa::ToggleBookmarkBar(). - (void)toggleBookmarkBar { - [self showBookmarkBar:!barIsVisible_]; + [self showBookmarkBar:!barShouldBeShown_ immediately:NO]; +} + +- (void)setBookmarkBarEnabled:(BOOL)enabled { + if (enabled) { + // Enabling the bar; set enabled then show if needed. + barIsEnabled_ = YES; + if (preferences_->GetBoolean(prefs::kShowBookmarkBar)) + [self showBookmarkBar:YES immediately:YES]; + } else { + // Disabling the bar; hide if visible. + if ([self isBookmarkBarVisible]) { + [self showBookmarkBar:NO immediately:YES]; + } + barIsEnabled_ = NO; + } } // Delete all items from the bookmark bar. @@ -250,8 +279,8 @@ const CGFloat kBookmarkHorizontalPadding = 8.0; // TODO(jrg): for now this is brute force. - (void)loaded:(BookmarkModel*)model { DCHECK(model == bookmarkModel_); - // Do nothing if not visible or too early - if ((barIsVisible_ == NO) || !model->IsLoaded()) + // Do nothing if not active or too early + if ((barShouldBeShown_ == NO) || !model->IsLoaded()) return; // Else brute force nuke and build. const BookmarkNode* node = model->GetBookmarkBarNode(); diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index 1f7c799..fdb40de 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -123,12 +123,11 @@ bool BrowserWindowCocoa::IsMaximized() const { } void BrowserWindowCocoa::SetFullscreen(bool fullscreen) { - NOTIMPLEMENTED(); + [controller_ setFullscreen:fullscreen]; } bool BrowserWindowCocoa::IsFullscreen() const { - NOTIMPLEMENTED(); - return false; + return !![controller_ isFullscreen]; } gfx::Rect BrowserWindowCocoa::GetRootWindowResizerRect() const { diff --git a/chrome/browser/cocoa/browser_window_cocoa_unittest.mm b/chrome/browser/cocoa/browser_window_cocoa_unittest.mm index 4308bc2..059be46 100644 --- a/chrome/browser/cocoa/browser_window_cocoa_unittest.mm +++ b/chrome/browser/cocoa/browser_window_cocoa_unittest.mm @@ -90,4 +90,34 @@ TEST_F(BrowserWindowCocoaTest, TestBookmarkBarVisible) { EXPECT_EQ(before, bwc->IsBookmarkBarVisible()); } +@interface FakeController : NSWindowController { + BOOL fullscreen_; +} +@end + +@implementation FakeController +- (void)setFullscreen:(BOOL)fullscreen { + fullscreen_ = fullscreen; +} +- (BOOL)isFullscreen { + return fullscreen_; +} +@end + +TEST_F(BrowserWindowCocoaTest, TestFullscreen) { + scoped_nsobject<FakeController> fake_controller_([[FakeController alloc] + init]); + BrowserWindowCocoaPong *bwc = new BrowserWindowCocoaPong( + browser_helper_.browser(), + (BrowserWindowController*)fake_controller_.get(), + cocoa_helper_.window()); + scoped_ptr<BrowserWindowCocoaPong> scoped_bwc(bwc); + + EXPECT_FALSE(bwc->IsFullscreen()); + bwc->SetFullscreen(true); + EXPECT_TRUE(bwc->IsFullscreen()); + bwc->SetFullscreen(false); + EXPECT_FALSE(bwc->IsFullscreen()); +} + /* TODO(???): test other methods of BrowserWindowCocoa */ diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h index ab90f2e..c7b24f1 100644 --- a/chrome/browser/cocoa/browser_window_controller.h +++ b/chrome/browser/cocoa/browser_window_controller.h @@ -44,6 +44,7 @@ class TabStripModelObserverBridge; // their destruction sequence. scoped_ptr<Browser> browser_; scoped_nsobject<NSWindow> window_; + scoped_nsobject<NSWindow> fullscreen_window_; scoped_ptr<TabStripModelObserverBridge> tabObserver_; scoped_ptr<BrowserWindowCocoa> windowShim_; scoped_nsobject<ToolbarController> toolbarController_; @@ -53,6 +54,7 @@ class TabStripModelObserverBridge; scoped_ptr<StatusBubble> statusBubble_; scoped_nsobject<DownloadShelfController> downloadShelfController_; BOOL ownsBrowser_; // Only ever NO when testing + BOOL fullscreen_; } // Load the browser window nib and do any Cocoa-specific initialization. @@ -109,6 +111,12 @@ class TabStripModelObserverBridge; // BrowserWindowController. - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController; +// Enters (or exits) fullscreen mode. +- (void)setFullscreen:(BOOL)fullscreen; + +// Returns fullscreen state. +- (BOOL)isFullscreen; + @end @@ -117,6 +125,9 @@ class TabStripModelObserverBridge; // Allows us to initWithBrowser withOUT taking ownership of the browser. - (id)initWithBrowser:(Browser*)browser takeOwnership:(BOOL)ownIt; +// Return an autoreleased NSWindow suitable for fullscreen use. +- (NSWindow*)fullscreenWindow; + @end // BrowserWindowController(TestingAPI) #endif // CHROME_BROWSER_COCOA_BROWSER_WINDOW_CONTROLLER_H_ diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 6a58402..3532141 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <Carbon/Carbon.h> + #include "base/mac_util.h" #include "base/scoped_nsdisable_screen_updates.h" #include "base/sys_string_conversions.h" @@ -20,6 +22,7 @@ #import "chrome/browser/cocoa/download_shelf_controller.h" #import "chrome/browser/cocoa/find_bar_cocoa_controller.h" #include "chrome/browser/cocoa/find_bar_bridge.h" +#import "chrome/browser/cocoa/fullscreen_window.h" #import "chrome/browser/cocoa/status_bubble_mac.h" #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" #import "chrome/browser/cocoa/tab_strip_view.h" @@ -53,6 +56,7 @@ const int kWindowGradientHeight = 24; @interface BrowserWindowController(Private) - (void)positionToolbar; +- (void)removeToolbar; - (void)installIncognitoBadge; // Leopard's gradient heuristic gets confused by our tabs and makes the title @@ -607,6 +611,63 @@ willPositionSheet:(NSWindow *)sheet [findBarCocoaController_ positionFindBarView:[self tabContentArea]]; } +// Adjust the UI for fullscreen mode. E.g. when going fullscreen, +// remove the toolbar. When stopping fullscreen, add it back in. +- (void)adjustUIForFullscreen:(BOOL)fullscreen { + if (fullscreen) { + // Disable showing of the bookmark bar. This does not toggle the + // preference. + [bookmarkBarController_ setBookmarkBarEnabled:NO]; + // Make room for more content area. + [self removeToolbar]; + // Hide the menubar, and allow it to un-hide when moving the mouse + // to the top of the screen. Does this eliminate the need for an + // info bubble describing how to exit fullscreen mode? + SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); + } else { + SetSystemUIMode(kUIModeNormal, 0); + [self positionToolbar]; + [bookmarkBarController_ setBookmarkBarEnabled:YES]; + } +} + +- (NSWindow*)fullscreenWindow { + return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] + autorelease]; +} + +- (void)setFullscreen:(BOOL)fullscreen { + fullscreen_ = fullscreen; + if (fullscreen) { + // Minimize our UI + [self adjustUIForFullscreen:fullscreen]; + // Move content to a new fullscreen window + NSView* content = [[self window] contentView]; + fullscreen_window_.reset([[self fullscreenWindow] retain]); + [content removeFromSuperview]; + [fullscreen_window_ setContentView:content]; + [self setWindow:fullscreen_window_.get()]; + // Show one window, hide the other. + [fullscreen_window_ makeKeyAndOrderFront:self]; + [content setNeedsDisplay:YES]; + [window_ orderOut:self]; + } else { + [self adjustUIForFullscreen:fullscreen]; + NSView* content = [fullscreen_window_ contentView]; + [content removeFromSuperview]; + [window_ setContentView:content]; + [self setWindow:window_.get()]; + [window_ makeKeyAndOrderFront:self]; + [content setNeedsDisplay:YES]; + [fullscreen_window_ close]; + fullscreen_window_.reset(nil); + } +} + +- (BOOL)isFullscreen { + return fullscreen_; +} + // Called by the bookmark bar to open a URL. - (void)openBookmarkURL:(const GURL&)url disposition:(WindowOpenDisposition)disposition { @@ -661,26 +722,47 @@ willPositionSheet:(NSWindow *)sheet @implementation BrowserWindowController (Private) -// Position |toolbarView_| below the tab strip, but not as a sibling. The -// toolbar is part of the window's contentView, mainly because we want the -// opacity during drags to be the same as the web content. -- (void)positionToolbar { +// If |add| is YES: +// Position |toolbarView_| below the tab strip, but not as a +// sibling. The toolbar is part of the window's contentView, mainly +// because we want the opacity during drags to be the same as the web +// content. This can be used for either the initial add or a +// reposition. +// If |add| is NO: +// Remove the toolbar from it's parent view (the window's content view). +// Called when going fullscreen and we need to minimize UI. +- (void)positionOrRemoveToolbar:(BOOL)add { NSView* contentView = [self tabContentArea]; NSRect contentFrame = [contentView frame]; NSView* toolbarView = [toolbarController_ view]; NSRect toolbarFrame = [toolbarView frame]; - // Shrink the content area by the height of the toolbar. - contentFrame.size.height -= toolbarFrame.size.height; + // Shrink or grow the content area by the height of the toolbar. + if (add) + contentFrame.size.height -= toolbarFrame.size.height; + else + contentFrame.size.height += toolbarFrame.size.height; [contentView setFrame:contentFrame]; - // Move the toolbar above the content area, within the window's content view - // (as opposed to the tab strip, which is a sibling). - toolbarFrame.origin.y = NSMaxY(contentFrame); - toolbarFrame.origin.x = 0; - toolbarFrame.size.width = contentFrame.size.width; - [toolbarView setFrame:toolbarFrame]; - [[[self window] contentView] addSubview:toolbarView]; + if (add) { + // Move the toolbar above the content area, within the window's content view + // (as opposed to the tab strip, which is a sibling). + toolbarFrame.origin.y = NSMaxY(contentFrame); + toolbarFrame.origin.x = 0; + toolbarFrame.size.width = contentFrame.size.width; + [toolbarView setFrame:toolbarFrame]; + [[[self window] contentView] addSubview:toolbarView]; + } else { + [toolbarView removeFromSuperview]; + } +} + +- (void)positionToolbar { + [self positionOrRemoveToolbar:YES]; +} + +- (void)removeToolbar { + [self positionOrRemoveToolbar:NO]; } // If the browser is in incognito mode, install the image view to decordate diff --git a/chrome/browser/cocoa/browser_window_controller_unittest.mm b/chrome/browser/cocoa/browser_window_controller_unittest.mm index 0dff06d..d640922 100644 --- a/chrome/browser/cocoa/browser_window_controller_unittest.mm +++ b/chrome/browser/cocoa/browser_window_controller_unittest.mm @@ -50,4 +50,31 @@ TEST_F(BrowserWindowControllerTest, TestSaveWindowPosition) { EXPECT_TRUE(prefs->GetDictionary(prefs::kBrowserWindowPlacement) != NULL); } +@interface BrowserWindowControllerFakeFullscreen : BrowserWindowController { +} +@end +@implementation BrowserWindowControllerFakeFullscreen +// This isn't needed to pass the test, but does prevent an actual +// fullscreen from happening. +- (NSWindow*)fullscreenWindow { + return nil; +} +@end + +TEST_F(BrowserWindowControllerTest, TestFullscreen) { + // Note use of "controller", not "controller_" + scoped_nsobject<BrowserWindowController> controller; + controller.reset([[BrowserWindowControllerFakeFullscreen alloc] + initWithBrowser:browser_helper_.browser() + takeOwnership:NO]); + EXPECT_FALSE([controller isFullscreen]); + [controller setFullscreen:YES]; + EXPECT_TRUE([controller isFullscreen]); + [controller setFullscreen:NO]; + EXPECT_FALSE([controller isFullscreen]); + + // Confirm the real fullscreen command doesn't return nil + EXPECT_TRUE([controller_ fullscreenWindow]); +} + /* TODO(???): test other methods of BrowserWindowController */ diff --git a/chrome/browser/cocoa/fullscreen_window.h b/chrome/browser/cocoa/fullscreen_window.h new file mode 100644 index 0000000..1f944e4 --- /dev/null +++ b/chrome/browser/cocoa/fullscreen_window.h @@ -0,0 +1,19 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <Cocoa/Cocoa.h> + +// A FullscreenWindow is a borderless window suitable for going +// fullscreen. The returned window is NOT release when closed and is +// not initially visible. +@interface FullscreenWindow : NSWindow + +// Initialize a FullscreenWindow for the given screen. +// Designated initializer. +- (id)initForScreen:(NSScreen*)screen; + +@end + + + diff --git a/chrome/browser/cocoa/fullscreen_window.mm b/chrome/browser/cocoa/fullscreen_window.mm new file mode 100644 index 0000000..3c5fbdb --- /dev/null +++ b/chrome/browser/cocoa/fullscreen_window.mm @@ -0,0 +1,43 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/cocoa/fullscreen_window.h" + +@implementation FullscreenWindow + +// Make sure our designated initializer gets called. +- (id)init { + return [self initForScreen:[NSScreen mainScreen]]; +} + +- (id)initForScreen:(NSScreen*)screen { + NSRect contentRect; + contentRect.origin = NSZeroPoint; + contentRect.size = [screen frame].size; + + if ((self = [super initWithContentRect:contentRect + styleMask:NSBorderlessWindowMask + backing:NSBackingStoreBuffered + defer:YES + screen:screen])) { + [self setReleasedWhenClosed:NO]; + } + return self; +} + +// According to +// http://www.cocoabuilder.com/archive/message/cocoa/2006/6/19/165953, +// NSBorderlessWindowMask windows cannot become key or main. +// In our case, however, we don't want that behavior, so we override +// canBecomeKeyWindow and canBecomeMainWindow. + +- (BOOL)canBecomeKeyWindow { + return YES; +} + +- (BOOL)canBecomeMainWindow { + return YES; +} + +@end diff --git a/chrome/browser/cocoa/fullscreen_window_unittest.mm b/chrome/browser/cocoa/fullscreen_window_unittest.mm new file mode 100644 index 0000000..c12f1fd --- /dev/null +++ b/chrome/browser/cocoa/fullscreen_window_unittest.mm @@ -0,0 +1,27 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/scoped_ptr.h" +#include "chrome/browser/cocoa/cocoa_test_helper.h" +#include "chrome/browser/cocoa/fullscreen_window.h" +#include "testing/gtest/include/gtest/gtest.h" + +class FullscreenWindowTest : public testing::Test { + public: + CocoaTestHelper cocoa_helper_; +}; + +TEST_F(FullscreenWindowTest, Basics) { + scoped_nsobject<FullscreenWindow> window_; + window_.reset([[FullscreenWindow alloc] init]); + + EXPECT_EQ([NSScreen mainScreen], [window_ screen]); + EXPECT_TRUE([window_ canBecomeKeyWindow]); + EXPECT_TRUE([window_ canBecomeMainWindow]); + EXPECT_EQ(NSBorderlessWindowMask, [window_ styleMask]); + EXPECT_FALSE([window_ isReleasedWhenClosed]); + EXPECT_TRUE(NSEqualRects([[NSScreen mainScreen] frame], [window_ frame])); +} + + diff --git a/chrome/browser/cocoa/tab_contents_controller.h b/chrome/browser/cocoa/tab_contents_controller.h index 0cd2e2c..f79b9ea 100644 --- a/chrome/browser/cocoa/tab_contents_controller.h +++ b/chrome/browser/cocoa/tab_contents_controller.h @@ -27,9 +27,6 @@ class TabStripModel; - (id)initWithNibName:(NSString*)name contents:(TabContents*)contents; -// Take this view (toolbar and web contents) full screen -- (IBAction)fullScreen:(id)sender; - // Called when the tab contents is about to be put into the view hierarchy as // the selected tab. Handles things such as ensuring the toolbar is correctly // enabled. diff --git a/chrome/browser/cocoa/tab_contents_controller.mm b/chrome/browser/cocoa/tab_contents_controller.mm index a51796d..b2ac634 100644 --- a/chrome/browser/cocoa/tab_contents_controller.mm +++ b/chrome/browser/cocoa/tab_contents_controller.mm @@ -37,14 +37,6 @@ return [[self view] superview] ? YES : NO; } -- (IBAction)fullScreen:(id)sender { - if ([[self view] isInFullScreenMode]) { - [[self view] exitFullScreenModeWithOptions:nil]; - } else { - [[self view] enterFullScreenMode:[NSScreen mainScreen] withOptions:nil]; - } -} - - (void)willBecomeSelectedTab { } |