OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/cocoa/fullscreen_window.h" | 5 #import "chrome/browser/ui/cocoa/fullscreen_window.h" |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | |
8 #import "chrome/browser/ui/cocoa/themed_window.h" | 7 #import "chrome/browser/ui/cocoa/themed_window.h" |
9 | 8 |
10 @implementation FullscreenWindow | 9 @implementation FullscreenWindow |
11 | 10 |
12 // Make sure our designated initializer gets called. | 11 // Make sure our designated initializer gets called. |
13 - (id)init { | 12 - (id)init { |
14 return [self initForScreen:[NSScreen mainScreen]]; | 13 return [self initForScreen:[NSScreen mainScreen]]; |
15 } | 14 } |
16 | 15 |
17 - (id)initForScreen:(NSScreen*)screen { | 16 - (id)initForScreen:(NSScreen*)screen { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 65 } |
67 | 66 |
68 - (void)resignMainWindow { | 67 - (void)resignMainWindow { |
69 [super resignMainWindow]; | 68 [super resignMainWindow]; |
70 [self setBackgroundColor:[NSColor windowBackgroundColor]]; | 69 [self setBackgroundColor:[NSColor windowBackgroundColor]]; |
71 } | 70 } |
72 | 71 |
73 // We need our own version, since the default one wants to flash the close | 72 // We need our own version, since the default one wants to flash the close |
74 // button (and possibly other things), which results in nothing happening. | 73 // button (and possibly other things), which results in nothing happening. |
75 - (void)performClose:(id)sender { | 74 - (void)performClose:(id)sender { |
76 id delegate = [self delegate]; | 75 BOOL shouldClose = YES; |
77 | |
78 // Route -performClose: to -commandDispatch: on the delegate when coming from | |
79 // the "close tab" menu item. See comment in chrome_browser_window.mm. | |
80 if ([self performCloseShouldRouteToCommandDispatch:sender]) { | |
81 [delegate commandDispatch:sender]; | |
82 return; | |
83 } | |
84 | 76 |
85 // If applicable, check if this window should close. | 77 // If applicable, check if this window should close. |
86 BOOL shouldClose = YES; | 78 id delegate = [self delegate]; |
87 if ([delegate respondsToSelector:@selector(windowShouldClose:)]) | 79 if ([delegate respondsToSelector:@selector(windowShouldClose:)]) |
88 shouldClose = [delegate windowShouldClose:self]; | 80 shouldClose = [delegate windowShouldClose:self]; |
89 | 81 |
90 if (shouldClose) { | 82 if (shouldClose) { |
91 [self close]; | 83 [self close]; |
92 } | 84 } |
93 } | 85 } |
94 | 86 |
95 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { | 87 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { |
96 SEL action = [item action]; | 88 SEL action = [item action]; |
97 | 89 |
98 // Explicitly enable |-performClose:| (see above); otherwise the fact that | 90 // Explicitly enable |-performClose:| (see above); otherwise the fact that |
99 // this window does not have a close button results in it being disabled. | 91 // this window does not have a close button results in it being disabled. |
100 if (action == @selector(performClose:)) | 92 if (action == @selector(performClose:)) |
101 return YES; | 93 return YES; |
102 | 94 |
103 return [super validateUserInterfaceItem:item]; | 95 return [super validateUserInterfaceItem:item]; |
104 } | 96 } |
105 | 97 |
106 @end | 98 @end |
OLD | NEW |