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 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
11 #import "base/mac/mac_util.h" | 11 #import "base/mac/mac_util.h" |
12 #include "chrome/browser/fullscreen.h" | 12 #include "chrome/browser/fullscreen.h" |
13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 13 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
14 #import "chrome/browser/ui/cocoa/nsview_additions.h" | 14 #import "chrome/browser/ui/cocoa/nsview_additions.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h
" | 16 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h
" |
17 | 17 |
18 NSString* const kWillEnterFullscreenNotification = | 18 NSString* const kWillEnterFullscreenNotification = |
19 @"WillEnterFullscreenNotification"; | 19 @"WillEnterFullscreenNotification"; |
20 NSString* const kWillLeaveFullscreenNotification = | 20 NSString* const kWillLeaveFullscreenNotification = |
21 @"WillLeaveFullscreenNotification"; | 21 @"WillLeaveFullscreenNotification"; |
22 | 22 |
| 23 @interface PresentationModeController () |
| 24 // Sets a new current floating bar shown fraction. NOTE: This function has side |
| 25 // effects, such as modifying the system fullscreen mode (menu bar shown state). |
| 26 - (void)changeToolbarFraction:(CGFloat)fraction; |
| 27 |
| 28 // Callback for menu bar animations. |
| 29 - (void)setMenuBarRevealProgress:(CGFloat)progress; |
| 30 @end |
| 31 |
23 namespace { | 32 namespace { |
| 33 |
24 // The activation zone for the main menu is 4 pixels high; if we make it any | 34 // The activation zone for the main menu is 4 pixels high; if we make it any |
25 // smaller, then the menu can be made to appear without the bar sliding down. | 35 // smaller, then the menu can be made to appear without the bar sliding down. |
26 const CGFloat kDropdownActivationZoneHeight = 4; | 36 const CGFloat kDropdownActivationZoneHeight = 4; |
27 const NSTimeInterval kDropdownAnimationDuration = 0.12; | 37 const NSTimeInterval kDropdownAnimationDuration = 0.12; |
28 const NSTimeInterval kMouseExitCheckDelay = 0.1; | 38 const NSTimeInterval kMouseExitCheckDelay = 0.1; |
29 // This show delay attempts to match the delay for the main menu. | 39 // This show delay attempts to match the delay for the main menu. |
30 const NSTimeInterval kDropdownShowDelay = 0.3; | 40 const NSTimeInterval kDropdownShowDelay = 0.3; |
31 const NSTimeInterval kDropdownHideDelay = 0.2; | 41 const NSTimeInterval kDropdownHideDelay = 0.2; |
32 | 42 |
33 // The amount by which the floating bar is offset downwards (to avoid the menu) | 43 // The amount by which the floating bar is offset downwards (to avoid the menu) |
34 // in presentation mode. (We can't use |-[NSMenu menuBarHeight]| since it | 44 // in presentation mode. (We can't use |-[NSMenu menuBarHeight]| since it |
35 // returns 0 when the menu bar is hidden.) | 45 // returns 0 when the menu bar is hidden.) |
36 const CGFloat kFloatingBarVerticalOffset = 22; | 46 const CGFloat kFloatingBarVerticalOffset = 22; |
37 | 47 |
| 48 OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
| 49 EventRef event, |
| 50 void* context) { |
| 51 PresentationModeController* self = |
| 52 static_cast<PresentationModeController*>(context); |
| 53 CGFloat revealFraction = 0; |
| 54 GetEventParameter(event, |
| 55 FOUR_CHAR_CODE('rvlf'), |
| 56 typeCGFloat, |
| 57 NULL, |
| 58 sizeof(CGFloat), |
| 59 NULL, |
| 60 &revealFraction); |
| 61 [self setMenuBarRevealProgress:revealFraction]; |
| 62 return CallNextEventHandler(handler, event); |
| 63 } |
| 64 |
38 } // end namespace | 65 } // end namespace |
39 | 66 |
40 | |
41 // Helper class to manage animations for the dropdown bar. Calls | 67 // Helper class to manage animations for the dropdown bar. Calls |
42 // [PresentationModeController changeFloatingBarShownFraction] once per | 68 // [PresentationModeController changeToolbarFraction] once per |
43 // animation step. | 69 // animation step. |
44 @interface DropdownAnimation : NSAnimation { | 70 @interface DropdownAnimation : NSAnimation { |
45 @private | 71 @private |
46 PresentationModeController* controller_; | 72 PresentationModeController* controller_; |
47 CGFloat startFraction_; | 73 CGFloat startFraction_; |
48 CGFloat endFraction_; | 74 CGFloat endFraction_; |
49 } | 75 } |
50 | 76 |
51 @property(readonly, nonatomic) CGFloat startFraction; | 77 @property(readonly, nonatomic) CGFloat startFraction; |
52 @property(readonly, nonatomic) CGFloat endFraction; | 78 @property(readonly, nonatomic) CGFloat endFraction; |
(...skipping 12 matching lines...) Expand all Loading... |
65 | 91 |
66 @synthesize startFraction = startFraction_; | 92 @synthesize startFraction = startFraction_; |
67 @synthesize endFraction = endFraction_; | 93 @synthesize endFraction = endFraction_; |
68 | 94 |
69 - (id)initWithFraction:(CGFloat)toFraction | 95 - (id)initWithFraction:(CGFloat)toFraction |
70 fullDuration:(CGFloat)fullDuration | 96 fullDuration:(CGFloat)fullDuration |
71 animationCurve:(NSAnimationCurve)animationCurve | 97 animationCurve:(NSAnimationCurve)animationCurve |
72 controller:(PresentationModeController*)controller { | 98 controller:(PresentationModeController*)controller { |
73 // Calculate the effective duration, based on the current shown fraction. | 99 // Calculate the effective duration, based on the current shown fraction. |
74 DCHECK(controller); | 100 DCHECK(controller); |
75 CGFloat fromFraction = [controller floatingBarShownFraction]; | 101 CGFloat fromFraction = controller.toolbarFraction; |
76 CGFloat effectiveDuration = fabs(fullDuration * (fromFraction - toFraction)); | 102 CGFloat effectiveDuration = fabs(fullDuration * (fromFraction - toFraction)); |
77 | 103 |
78 if ((self = [super gtm_initWithDuration:effectiveDuration | 104 if ((self = [super gtm_initWithDuration:effectiveDuration |
79 eventMask:NSLeftMouseDownMask | 105 eventMask:NSLeftMouseDownMask |
80 animationCurve:animationCurve])) { | 106 animationCurve:animationCurve])) { |
81 startFraction_ = fromFraction; | 107 startFraction_ = fromFraction; |
82 endFraction_ = toFraction; | 108 endFraction_ = toFraction; |
83 controller_ = controller; | 109 controller_ = controller; |
84 } | 110 } |
85 return self; | 111 return self; |
86 } | 112 } |
87 | 113 |
88 // Called once per animation step. Overridden to change the floating bar's | 114 // Called once per animation step. Overridden to change the floating bar's |
89 // position based on the animation's progress. | 115 // position based on the animation's progress. |
90 - (void)setCurrentProgress:(NSAnimationProgress)progress { | 116 - (void)setCurrentProgress:(NSAnimationProgress)progress { |
91 CGFloat fraction = | 117 CGFloat fraction = |
92 startFraction_ + (progress * (endFraction_ - startFraction_)); | 118 startFraction_ + (progress * (endFraction_ - startFraction_)); |
93 [controller_ changeFloatingBarShownFraction:fraction]; | 119 [controller_ changeToolbarFraction:fraction]; |
94 } | 120 } |
95 | 121 |
96 @end | 122 @end |
97 | 123 |
98 | 124 |
99 @interface PresentationModeController (PrivateMethods) | 125 @interface PresentationModeController (PrivateMethods) |
100 | 126 |
101 // Updates the visibility of the menu bar and the dock. | 127 // Updates the visibility of the menu bar and the dock. |
102 - (void)updateMenuBarAndDockVisibility; | 128 - (void)updateMenuBarAndDockVisibility; |
103 | 129 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 182 |
157 // Stops any running animations, removes tracking areas, etc. | 183 // Stops any running animations, removes tracking areas, etc. |
158 - (void)cleanup; | 184 - (void)cleanup; |
159 | 185 |
160 // Shows and hides the UI associated with this window being active (having main | 186 // Shows and hides the UI associated with this window being active (having main |
161 // status). This includes hiding the menu bar. These functions are called when | 187 // status). This includes hiding the menu bar. These functions are called when |
162 // the window gains or loses main status as well as in |-cleanup|. | 188 // the window gains or loses main status as well as in |-cleanup|. |
163 - (void)showActiveWindowUI; | 189 - (void)showActiveWindowUI; |
164 - (void)hideActiveWindowUI; | 190 - (void)hideActiveWindowUI; |
165 | 191 |
| 192 // In Immersive Fullscreen, the menubar is visible iff. toolbarFraction_ >= |
| 193 // 1.0. |
| 194 - (BOOL)shouldShowMenubarInImmersiveFullscreen; |
| 195 |
166 @end | 196 @end |
167 | 197 |
168 | 198 |
169 @implementation PresentationModeController | 199 @implementation PresentationModeController |
170 | 200 |
171 @synthesize inPresentationMode = inPresentationMode_; | 201 @synthesize inPresentationMode = inPresentationMode_; |
| 202 @synthesize slidingStyle = slidingStyle_; |
| 203 @synthesize toolbarFraction = toolbarFraction_; |
172 | 204 |
173 - (id)initWithBrowserController:(BrowserWindowController*)controller { | 205 - (id)initWithBrowserController:(BrowserWindowController*)controller |
| 206 style:(fullscreen_mac::SlidingStyle)style { |
174 if ((self = [super init])) { | 207 if ((self = [super init])) { |
175 browserController_ = controller; | 208 browserController_ = controller; |
176 systemFullscreenMode_ = base::mac::kFullScreenModeNormal; | 209 systemFullscreenMode_ = base::mac::kFullScreenModeNormal; |
| 210 slidingStyle_ = style; |
177 } | 211 } |
178 | 212 |
179 // Let the world know what we're up to. | 213 // Let the world know what we're up to. |
180 [[NSNotificationCenter defaultCenter] | 214 [[NSNotificationCenter defaultCenter] |
181 postNotificationName:kWillEnterFullscreenNotification | 215 postNotificationName:kWillEnterFullscreenNotification |
182 object:nil]; | 216 object:nil]; |
183 | 217 |
| 218 // Install the Carbon event handler for the undocumented menu bar show/hide |
| 219 // event. |
| 220 EventTypeSpec eventSpec = {kEventClassMenu, 2004}; |
| 221 InstallApplicationEventHandler(NewEventHandlerUPP(&MenuBarRevealHandler), |
| 222 1, |
| 223 &eventSpec, |
| 224 self, |
| 225 &menuBarTrackingHandler_); |
184 return self; | 226 return self; |
185 } | 227 } |
186 | 228 |
187 - (void)dealloc { | 229 - (void)dealloc { |
| 230 RemoveEventHandler(menuBarTrackingHandler_); |
188 DCHECK(!inPresentationMode_); | 231 DCHECK(!inPresentationMode_); |
189 DCHECK(!trackingArea_); | 232 DCHECK(!trackingArea_); |
190 [super dealloc]; | 233 [super dealloc]; |
191 } | 234 } |
192 | 235 |
193 - (void)enterPresentationModeForContentView:(NSView*)contentView | 236 - (void)enterPresentationModeForContentView:(NSView*)contentView |
194 showDropdown:(BOOL)showDropdown { | 237 showDropdown:(BOOL)showDropdown { |
195 DCHECK(!inPresentationMode_); | 238 DCHECK(!inPresentationMode_); |
196 enteringPresentationMode_ = YES; | 239 enteringPresentationMode_ = YES; |
197 inPresentationMode_ = YES; | 240 inPresentationMode_ = YES; |
198 contentView_ = contentView; | 241 contentView_ = contentView; |
199 [self changeFloatingBarShownFraction:(showDropdown ? 1 : 0)]; | 242 [self changeToolbarFraction:(showDropdown ? 1 : 0)]; |
| 243 [self updateMenuBarAndDockVisibility]; |
200 | 244 |
201 // Register for notifications. Self is removed as an observer in |-cleanup|. | 245 // Register for notifications. Self is removed as an observer in |-cleanup|. |
202 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; | 246 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; |
203 NSWindow* window = [browserController_ window]; | 247 NSWindow* window = [browserController_ window]; |
204 | 248 |
205 // Disable these notifications on Lion as they cause crashes. | 249 // Disable these notifications on Lion as they cause crashes. |
206 // TODO(rohitrao): Figure out what happens if a fullscreen window changes | 250 // TODO(rohitrao): Figure out what happens if a fullscreen window changes |
207 // monitors on Lion. | 251 // monitors on Lion. |
208 if (base::mac::IsOSSnowLeopard()) { | 252 if (base::mac::IsOSSnowLeopard()) { |
209 [nc addObserver:self | 253 [nc addObserver:self |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 [self setupTrackingArea]; | 339 [self setupTrackingArea]; |
296 } | 340 } |
297 | 341 |
298 - (void)ensureOverlayShownWithAnimation:(BOOL)animate delay:(BOOL)delay { | 342 - (void)ensureOverlayShownWithAnimation:(BOOL)animate delay:(BOOL)delay { |
299 if (!inPresentationMode_) | 343 if (!inPresentationMode_) |
300 return; | 344 return; |
301 | 345 |
302 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) | 346 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) |
303 return; | 347 return; |
304 | 348 |
| 349 if (self.slidingStyle == fullscreen_mac::OMNIBOX_TABS_PRESENT) |
| 350 return; |
| 351 |
305 if (animate) { | 352 if (animate) { |
306 if (delay) { | 353 if (delay) { |
307 [self startShowTimer]; | 354 [self startShowTimer]; |
308 } else { | 355 } else { |
309 [self cancelAllTimers]; | 356 [self cancelAllTimers]; |
310 [self changeOverlayToFraction:1 withAnimation:YES]; | 357 [self changeOverlayToFraction:1 withAnimation:YES]; |
311 } | 358 } |
312 } else { | 359 } else { |
313 DCHECK(!delay); | 360 DCHECK(!delay); |
314 [self cancelAllTimers]; | 361 [self cancelAllTimers]; |
315 [self changeOverlayToFraction:1 withAnimation:NO]; | 362 [self changeOverlayToFraction:1 withAnimation:NO]; |
316 } | 363 } |
317 } | 364 } |
318 | 365 |
319 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate delay:(BOOL)delay { | 366 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate delay:(BOOL)delay { |
320 if (!inPresentationMode_) | 367 if (!inPresentationMode_) |
321 return; | 368 return; |
322 | 369 |
| 370 if (self.slidingStyle == fullscreen_mac::OMNIBOX_TABS_PRESENT) |
| 371 return; |
| 372 |
323 if (animate) { | 373 if (animate) { |
324 if (delay) { | 374 if (delay) { |
325 [self startHideTimer]; | 375 [self startHideTimer]; |
326 } else { | 376 } else { |
327 [self cancelAllTimers]; | 377 [self cancelAllTimers]; |
328 [self changeOverlayToFraction:0 withAnimation:YES]; | 378 [self changeOverlayToFraction:0 withAnimation:YES]; |
329 } | 379 } |
330 } else { | 380 } else { |
331 DCHECK(!delay); | 381 DCHECK(!delay); |
332 [self cancelAllTimers]; | 382 [self cancelAllTimers]; |
333 [self changeOverlayToFraction:0 withAnimation:NO]; | 383 [self changeOverlayToFraction:0 withAnimation:NO]; |
334 } | 384 } |
335 } | 385 } |
336 | 386 |
337 - (void)cancelAnimationAndTimers { | 387 - (void)cancelAnimationAndTimers { |
338 [self cancelAllTimers]; | 388 [self cancelAllTimers]; |
339 [currentAnimation_ stopAnimation]; | 389 [currentAnimation_ stopAnimation]; |
340 currentAnimation_.reset(); | 390 currentAnimation_.reset(); |
341 } | 391 } |
342 | 392 |
343 - (CGFloat)floatingBarShownFraction { | |
344 return [browserController_ floatingBarShownFraction]; | |
345 } | |
346 | |
347 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode { | 393 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode { |
348 if (mode == systemFullscreenMode_) | 394 if (mode == systemFullscreenMode_) |
349 return; | 395 return; |
350 if (systemFullscreenMode_ == base::mac::kFullScreenModeNormal) | 396 if (systemFullscreenMode_ == base::mac::kFullScreenModeNormal) |
351 base::mac::RequestFullScreen(mode); | 397 base::mac::RequestFullScreen(mode); |
352 else if (mode == base::mac::kFullScreenModeNormal) | 398 else if (mode == base::mac::kFullScreenModeNormal) |
353 base::mac::ReleaseFullScreen(systemFullscreenMode_); | 399 base::mac::ReleaseFullScreen(systemFullscreenMode_); |
354 else | 400 else |
355 base::mac::SwitchFullScreenModes(systemFullscreenMode_, mode); | 401 base::mac::SwitchFullScreenModes(systemFullscreenMode_, mode); |
356 systemFullscreenMode_ = mode; | 402 systemFullscreenMode_ = mode; |
357 } | 403 } |
358 | 404 |
359 - (void)changeFloatingBarShownFraction:(CGFloat)fraction { | 405 - (void)changeToolbarFraction:(CGFloat)fraction { |
360 [browserController_ setFloatingBarShownFraction:fraction]; | 406 toolbarFraction_ = fraction; |
| 407 [browserController_ layoutSubviews]; |
361 | 408 |
362 [self updateMenuBarAndDockVisibility]; | 409 // In AppKit fullscreen, moving the mouse to the top of the screen toggles |
| 410 // menu visibility. Replicate the same effect for immersive fullscreen. |
| 411 if ([browserController_ isInImmersiveFullscreen]) |
| 412 [self updateMenuBarAndDockVisibility]; |
| 413 } |
| 414 |
| 415 // This method works, but is fragile. |
| 416 // |
| 417 // It gets used during view layout, which sometimes needs to be done at the |
| 418 // beginning of an animation. As such, this method needs to reflect the |
| 419 // menubarOffset expected at the end of the animation. This information is not |
| 420 // readily available. (The layout logic needs a refactor). |
| 421 // |
| 422 // For AppKit Fullscreen, the menubar always starts hidden, and |
| 423 // menubarFraction_ always starts at 0, so the logic happens to work. For |
| 424 // Immersive Fullscreen, this class controls the visibility of the menu bar, so |
| 425 // the logic is correct and not fragile. |
| 426 - (CGFloat)menubarOffset { |
| 427 if ([browserController_ isInAppKitFullscreen]) |
| 428 return -std::floor(menubarFraction_ * [self floatingBarVerticalOffset]); |
| 429 |
| 430 return [self shouldShowMenubarInImmersiveFullscreen] |
| 431 ? -[self floatingBarVerticalOffset] |
| 432 : 0; |
363 } | 433 } |
364 | 434 |
365 // Used to activate the floating bar in presentation mode. | 435 // Used to activate the floating bar in presentation mode. |
366 - (void)mouseEntered:(NSEvent*)event { | 436 - (void)mouseEntered:(NSEvent*)event { |
367 DCHECK(inPresentationMode_); | 437 DCHECK(inPresentationMode_); |
368 | 438 |
369 // Having gotten a mouse entered, we no longer need to do exit checks. | 439 // Having gotten a mouse entered, we no longer need to do exit checks. |
370 [self cancelMouseExitCheck]; | 440 [self cancelMouseExitCheck]; |
371 | 441 |
372 NSTrackingArea* trackingArea = [event trackingArea]; | 442 NSTrackingArea* trackingArea = [event trackingArea]; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 // |any updates that may have come while the animation was running. Install a | 489 // |any updates that may have come while the animation was running. Install a |
420 // new tracking area with these bounds. | 490 // new tracking area with these bounds. |
421 [self setupTrackingArea]; | 491 [self setupTrackingArea]; |
422 | 492 |
423 // TODO(viettrungluu): Better would be to check during the animation; doing it | 493 // TODO(viettrungluu): Better would be to check during the animation; doing it |
424 // here means that the timing is slightly off. | 494 // here means that the timing is slightly off. |
425 if (![self mouseInsideTrackingRect]) | 495 if (![self mouseInsideTrackingRect]) |
426 [self scheduleHideForMouse]; | 496 [self scheduleHideForMouse]; |
427 } | 497 } |
428 | 498 |
| 499 - (void)setMenuBarRevealProgress:(CGFloat)progress { |
| 500 menubarFraction_ = progress; |
| 501 |
| 502 // If an animation is not running, then -layoutSubviews will not be called |
| 503 // for each tick of the menu bar reveal. Do that manually. |
| 504 // TODO(erikchen): The animation is janky. layoutSubviews need a refactor so |
| 505 // that it calls setFrameOffset: instead of setFrame: if the frame's size has |
| 506 // not changed. |
| 507 if (!currentAnimation_.get()) |
| 508 [browserController_ layoutSubviews]; |
| 509 } |
| 510 |
429 @end | 511 @end |
430 | 512 |
431 | 513 |
432 @implementation PresentationModeController (PrivateMethods) | 514 @implementation PresentationModeController (PrivateMethods) |
433 | 515 |
434 - (void)updateMenuBarAndDockVisibility { | 516 - (void)updateMenuBarAndDockVisibility { |
435 if (![[browserController_ window] isMainWindow] || | 517 if (![[browserController_ window] isMainWindow] || |
436 ![browserController_ isInImmersiveFullscreen]) { | 518 ![browserController_ isInImmersiveFullscreen]) { |
437 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeNormal]; | 519 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeNormal]; |
438 return; | 520 return; |
(...skipping 17 matching lines...) Expand all Loading... |
456 return eachScreenShouldHaveMenuBar ?: [self isWindowOnPrimaryScreen]; | 538 return eachScreenShouldHaveMenuBar ?: [self isWindowOnPrimaryScreen]; |
457 } | 539 } |
458 | 540 |
459 - (BOOL)isWindowOnPrimaryScreen { | 541 - (BOOL)isWindowOnPrimaryScreen { |
460 NSScreen* screen = [[browserController_ window] screen]; | 542 NSScreen* screen = [[browserController_ window] screen]; |
461 NSScreen* primaryScreen = [[NSScreen screens] objectAtIndex:0]; | 543 NSScreen* primaryScreen = [[NSScreen screens] objectAtIndex:0]; |
462 return (screen == primaryScreen); | 544 return (screen == primaryScreen); |
463 } | 545 } |
464 | 546 |
465 - (base::mac::FullScreenMode)desiredSystemFullscreenMode { | 547 - (base::mac::FullScreenMode)desiredSystemFullscreenMode { |
466 if ([browserController_ floatingBarShownFraction] >= 1.0) | 548 if ([self shouldShowMenubarInImmersiveFullscreen]) |
467 return base::mac::kFullScreenModeHideDock; | 549 return base::mac::kFullScreenModeHideDock; |
468 return base::mac::kFullScreenModeHideAll; | 550 return base::mac::kFullScreenModeHideAll; |
469 } | 551 } |
470 | 552 |
471 - (void)changeOverlayToFraction:(CGFloat)fraction | 553 - (void)changeOverlayToFraction:(CGFloat)fraction |
472 withAnimation:(BOOL)animate { | 554 withAnimation:(BOOL)animate { |
473 // The non-animated case is really simple, so do it and return. | 555 // The non-animated case is really simple, so do it and return. |
474 if (!animate) { | 556 if (!animate) { |
475 [currentAnimation_ stopAnimation]; | 557 [currentAnimation_ stopAnimation]; |
476 [self changeFloatingBarShownFraction:fraction]; | 558 [self changeToolbarFraction:fraction]; |
477 return; | 559 return; |
478 } | 560 } |
479 | 561 |
480 // If we're already animating to the given fraction, then there's nothing more | 562 // If we're already animating to the given fraction, then there's nothing more |
481 // to do. | 563 // to do. |
482 if (currentAnimation_ && [currentAnimation_ endFraction] == fraction) | 564 if (currentAnimation_ && [currentAnimation_ endFraction] == fraction) |
483 return; | 565 return; |
484 | 566 |
485 // In all other cases, we want to cancel any running animation (which may be | 567 // In all other cases, we want to cancel any running animation (which may be |
486 // to show or to hide). | 568 // to show or to hide). |
487 [currentAnimation_ stopAnimation]; | 569 [currentAnimation_ stopAnimation]; |
488 | 570 |
489 // Now, if it happens to already be in the right state, there's nothing more | |
490 // to do. | |
491 if ([browserController_ floatingBarShownFraction] == fraction) | |
492 return; | |
493 | |
494 // Create the animation and set it up. | 571 // Create the animation and set it up. |
495 currentAnimation_.reset( | 572 currentAnimation_.reset( |
496 [[DropdownAnimation alloc] initWithFraction:fraction | 573 [[DropdownAnimation alloc] initWithFraction:fraction |
497 fullDuration:kDropdownAnimationDuration | 574 fullDuration:kDropdownAnimationDuration |
498 animationCurve:NSAnimationEaseOut | 575 animationCurve:NSAnimationEaseOut |
499 controller:self]); | 576 controller:self]); |
500 DCHECK(currentAnimation_); | 577 DCHECK(currentAnimation_); |
501 [currentAnimation_ setAnimationBlockingMode:NSAnimationNonblocking]; | 578 [currentAnimation_ setAnimationBlockingMode:NSAnimationNonblocking]; |
502 [currentAnimation_ setDelegate:self]; | 579 [currentAnimation_ setDelegate:self]; |
503 | 580 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 | 746 |
670 // TODO(rohitrao): Insert the Exit Fullscreen button. http://crbug.com/35956 | 747 // TODO(rohitrao): Insert the Exit Fullscreen button. http://crbug.com/35956 |
671 } | 748 } |
672 | 749 |
673 - (void)hideActiveWindowUI { | 750 - (void)hideActiveWindowUI { |
674 [self updateMenuBarAndDockVisibility]; | 751 [self updateMenuBarAndDockVisibility]; |
675 | 752 |
676 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 | 753 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 |
677 } | 754 } |
678 | 755 |
| 756 - (BOOL)shouldShowMenubarInImmersiveFullscreen { |
| 757 return toolbarFraction_ >= 1.0; |
| 758 } |
| 759 |
679 @end | 760 @end |
OLD | NEW |