OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
6 | 6 |
7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 @interface NSWindow (NSPrivateApis) | 145 @interface NSWindow (NSPrivateApis) |
146 // Note: These functions are private, use -[NSObject respondsToSelector:] | 146 // Note: These functions are private, use -[NSObject respondsToSelector:] |
147 // before calling them. | 147 // before calling them. |
148 | 148 |
149 - (void)setBottomCornerRounded:(BOOL)rounded; | 149 - (void)setBottomCornerRounded:(BOOL)rounded; |
150 | 150 |
151 - (NSRect)_growBoxRect; | 151 - (NSRect)_growBoxRect; |
152 | 152 |
153 @end | 153 @end |
154 | 154 |
155 // Provide the forward-declarations of new 10.7 SDK symbols so they can be | 155 // Provide the forward-declarations of new 10.7 SDK symbols so they can be |
Mark Mentovai
2011/07/13 14:46:04
10.6, not 10.7.
| |
156 // called when building with the 10.5 SDK. | 156 // called when building with the 10.5 SDK. |
157 #if !defined(MAC_OS_X_VERSION_10_6) || \ | |
158 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 | |
159 | |
160 typedef NSUInteger NSApplicationPresentationOptions; | |
161 | |
162 @interface NSApplication (LionSDKDeclarations) | |
Mark Mentovai
2011/07/13 14:46:04
SnowLeopard, not Lion.
| |
163 - (NSApplicationPresentationOptions)currentSystemPresentationOptions; | |
164 @end | |
165 | |
166 #endif // MAC_OS_X_VERSION_10_6 | |
167 | |
168 // Provide the forward-declarations of new 10.7 SDK symbols so they can be | |
169 // called when building with the 10.5 SDK. | |
157 #if !defined(MAC_OS_X_VERSION_10_7) || \ | 170 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
158 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | 171 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 |
159 | 172 |
160 @interface NSWindow (LionSDKDeclarations) | 173 @interface NSWindow (LionSDKDeclarations) |
161 - (void)setRestorable:(BOOL)flag; | 174 - (void)setRestorable:(BOOL)flag; |
162 @end | 175 @end |
163 | 176 |
177 enum { | |
178 NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7, | |
179 NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8 | |
180 }; | |
181 | |
182 enum { | |
183 NSApplicationPresentationFullScreen = 1 << 10 | |
184 }; | |
185 | |
164 #endif // MAC_OS_X_VERSION_10_7 | 186 #endif // MAC_OS_X_VERSION_10_7 |
165 | 187 |
166 | 188 |
167 @implementation BrowserWindowController | 189 @implementation BrowserWindowController |
168 | 190 |
169 + (BrowserWindowController*)browserWindowControllerForWindow:(NSWindow*)window { | 191 + (BrowserWindowController*)browserWindowControllerForWindow:(NSWindow*)window { |
170 while (window) { | 192 while (window) { |
171 id controller = [window windowController]; | 193 id controller = [window windowController]; |
172 if ([controller isKindOfClass:[BrowserWindowController class]]) | 194 if ([controller isKindOfClass:[BrowserWindowController class]]) |
173 return (BrowserWindowController*)controller; | 195 return (BrowserWindowController*)controller; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 addObserver:self | 379 addObserver:self |
358 selector:@selector(applicationDidUnhide:) | 380 selector:@selector(applicationDidUnhide:) |
359 name:NSApplicationDidUnhideNotification | 381 name:NSApplicationDidUnhideNotification |
360 object:nil]; | 382 object:nil]; |
361 | 383 |
362 // This must be done after the view is added to the window since it relies | 384 // This must be done after the view is added to the window since it relies |
363 // on the window bounds to determine whether to show buttons or not. | 385 // on the window bounds to determine whether to show buttons or not. |
364 if ([self hasToolbar]) // Do not create the buttons in popups. | 386 if ([self hasToolbar]) // Do not create the buttons in popups. |
365 [toolbarController_ createBrowserActionButtons]; | 387 [toolbarController_ createBrowserActionButtons]; |
366 | 388 |
367 [self setUpOSFullScreenButton]; | 389 NSWindowCollectionBehavior behavior = [[self window] collectionBehavior]; |
390 behavior |= NSWindowCollectionBehaviorFullScreenPrimary; | |
391 [[self window] setCollectionBehavior:behavior]; | |
368 | 392 |
369 // We are done initializing now. | 393 // We are done initializing now. |
370 initializing_ = NO; | 394 initializing_ = NO; |
371 } | 395 } |
372 return self; | 396 return self; |
373 } | 397 } |
374 | 398 |
375 - (void)awakeFromNib { | 399 - (void)awakeFromNib { |
376 // Set different minimum sizes on tabbed windows vs non-tabbed, e.g. popups. | 400 // Set different minimum sizes on tabbed windows vs non-tabbed, e.g. popups. |
377 NSSize minSize = [self isTabbedWindow] ? | 401 NSSize minSize = [self isTabbedWindow] ? |
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1875 } | 1899 } |
1876 | 1900 |
1877 - (void)sheetDidEnd:(NSWindow*)sheet | 1901 - (void)sheetDidEnd:(NSWindow*)sheet |
1878 returnCode:(NSInteger)code | 1902 returnCode:(NSInteger)code |
1879 context:(void*)context { | 1903 context:(void*)context { |
1880 [sheet orderOut:self]; | 1904 [sheet orderOut:self]; |
1881 } | 1905 } |
1882 | 1906 |
1883 @end // @implementation BrowserWindowController | 1907 @end // @implementation BrowserWindowController |
1884 | 1908 |
1909 @implementation BrowserWindowController(LionFullScreen) | |
1910 | |
1911 - (NSSize)window:(NSWindow *)window | |
1912 willUseFullScreenContentSize:(NSSize)proposedSize { | |
1913 [window setFrame:NSMakeRect(0, 0, proposedSize.width, proposedSize.height) | |
1914 display:YES | |
1915 animate:NO]; | |
1916 [self layoutSubviews]; | |
1917 return proposedSize; | |
1918 } | |
1919 | |
1920 - (void)windowDidEnterFullScreen:(NSNotification *)notification { | |
1921 [self layoutSubviews]; | |
1922 } | |
1923 | |
1924 - (void)windowDidExitFullScreen:(NSNotification *)notification { | |
1925 [self layoutSubviews]; | |
1926 } | |
1927 | |
1928 - (BOOL)isLionFullScreen { | |
1929 return !!([NSApp currentSystemPresentationOptions] & | |
1930 NSApplicationPresentationFullScreen); | |
1931 } | |
1932 | |
1933 @end // @implementation BrowserWindowController(LionFullScreen) | |
1934 | |
1885 | 1935 |
1886 @implementation BrowserWindowController(Fullscreen) | 1936 @implementation BrowserWindowController(Fullscreen) |
1887 | 1937 |
1888 - (IBAction)enterFullscreen:(id)sender { | 1938 - (IBAction)enterFullscreen:(id)sender { |
1889 browser_->ExecuteCommand(IDC_FULLSCREEN); | 1939 browser_->ExecuteCommand(IDC_FULLSCREEN); |
1890 } | 1940 } |
1891 | 1941 |
1892 - (void)setFullscreen:(BOOL)fullscreen { | 1942 - (void)setFullscreen:(BOOL)fullscreen { |
1893 // The logic in this function is a bit complicated and very carefully | 1943 // The logic in this function is a bit complicated and very carefully |
1894 // arranged. See the below comments for more details. | 1944 // arranged. See the below comments for more details. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2029 NSWindowCollectionBehaviorMoveToActiveSpace]; | 2079 NSWindowCollectionBehaviorMoveToActiveSpace]; |
2030 [destWindow makeKeyAndOrderFront:self]; | 2080 [destWindow makeKeyAndOrderFront:self]; |
2031 [destWindow setCollectionBehavior:behavior]; | 2081 [destWindow setCollectionBehavior:behavior]; |
2032 | 2082 |
2033 [focusTracker restoreFocusInWindow:destWindow]; | 2083 [focusTracker restoreFocusInWindow:destWindow]; |
2034 [window orderOut:self]; | 2084 [window orderOut:self]; |
2035 | 2085 |
2036 // We're done moving focus, so re-enable bar visibility changes. | 2086 // We're done moving focus, so re-enable bar visibility changes. |
2037 [self enableBarVisibilityUpdates]; | 2087 [self enableBarVisibilityUpdates]; |
2038 | 2088 |
2039 // This needs to be done when leaving full-screen mode to ensure that the | |
2040 // button's action is set properly. | |
2041 [self setUpOSFullScreenButton]; | |
2042 | |
2043 // Fade back in. | 2089 // Fade back in. |
2044 if (didFadeOut) { | 2090 if (didFadeOut) { |
2045 CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendSolidColor, | 2091 CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendSolidColor, |
2046 kCGDisplayBlendNormal, 0.0, 0.0, 0.0, /*synchronous=*/false); | 2092 kCGDisplayBlendNormal, 0.0, 0.0, 0.0, /*synchronous=*/false); |
2047 CGReleaseDisplayFadeReservation(token); | 2093 CGReleaseDisplayFadeReservation(token); |
2048 } | 2094 } |
2049 } | 2095 } |
2050 | 2096 |
2051 - (BOOL)isFullscreen { | 2097 - (BOOL)isFullscreen { |
2052 return fullscreenController_.get() && [fullscreenController_ isFullscreen]; | 2098 return fullscreenController_.get() && [fullscreenController_ isFullscreen]; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2176 | 2222 |
2177 - (BOOL)supportsBookmarkBar { | 2223 - (BOOL)supportsBookmarkBar { |
2178 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2224 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2179 } | 2225 } |
2180 | 2226 |
2181 - (BOOL)isTabbedWindow { | 2227 - (BOOL)isTabbedWindow { |
2182 return browser_->is_type_tabbed(); | 2228 return browser_->is_type_tabbed(); |
2183 } | 2229 } |
2184 | 2230 |
2185 @end // @implementation BrowserWindowController(WindowType) | 2231 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |