summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-21 20:36:12 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-21 20:36:12 +0000
commit6f3b9f925c3e52a63bb320ce1c6caf67701b335c (patch)
tree8f9e5b0f6bfe99233827690832756d8d631fa472 /chrome
parent6dbdf1bee59b47d8e75fd49ec1e7228115b4cbb1 (diff)
downloadchromium_src-6f3b9f925c3e52a63bb320ce1c6caf67701b335c.zip
chromium_src-6f3b9f925c3e52a63bb320ce1c6caf67701b335c.tar.gz
chromium_src-6f3b9f925c3e52a63bb320ce1c6caf67701b335c.tar.bz2
Add Lion button, wire it up to enter our full-screen.
BUG=74056 TEST=On Lion, hit the new full-screen button Review URL: http://codereview.chromium.org/6715003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78918 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller.h5
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller.mm38
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_private.mm26
-rw-r--r--chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm28
4 files changed, 93 insertions, 4 deletions
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.h b/chrome/browser/ui/cocoa/browser_window_controller.h
index 597ed90..4e9ea3a 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.h
+++ b/chrome/browser/ui/cocoa/browser_window_controller.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -320,6 +320,9 @@ class TabContents;
// Methods having to do with fullscreen mode.
@interface BrowserWindowController(Fullscreen)
+// Enters fullscreen mode.
+- (IBAction)enterFullscreen:(id)sender;
+
// Enters (or exits) fullscreen mode.
- (void)setFullscreen:(BOOL)fullscreen;
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index fee79e5..c851c17 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -147,6 +147,25 @@
@end
+// 10.7 adds public APIs for full-screen support. Provide the declaration so it
+// can be called below when building with the 10.5 SDK.
+#if !defined(MAC_OS_X_VERSION_10_7) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
+
+@interface NSWindow (LionSDKDeclarations)
+- (void)toggleFullScreen:(id)sender;
+@end
+
+enum {
+ NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
+ NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8
+};
+
+enum {
+ NSWindowFullScreenButton = 7
+};
+
+#endif // MAC_OS_X_VERSION_10_7
// IncognitoImageView subclasses NSView to allow mouse events to pass through it
// so you can drag the window by dragging on the spy guy.
@@ -387,6 +406,21 @@
if ([self hasToolbar]) // Do not create the buttons in popups.
[toolbarController_ createBrowserActionButtons];
+ // For versions of Mac OS that provide an "enter fullscreen" button, make
+ // one appear (in a rather hacky manner). http://crbug.com/74065 : When
+ // switching the fullscreen implementation to the new API, revisit how much
+ // of this hacky code is necessary.
+ if ([window respondsToSelector:@selector(toggleFullScreen:)]) {
+ NSWindowCollectionBehavior behavior = [window collectionBehavior];
+ behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
+ [window setCollectionBehavior:behavior];
+
+ NSButton* fullscreenButton =
+ [window standardWindowButton:NSWindowFullScreenButton];
+ [fullscreenButton setAction:@selector(enterFullscreen:)];
+ [fullscreenButton setTarget:self];
+ }
+
// We are done initializing now.
initializing_ = NO;
}
@@ -1856,6 +1890,10 @@ willAnimateFromState:(bookmarks::VisualState)oldState
@implementation BrowserWindowController(Fullscreen)
+- (IBAction)enterFullscreen:(id)sender {
+ browser_->ExecuteCommand(IDC_FULLSCREEN);
+}
+
- (void)setFullscreen:(BOOL)fullscreen {
// The logic in this function is a bit complicated and very carefully
// arranged. See the below comments for more details.
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index cb81b18..5f49c6e6 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -40,6 +40,20 @@ const CGFloat kLocBarBottomInset = 1;
} // end namespace
+// 10.7 adds public APIs for full-screen support. Provide the declaration so it
+// can be called below when building with the 10.5 SDK.
+#if !defined(MAC_OS_X_VERSION_10_7) || \
+MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
+
+@interface NSWindow (LionSDKDeclarations)
+- (void)toggleFullScreen:(id)sender;
+@end
+
+enum {
+ NSWindowFullScreenButton = 7
+};
+
+#endif // MAC_OS_X_VERSION_10_7
@implementation BrowserWindowController(Private)
@@ -283,9 +297,19 @@ willPositionSheet:(NSWindow*)sheet
// Now lay out incognito badge together with the tab strip.
if (incognitoBadge_.get()) {
+ // Avoid the full-screen button.
+ CGFloat extraPadding = 0;
+ if ([[self window] respondsToSelector:@selector(toggleFullScreen:)]) {
+ NSButton* fullscreenButton =
+ [[self window] standardWindowButton:NSWindowFullScreenButton];
+ if (fullscreenButton)
+ extraPadding += [fullscreenButton frame].size.width;
+ }
+
// Actually place the badge *above* |maxY|, by +2 to miss the divider.
NSPoint origin = NSMakePoint(width - NSWidth([incognitoBadge_ frame]) -
- kIncognitoBadgeOffset, maxY + 2);
+ kIncognitoBadgeOffset - extraPadding,
+ maxY + 2);
[incognitoBadge_ setFrameOrigin:origin];
[incognitoBadge_ setHidden:NO]; // Make sure it's shown.
}
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
index 2988682..a1cd4cc 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -53,6 +53,21 @@
NSString* const kTabStripNumberOfTabsChanged = @"kTabStripNumberOfTabsChanged";
+// 10.7 adds public APIs for full-screen support. Provide the declaration so it
+// can be called below when building with the 10.5 SDK.
+#if !defined(MAC_OS_X_VERSION_10_7) || \
+MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
+
+@interface NSWindow (LionSDKDeclarations)
+- (void)toggleFullScreen:(id)sender;
+@end
+
+enum {
+ NSWindowFullScreenButton = 7
+};
+
+#endif // MAC_OS_X_VERSION_10_7
+
namespace {
// The images names used for different states of the new tab button.
@@ -761,10 +776,19 @@ private:
availableSpace = availableResizeWidth_;
} else {
availableSpace = NSWidth([tabStripView_ frame]);
- // Account for the new tab button and the incognito badge.
+
+ // Account for the widths of the new tab button, the incognito badge, and
+ // the fullscreen button if any/all are present.
availableSpace -= NSWidth([newTabButton_ frame]) + kNewTabButtonOffset;
if (browser_->profile()->IsOffTheRecord())
availableSpace -= kIncognitoBadgeTabStripShrink;
+ if ([[tabStripView_ window]
+ respondsToSelector:@selector(toggleFullScreen:)]) {
+ NSButton* fullscreenButton = [[tabStripView_ window]
+ standardWindowButton:NSWindowFullScreenButton];
+ if (fullscreenButton)
+ availableSpace -= [fullscreenButton frame].size.width;
+ }
}
availableSpace -= [self indentForControls];
}