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 "app/mac/scoped_nsdisable_screen_updates.h" | 9 #include "app/mac/scoped_nsdisable_screen_updates.h" |
10 #include "app/mac/nsimage_cache.h" | 10 #include "app/mac/nsimage_cache.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 - (NSRect)_growBoxRect; | 150 - (NSRect)_growBoxRect; |
151 | 151 |
152 @end | 152 @end |
153 | 153 |
154 // Provide the forward-declarations of new 10.7 SDK symbols so they can be | 154 // Provide the forward-declarations of new 10.7 SDK symbols so they can be |
155 // called when building with the 10.5 SDK. | 155 // called when building with the 10.5 SDK. |
156 #if !defined(MAC_OS_X_VERSION_10_7) || \ | 156 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
157 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | 157 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 |
158 | 158 |
159 @interface NSWindow (LionSDKDeclarations) | 159 @interface NSWindow (LionSDKDeclarations) |
160 - (void)toggleFullScreen:(id)sender; | |
161 - (void)setRestorable:(BOOL)flag; | 160 - (void)setRestorable:(BOOL)flag; |
162 @end | 161 @end |
163 | 162 |
164 enum { | |
165 NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7, | |
166 NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8 | |
167 }; | |
168 | |
169 enum { | |
170 NSWindowFullScreenButton = 7 | |
171 }; | |
172 | |
173 #endif // MAC_OS_X_VERSION_10_7 | 163 #endif // MAC_OS_X_VERSION_10_7 |
174 | 164 |
175 // IncognitoImageView subclasses NSView to allow mouse events to pass through it | 165 // IncognitoImageView subclasses NSView to allow mouse events to pass through it |
176 // so you can drag the window by dragging on the spy guy. | 166 // so you can drag the window by dragging on the spy guy. |
177 @interface IncognitoImageView : NSView { | 167 @interface IncognitoImageView : NSView { |
178 @private | 168 @private |
179 scoped_nsobject<NSImage> image_; | 169 scoped_nsobject<NSImage> image_; |
180 } | 170 } |
181 | 171 |
182 - (void)setImage:(NSImage*)image; | 172 - (void)setImage:(NSImage*)image; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 addObserver:self | 400 addObserver:self |
411 selector:@selector(applicationDidUnhide:) | 401 selector:@selector(applicationDidUnhide:) |
412 name:NSApplicationDidUnhideNotification | 402 name:NSApplicationDidUnhideNotification |
413 object:nil]; | 403 object:nil]; |
414 | 404 |
415 // This must be done after the view is added to the window since it relies | 405 // This must be done after the view is added to the window since it relies |
416 // on the window bounds to determine whether to show buttons or not. | 406 // on the window bounds to determine whether to show buttons or not. |
417 if ([self hasToolbar]) // Do not create the buttons in popups. | 407 if ([self hasToolbar]) // Do not create the buttons in popups. |
418 [toolbarController_ createBrowserActionButtons]; | 408 [toolbarController_ createBrowserActionButtons]; |
419 | 409 |
420 // For versions of Mac OS that provide an "enter fullscreen" button, make | 410 [self setUpOSFullScreenButton]; |
421 // one appear (in a rather hacky manner). http://crbug.com/74065 : When | |
422 // switching the fullscreen implementation to the new API, revisit how much | |
423 // of this hacky code is necessary. | |
424 if ([window respondsToSelector:@selector(toggleFullScreen:)]) { | |
425 NSWindowCollectionBehavior behavior = [window collectionBehavior]; | |
426 behavior |= NSWindowCollectionBehaviorFullScreenPrimary; | |
427 [window setCollectionBehavior:behavior]; | |
428 | |
429 NSButton* fullscreenButton = | |
430 [window standardWindowButton:NSWindowFullScreenButton]; | |
431 [fullscreenButton setAction:@selector(enterFullscreen:)]; | |
432 [fullscreenButton setTarget:self]; | |
433 } | |
434 | 411 |
435 // We are done initializing now. | 412 // We are done initializing now. |
436 initializing_ = NO; | 413 initializing_ = NO; |
437 } | 414 } |
438 return self; | 415 return self; |
439 } | 416 } |
440 | 417 |
441 - (void)dealloc { | 418 - (void)dealloc { |
442 browser_->CloseAllTabs(); | 419 browser_->CloseAllTabs(); |
443 [downloadShelfController_ exiting]; | 420 [downloadShelfController_ exiting]; |
(...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 NSWindowCollectionBehaviorMoveToActiveSpace]; | 2030 NSWindowCollectionBehaviorMoveToActiveSpace]; |
2054 [destWindow makeKeyAndOrderFront:self]; | 2031 [destWindow makeKeyAndOrderFront:self]; |
2055 [destWindow setCollectionBehavior:behavior]; | 2032 [destWindow setCollectionBehavior:behavior]; |
2056 | 2033 |
2057 [focusTracker restoreFocusInWindow:destWindow]; | 2034 [focusTracker restoreFocusInWindow:destWindow]; |
2058 [window orderOut:self]; | 2035 [window orderOut:self]; |
2059 | 2036 |
2060 // We're done moving focus, so re-enable bar visibility changes. | 2037 // We're done moving focus, so re-enable bar visibility changes. |
2061 [self enableBarVisibilityUpdates]; | 2038 [self enableBarVisibilityUpdates]; |
2062 | 2039 |
| 2040 // This needs to be done when leaving full-screen mode to ensure that the |
| 2041 // button's action is set properly. |
| 2042 [self setUpOSFullScreenButton]; |
| 2043 |
2063 // Fade back in. | 2044 // Fade back in. |
2064 if (didFadeOut) { | 2045 if (didFadeOut) { |
2065 CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendSolidColor, | 2046 CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendSolidColor, |
2066 kCGDisplayBlendNormal, 0.0, 0.0, 0.0, /*synchronous=*/false); | 2047 kCGDisplayBlendNormal, 0.0, 0.0, 0.0, /*synchronous=*/false); |
2067 CGReleaseDisplayFadeReservation(token); | 2048 CGReleaseDisplayFadeReservation(token); |
2068 } | 2049 } |
2069 } | 2050 } |
2070 | 2051 |
2071 - (BOOL)isFullscreen { | 2052 - (BOOL)isFullscreen { |
2072 return fullscreenController_.get() && [fullscreenController_ isFullscreen]; | 2053 return fullscreenController_.get() && [fullscreenController_ isFullscreen]; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2196 | 2177 |
2197 - (BOOL)supportsBookmarkBar { | 2178 - (BOOL)supportsBookmarkBar { |
2198 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2179 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2199 } | 2180 } |
2200 | 2181 |
2201 - (BOOL)isTabbedWindow { | 2182 - (BOOL)isTabbedWindow { |
2202 return browser_->is_type_tabbed(); | 2183 return browser_->is_type_tabbed(); |
2203 } | 2184 } |
2204 | 2185 |
2205 @end // @implementation BrowserWindowController(WindowType) | 2186 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |