summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
authorrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-25 20:34:39 +0000
committerrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-25 20:34:39 +0000
commitb12ed2fc8766a07fec27bc2dcad4b2ebaaa1bbdf (patch)
tree5e3b1940100116f3f0ab99d9875d9e8e8b10c9aa /chrome/browser/cocoa
parent9c90deb6ab28f8043574331bb3d2ba6c624f5106 (diff)
downloadchromium_src-b12ed2fc8766a07fec27bc2dcad4b2ebaaa1bbdf.zip
chromium_src-b12ed2fc8766a07fec27bc2dcad4b2ebaaa1bbdf.tar.gz
chromium_src-b12ed2fc8766a07fec27bc2dcad4b2ebaaa1bbdf.tar.bz2
[Mac] Changes to enable performClose: for fullscreen windows.
(Changes really made by viettrungluu@chromium.org.) BUG=31638 TEST=None. (Unittests should still pass.) Review URL: http://codereview.chromium.org/552133 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37029 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/fullscreen_window.h5
-rw-r--r--chrome/browser/cocoa/fullscreen_window.mm31
-rw-r--r--chrome/browser/cocoa/fullscreen_window_unittest.mm41
3 files changed, 61 insertions, 16 deletions
diff --git a/chrome/browser/cocoa/fullscreen_window.h b/chrome/browser/cocoa/fullscreen_window.h
index 313c72a..d43059d 100644
--- a/chrome/browser/cocoa/fullscreen_window.h
+++ b/chrome/browser/cocoa/fullscreen_window.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -17,6 +17,3 @@
- (id)initForScreen:(NSScreen*)screen;
@end
-
-
-
diff --git a/chrome/browser/cocoa/fullscreen_window.mm b/chrome/browser/cocoa/fullscreen_window.mm
index 3c5fbdb..28cf175 100644
--- a/chrome/browser/cocoa/fullscreen_window.mm
+++ b/chrome/browser/cocoa/fullscreen_window.mm
@@ -1,8 +1,10 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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"
+#import "chrome/browser/cocoa/fullscreen_window.h"
+
+#include "base/mac_util.h"
@implementation FullscreenWindow
@@ -40,4 +42,29 @@
return YES;
}
+// We need our own version, since the default one wants to flash the close
+// button (and possibly other things), which results in nothing happening.
+- (void)performClose:(id)sender {
+ BOOL shouldClose = YES;
+
+ // If applicable, check if this window should close.
+ id delegate = [self delegate];
+ if ([delegate respondsToSelector:@selector(windowShouldClose:)])
+ shouldClose = [delegate windowShouldClose:self];
+
+ if (shouldClose) {
+ [self close];
+ mac_util::ReleaseFullScreen();
+ }
+}
+
+- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
+ // Explicitly enable |-performClose:| (see above); otherwise the fact that
+ // this window does not have a close button results in it being disabled.
+ if ([item action] == @selector(performClose:))
+ return YES;
+
+ return [super validateUserInterfaceItem:item];
+}
+
@end
diff --git a/chrome/browser/cocoa/fullscreen_window_unittest.mm b/chrome/browser/cocoa/fullscreen_window_unittest.mm
index 6d50f79..5f6df44 100644
--- a/chrome/browser/cocoa/fullscreen_window_unittest.mm
+++ b/chrome/browser/cocoa/fullscreen_window_unittest.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -8,19 +8,40 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
+@interface PerformCloseUIItem : NSObject<NSValidatedUserInterfaceItem>
+@end
+
+@implementation PerformCloseUIItem
+- (SEL)action {
+ return @selector(performClose:);
+}
+
+- (NSInteger)tag {
+ return 0;
+}
+@end
+
class FullscreenWindowTest : public CocoaTest {
};
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_TRUE(NSEqualRects([[NSScreen mainScreen] frame], [window_ frame]));
- EXPECT_FALSE([window_ isReleasedWhenClosed]);
+ 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_TRUE(NSEqualRects([[NSScreen mainScreen] frame], [window frame]));
+ EXPECT_FALSE([window isReleasedWhenClosed]);
}
+TEST_F(FullscreenWindowTest, CanPerformClose) {
+ scoped_nsobject<FullscreenWindow> window;
+ window.reset([[FullscreenWindow alloc] init]);
+ scoped_nsobject<PerformCloseUIItem> item;
+ item.reset([[PerformCloseUIItem alloc] init]);
+
+ EXPECT_TRUE([window validateUserInterfaceItem:item.get()]);
+}