| 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/presentation_mode_controller.h" | 5 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #import "base/mac/mac_util.h" | 10 #import "base/mac/mac_util.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 DCHECK(!inPresentationMode_); | 192 DCHECK(!inPresentationMode_); |
| 193 enteringPresentationMode_ = YES; | 193 enteringPresentationMode_ = YES; |
| 194 inPresentationMode_ = YES; | 194 inPresentationMode_ = YES; |
| 195 contentView_ = contentView; | 195 contentView_ = contentView; |
| 196 [self changeFloatingBarShownFraction:(showDropdown ? 1 : 0)]; | 196 [self changeFloatingBarShownFraction:(showDropdown ? 1 : 0)]; |
| 197 | 197 |
| 198 // Register for notifications. Self is removed as an observer in |-cleanup|. | 198 // Register for notifications. Self is removed as an observer in |-cleanup|. |
| 199 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; | 199 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; |
| 200 NSWindow* window = [browserController_ window]; | 200 NSWindow* window = [browserController_ window]; |
| 201 | 201 |
| 202 // When in presentation mode, the window's background will need to appear | |
| 203 // above the window contents. For this to happen, the window will need its | |
| 204 // own layer. This comes with a performance penalty when not fullscreen, so | |
| 205 // do not enable this by default. | |
| 206 [[window contentView] cr_setWantsLayer:YES]; | |
| 207 | |
| 208 // Disable these notifications on Lion as they cause crashes. | 202 // Disable these notifications on Lion as they cause crashes. |
| 209 // TODO(rohitrao): Figure out what happens if a fullscreen window changes | 203 // TODO(rohitrao): Figure out what happens if a fullscreen window changes |
| 210 // monitors on Lion. | 204 // monitors on Lion. |
| 211 if (base::mac::IsOSSnowLeopard()) { | 205 if (base::mac::IsOSSnowLeopard()) { |
| 212 [nc addObserver:self | 206 [nc addObserver:self |
| 213 selector:@selector(windowDidChangeScreen:) | 207 selector:@selector(windowDidChangeScreen:) |
| 214 name:NSWindowDidChangeScreenNotification | 208 name:NSWindowDidChangeScreenNotification |
| 215 object:window]; | 209 object:window]; |
| 216 | 210 |
| 217 [nc addObserver:self | 211 [nc addObserver:self |
| (...skipping 15 matching lines...) Expand all Loading... |
| 233 enteringPresentationMode_ = NO; | 227 enteringPresentationMode_ = NO; |
| 234 } | 228 } |
| 235 | 229 |
| 236 - (void)exitPresentationMode { | 230 - (void)exitPresentationMode { |
| 237 [[NSNotificationCenter defaultCenter] | 231 [[NSNotificationCenter defaultCenter] |
| 238 postNotificationName:kWillLeaveFullscreenNotification | 232 postNotificationName:kWillLeaveFullscreenNotification |
| 239 object:nil]; | 233 object:nil]; |
| 240 DCHECK(inPresentationMode_); | 234 DCHECK(inPresentationMode_); |
| 241 inPresentationMode_ = NO; | 235 inPresentationMode_ = NO; |
| 242 | 236 |
| 243 // Remove the layer that was created. | |
| 244 NSWindow* window = [browserController_ window]; | |
| 245 [[window contentView] cr_setWantsLayer:NO]; | |
| 246 | |
| 247 [self cleanup]; | 237 [self cleanup]; |
| 248 } | 238 } |
| 249 | 239 |
| 250 - (void)windowDidChangeScreen:(NSNotification*)notification { | 240 - (void)windowDidChangeScreen:(NSNotification*)notification { |
| 251 [browserController_ resizeFullscreenWindow]; | 241 [browserController_ resizeFullscreenWindow]; |
| 252 } | 242 } |
| 253 | 243 |
| 254 - (void)windowDidMove:(NSNotification*)notification { | 244 - (void)windowDidMove:(NSNotification*)notification { |
| 255 [browserController_ resizeFullscreenWindow]; | 245 [browserController_ resizeFullscreenWindow]; |
| 256 } | 246 } |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 - (void)hideActiveWindowUI { | 648 - (void)hideActiveWindowUI { |
| 659 if (systemFullscreenMode_ != base::mac::kFullScreenModeNormal) { | 649 if (systemFullscreenMode_ != base::mac::kFullScreenModeNormal) { |
| 660 base::mac::ReleaseFullScreen(systemFullscreenMode_); | 650 base::mac::ReleaseFullScreen(systemFullscreenMode_); |
| 661 systemFullscreenMode_ = base::mac::kFullScreenModeNormal; | 651 systemFullscreenMode_ = base::mac::kFullScreenModeNormal; |
| 662 } | 652 } |
| 663 | 653 |
| 664 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 | 654 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 |
| 665 } | 655 } |
| 666 | 656 |
| 667 @end | 657 @end |
| OLD | NEW |