OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/browser_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <numeric> | 8 #include <numeric> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 [base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(window) | 195 [base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(window) |
196 setCommandHandler:[[[BrowserWindowCommandHandler alloc] init] | 196 setCommandHandler:[[[BrowserWindowCommandHandler alloc] init] |
197 autorelease]]; | 197 autorelease]]; |
198 } | 198 } |
199 | 199 |
200 } // namespace | 200 } // namespace |
201 | 201 |
202 @interface NSWindow (NSPrivateApis) | 202 @interface NSWindow (NSPrivateApis) |
203 // Note: These functions are private, use -[NSObject respondsToSelector:] | 203 // Note: These functions are private, use -[NSObject respondsToSelector:] |
204 // before calling them. | 204 // before calling them. |
205 | |
206 - (void)setBottomCornerRounded:(BOOL)rounded; | |
207 | |
208 - (NSRect)_growBoxRect; | 205 - (NSRect)_growBoxRect; |
209 | |
210 @end | 206 @end |
211 | 207 |
212 @implementation BrowserWindowController | 208 @implementation BrowserWindowController |
213 | 209 |
214 + (BrowserWindowController*)browserWindowControllerForWindow:(NSWindow*)window { | 210 + (BrowserWindowController*)browserWindowControllerForWindow:(NSWindow*)window { |
215 while (window) { | 211 while (window) { |
216 id controller = [window windowController]; | 212 id controller = [window windowController]; |
217 if ([controller isKindOfClass:[BrowserWindowController class]]) | 213 if ([controller isKindOfClass:[BrowserWindowController class]]) |
218 return (BrowserWindowController*)controller; | 214 return (BrowserWindowController*)controller; |
219 window = [window parentWindow]; | 215 window = [window parentWindow]; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 [[self window] setMinSize:minSize]; | 253 [[self window] setMinSize:minSize]; |
258 | 254 |
259 // Create the bar visibility lock set; 10 is arbitrary, but should hopefully | 255 // Create the bar visibility lock set; 10 is arbitrary, but should hopefully |
260 // be big enough to hold all locks that'll ever be needed. | 256 // be big enough to hold all locks that'll ever be needed. |
261 barVisibilityLocks_.reset([[NSMutableSet setWithCapacity:10] retain]); | 257 barVisibilityLocks_.reset([[NSMutableSet setWithCapacity:10] retain]); |
262 | 258 |
263 // Lion will attempt to automagically save and restore the UI. This | 259 // Lion will attempt to automagically save and restore the UI. This |
264 // functionality appears to be leaky (or at least interacts badly with our | 260 // functionality appears to be leaky (or at least interacts badly with our |
265 // architecture) and thus BrowserWindowController never gets released. This | 261 // architecture) and thus BrowserWindowController never gets released. This |
266 // prevents the browser from being able to quit <http://crbug.com/79113>. | 262 // prevents the browser from being able to quit <http://crbug.com/79113>. |
267 if ([window respondsToSelector:@selector(setRestorable:)]) | 263 [window setRestorable:NO]; |
268 [window setRestorable:NO]; | |
269 | 264 |
270 // Get the windows to swish in on Lion. | 265 // Get the windows to swish in on Lion. |
271 if ([window respondsToSelector:@selector(setAnimationBehavior:)]) | 266 [window setAnimationBehavior:NSWindowAnimationBehaviorDocumentWindow]; |
272 [window setAnimationBehavior:NSWindowAnimationBehaviorDocumentWindow]; | |
273 | 267 |
274 // Get the most appropriate size for the window, then enforce the | 268 // Get the most appropriate size for the window, then enforce the |
275 // minimum width and height. The window shim will handle flipping | 269 // minimum width and height. The window shim will handle flipping |
276 // the coordinates for us so we can use it to save some code. | 270 // the coordinates for us so we can use it to save some code. |
277 // Note that this may leave a significant portion of the window | 271 // Note that this may leave a significant portion of the window |
278 // offscreen, but there will always be enough window onscreen to | 272 // offscreen, but there will always be enough window onscreen to |
279 // drag the whole window back into view. | 273 // drag the whole window back into view. |
280 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; | 274 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; |
281 gfx::Rect desiredContentRect; | 275 gfx::Rect desiredContentRect; |
282 chrome::GetSavedWindowBoundsAndShowState(browser_.get(), | 276 chrome::GetSavedWindowBoundsAndShowState(browser_.get(), |
(...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1853 | 1847 |
1854 - (TabAlertState)alertState { | 1848 - (TabAlertState)alertState { |
1855 return static_cast<BrowserWindowCocoa*>([self browserWindow])->alert_state(); | 1849 return static_cast<BrowserWindowCocoa*>([self browserWindow])->alert_state(); |
1856 } | 1850 } |
1857 | 1851 |
1858 @end // @implementation BrowserWindowController | 1852 @end // @implementation BrowserWindowController |
1859 | 1853 |
1860 @implementation BrowserWindowController(Fullscreen) | 1854 @implementation BrowserWindowController(Fullscreen) |
1861 | 1855 |
1862 - (void)handleLionToggleFullscreen { | 1856 - (void)handleLionToggleFullscreen { |
1863 DCHECK(base::mac::IsOSLionOrLater()); | |
1864 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN); | 1857 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN); |
1865 } | 1858 } |
1866 | 1859 |
1867 - (void)enterBrowserFullscreenWithToolbar:(BOOL)withToolbar { | 1860 - (void)enterBrowserFullscreenWithToolbar:(BOOL)withToolbar { |
1868 if (!chrome::mac::SupportsSystemFullscreen()) { | 1861 if (!chrome::mac::SupportsSystemFullscreen()) { |
1869 if (![self isInImmersiveFullscreen]) | 1862 if (![self isInImmersiveFullscreen]) |
1870 [self enterImmersiveFullscreen]; | 1863 [self enterImmersiveFullscreen]; |
1871 return; | 1864 return; |
1872 } | 1865 } |
1873 | 1866 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 | 2062 |
2070 - (BOOL)isTabbedWindow { | 2063 - (BOOL)isTabbedWindow { |
2071 return browser_->is_type_tabbed(); | 2064 return browser_->is_type_tabbed(); |
2072 } | 2065 } |
2073 | 2066 |
2074 - (NSRect)savedRegularWindowFrame { | 2067 - (NSRect)savedRegularWindowFrame { |
2075 return savedRegularWindowFrame_; | 2068 return savedRegularWindowFrame_; |
2076 } | 2069 } |
2077 | 2070 |
2078 @end // @implementation BrowserWindowController(WindowType) | 2071 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |