Index: chrome/browser/ui/cocoa/fullscreen_toolbar_controller.mm |
diff --git a/chrome/browser/ui/cocoa/presentation_mode_controller.mm b/chrome/browser/ui/cocoa/fullscreen_toolbar_controller.mm |
similarity index 90% |
rename from chrome/browser/ui/cocoa/presentation_mode_controller.mm |
rename to chrome/browser/ui/cocoa/fullscreen_toolbar_controller.mm |
index be1943b18ee118a2e820ad2ddb1fcffd6a518dd5..552cfc9275571c202a7c8991c834474e33332400 100644 |
--- a/chrome/browser/ui/cocoa/presentation_mode_controller.mm |
+++ b/chrome/browser/ui/cocoa/fullscreen_toolbar_controller.mm |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#import "chrome/browser/ui/cocoa/presentation_mode_controller.h" |
+#import "chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h" |
#include <algorithm> |
@@ -37,15 +37,15 @@ const NSTimeInterval kDropdownForTabStripChangesDuration = 0.75; |
const CGFloat kMenuBarRevealEventKind = 2004; |
// The amount by which the floating bar is offset downwards (to avoid the menu) |
-// in presentation mode. (We can't use |-[NSMenu menuBarHeight]| since it |
+// when the toolbar is hidden. (We can't use |-[NSMenu menuBarHeight]| since it |
// returns 0 when the menu bar is hidden.) |
const CGFloat kFloatingBarVerticalOffset = 22; |
OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
EventRef event, |
void* context) { |
- PresentationModeController* self = |
- static_cast<PresentationModeController*>(context); |
+ FullscreenToolbarController* self = |
+ static_cast<FullscreenToolbarController*>(context); |
// If Chrome has multiple fullscreen windows in their own space, the Handler |
// becomes flaky and might start receiving kMenuBarRevealEventKind events |
@@ -74,11 +74,11 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
} // end namespace |
// Helper class to manage animations for the dropdown bar. Calls |
-// [PresentationModeController changeToolbarFraction] once per |
+// [FullscreenToolbarController changeToolbarFraction] once per |
// animation step. |
@interface DropdownAnimation : NSAnimation { |
@private |
- PresentationModeController* controller_; |
+ FullscreenToolbarController* controller_; |
CGFloat startFraction_; |
CGFloat endFraction_; |
} |
@@ -92,7 +92,7 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
- (id)initWithFraction:(CGFloat)fromFraction |
fullDuration:(CGFloat)fullDuration |
animationCurve:(NSAnimationCurve)animationCurve |
- controller:(PresentationModeController*)controller; |
+ controller:(FullscreenToolbarController*)controller; |
@end |
@@ -104,7 +104,7 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
- (id)initWithFraction:(CGFloat)toFraction |
fullDuration:(CGFloat)fullDuration |
animationCurve:(NSAnimationCurve)animationCurve |
- controller:(PresentationModeController*)controller { |
+ controller:(FullscreenToolbarController*)controller { |
// Calculate the effective duration, based on the current shown fraction. |
DCHECK(controller); |
CGFloat fromFraction = controller.toolbarFraction; |
@@ -130,8 +130,7 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
@end |
- |
-@interface PresentationModeController (PrivateMethods) |
+@interface FullscreenToolbarController (PrivateMethods) |
// Updates the visibility of the menu bar and the dock. |
- (void)updateMenuBarAndDockVisibility; |
@@ -150,8 +149,7 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
// Change the overlay to the given fraction, with or without animation. Only |
// guaranteed to work properly with |fraction == 0| or |fraction == 1|. This |
// performs the show/hide (animation) immediately. It does not touch the timers. |
-- (void)changeOverlayToFraction:(CGFloat)fraction |
- withAnimation:(BOOL)animate; |
+- (void)changeOverlayToFraction:(CGFloat)fraction withAnimation:(BOOL)animate; |
// Schedule the floating bar to be shown/hidden because of mouse position. |
- (void)scheduleShowForMouse; |
@@ -204,9 +202,8 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
@end |
-@implementation PresentationModeController |
+@implementation FullscreenToolbarController |
-@synthesize inPresentationMode = inPresentationMode_; |
@synthesize slidingStyle = slidingStyle_; |
@synthesize toolbarFraction = toolbarFraction_; |
@@ -220,8 +217,8 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
// Let the world know what we're up to. |
[[NSNotificationCenter defaultCenter] |
- postNotificationName:kWillEnterFullscreenNotification |
- object:nil]; |
+ postNotificationName:kWillEnterFullscreenNotification |
+ object:nil]; |
// Install the Carbon event handler for the menubar show, hide and |
// undocumented reveal event. |
@@ -244,16 +241,16 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
- (void)dealloc { |
RemoveEventHandler(menuBarTrackingHandler_); |
- DCHECK(!inPresentationMode_); |
+ DCHECK(!inFullscreenMode_); |
DCHECK(!trackingArea_); |
[super dealloc]; |
} |
-- (void)enterPresentationModeForContentView:(NSView*)contentView |
- showDropdown:(BOOL)showDropdown { |
- DCHECK(!inPresentationMode_); |
- enteringPresentationMode_ = YES; |
- inPresentationMode_ = YES; |
+- (void)setupFullscreenToolbarForContentView:(NSView*)contentView |
+ showDropdown:(BOOL)showDropdown { |
+ DCHECK(!inFullscreenMode_); |
+ settingUp_ = YES; |
+ inFullscreenMode_ = YES; |
contentView_ = contentView; |
[self changeToolbarFraction:(showDropdown ? 1 : 0)]; |
[self updateMenuBarAndDockVisibility]; |
@@ -272,15 +269,15 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
name:NSWindowDidResignMainNotification |
object:window]; |
- enteringPresentationMode_ = NO; |
+ settingUp_ = NO; |
} |
-- (void)exitPresentationMode { |
+- (void)exitFullscreenMode { |
[[NSNotificationCenter defaultCenter] |
- postNotificationName:kWillLeaveFullscreenNotification |
- object:nil]; |
- DCHECK(inPresentationMode_); |
- inPresentationMode_ = NO; |
+ postNotificationName:kWillLeaveFullscreenNotification |
+ object:nil]; |
+ DCHECK(inFullscreenMode_); |
+ inFullscreenMode_ = NO; |
[self cleanup]; |
} |
@@ -307,7 +304,7 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
} |
- (void)overlayFrameChanged:(NSRect)frame { |
- if (!inPresentationMode_) |
+ if (!inFullscreenMode_) |
return; |
// Make sure |trackingAreaBounds_| always reflects either the tracking area or |
@@ -328,7 +325,7 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
// If this is part of the initial setup, lock bar visibility if the mouse is |
// within the tracking area bounds. |
- if (enteringPresentationMode_ && [self mouseInsideTrackingRect]) |
+ if (settingUp_ && [self mouseInsideTrackingRect]) |
[browserController_ lockBarVisibilityForOwner:self |
withAnimation:NO |
delay:NO]; |
@@ -336,7 +333,7 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
} |
- (void)ensureOverlayShownWithAnimation:(BOOL)animate delay:(BOOL)delay { |
- if (!inPresentationMode_) |
+ if (!inFullscreenMode_) |
return; |
if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) |
@@ -360,7 +357,7 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
} |
- (void)ensureOverlayHiddenWithAnimation:(BOOL)animate delay:(BOOL)delay { |
- if (!inPresentationMode_) |
+ if (!inFullscreenMode_) |
return; |
if (self.slidingStyle == fullscreen_mac::OMNIBOX_TABS_PRESENT) |
@@ -446,9 +443,9 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
return [browserController_ window].isMainWindow; |
} |
-// Used to activate the floating bar in presentation mode. |
+// Used to activate the floating bar if the toolbar is hidden. |
- (void)mouseEntered:(NSEvent*)event { |
- DCHECK(inPresentationMode_); |
+ DCHECK(inFullscreenMode_); |
// Having gotten a mouse entered, we no longer need to do exit checks. |
[self cancelMouseExitCheck]; |
@@ -464,9 +461,9 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
} |
} |
-// Used to deactivate the floating bar in presentation mode. |
+// Used to deactivate the floating bar if the toolbar is hidden. |
- (void)mouseExited:(NSEvent*)event { |
- DCHECK(inPresentationMode_); |
+ DCHECK(inFullscreenMode_); |
NSTrackingArea* trackingArea = [event trackingArea]; |
if (trackingArea == trackingArea_) { |
@@ -542,8 +539,7 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
@end |
- |
-@implementation PresentationModeController (PrivateMethods) |
+@implementation FullscreenToolbarController (PrivateMethods) |
- (void)updateMenuBarAndDockVisibility { |
if (![self isMainWindow] || ![browserController_ isInImmersiveFullscreen]) { |
@@ -581,8 +577,7 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
return base::mac::kFullScreenModeHideAll; |
} |
-- (void)changeOverlayToFraction:(CGFloat)fraction |
- withAnimation:(BOOL)animate { |
+- (void)changeOverlayToFraction:(CGFloat)fraction withAnimation:(BOOL)animate { |
// The non-animated case is really simple, so do it and return. |
if (!animate) { |
[currentAnimation_ stopAnimation]; |
@@ -600,11 +595,11 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
[currentAnimation_ stopAnimation]; |
// Create the animation and set it up. |
- currentAnimation_.reset( |
- [[DropdownAnimation alloc] initWithFraction:fraction |
- fullDuration:kDropdownAnimationDuration |
- animationCurve:NSAnimationEaseOut |
- controller:self]); |
+ currentAnimation_.reset([[DropdownAnimation alloc] |
+ initWithFraction:fraction |
+ fullDuration:kDropdownAnimationDuration |
+ animationCurve:NSAnimationEaseOut |
+ controller:self]); |
DCHECK(currentAnimation_); |
[currentAnimation_ setAnimationBlockingMode:NSAnimationNonblocking]; |
[currentAnimation_ setDelegate:self]; |
@@ -640,12 +635,11 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
} |
// Create and add a new tracking area for |frame|. |
- trackingArea_.reset( |
- [[NSTrackingArea alloc] initWithRect:trackingAreaBounds_ |
- options:NSTrackingMouseEnteredAndExited | |
- NSTrackingActiveInKeyWindow |
- owner:self |
- userInfo:nil]); |
+ trackingArea_.reset([[NSTrackingArea alloc] |
+ initWithRect:trackingAreaBounds_ |
+ options:NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow |
+ owner:self |
+ userInfo:nil]); |
DCHECK(contentView_); |
[contentView_ addTrackingArea:trackingArea_]; |
} |
@@ -673,7 +667,8 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
- (void)cancelMouseExitCheck { |
[NSObject cancelPreviousPerformRequestsWithTarget:self |
- selector:@selector(checkForMouseExit) object:nil]; |
+ selector:@selector(checkForMouseExit) |
+ object:nil]; |
} |
- (void)checkForMouseExit { |
@@ -758,7 +753,7 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
[self removeTrackingAreaIfNecessary]; |
contentView_ = nil; |
- // This isn't tracked when not in presentation mode. |
+ // This isn't tracked when not in fullscreen mode. |
[browserController_ releaseBarVisibilityForOwner:self |
withAnimation:NO |
delay:NO]; |