Chromium Code Reviews| 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 13 matching lines...) Expand all Loading... | |
| 24 | 24 |
| 25 // The activation zone for the main menu is 4 pixels high; if we make it any | 25 // The activation zone for the main menu is 4 pixels high; if we make it any |
| 26 // smaller, then the menu can be made to appear without the bar sliding down. | 26 // smaller, then the menu can be made to appear without the bar sliding down. |
| 27 const CGFloat kDropdownActivationZoneHeight = 4; | 27 const CGFloat kDropdownActivationZoneHeight = 4; |
| 28 const NSTimeInterval kDropdownAnimationDuration = 0.12; | 28 const NSTimeInterval kDropdownAnimationDuration = 0.12; |
| 29 const NSTimeInterval kMouseExitCheckDelay = 0.1; | 29 const NSTimeInterval kMouseExitCheckDelay = 0.1; |
| 30 // This show delay attempts to match the delay for the main menu. | 30 // This show delay attempts to match the delay for the main menu. |
| 31 const NSTimeInterval kDropdownShowDelay = 0.3; | 31 const NSTimeInterval kDropdownShowDelay = 0.3; |
| 32 const NSTimeInterval kDropdownHideDelay = 0.2; | 32 const NSTimeInterval kDropdownHideDelay = 0.2; |
| 33 | 33 |
| 34 // The duration the toolbar is revealed for tab strip changes. | |
| 35 const NSTimeInterval kDropdownForTabStripChangesDuration = 0.75; | |
| 36 | |
| 34 // The event kind value for a undocumented menubar show/hide Carbon event. | 37 // The event kind value for a undocumented menubar show/hide Carbon event. |
| 35 const CGFloat kMenuBarRevealEventKind = 2004; | 38 const CGFloat kMenuBarRevealEventKind = 2004; |
| 36 | 39 |
| 37 // The amount by which the floating bar is offset downwards (to avoid the menu) | 40 // The amount by which the floating bar is offset downwards (to avoid the menu) |
| 38 // in presentation mode. (We can't use |-[NSMenu menuBarHeight]| since it | 41 // in presentation mode. (We can't use |-[NSMenu menuBarHeight]| since it |
| 39 // returns 0 when the menu bar is hidden.) | 42 // returns 0 when the menu bar is hidden.) |
| 40 const CGFloat kFloatingBarVerticalOffset = 22; | 43 const CGFloat kFloatingBarVerticalOffset = 22; |
| 41 | 44 |
| 42 OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, | 45 OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, |
| 43 EventRef event, | 46 EventRef event, |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 [self changeOverlayToFraction:0 withAnimation:NO]; | 380 [self changeOverlayToFraction:0 withAnimation:NO]; |
| 378 } | 381 } |
| 379 } | 382 } |
| 380 | 383 |
| 381 - (void)cancelAnimationAndTimers { | 384 - (void)cancelAnimationAndTimers { |
| 382 [self cancelAllTimers]; | 385 [self cancelAllTimers]; |
| 383 [currentAnimation_ stopAnimation]; | 386 [currentAnimation_ stopAnimation]; |
| 384 currentAnimation_.reset(); | 387 currentAnimation_.reset(); |
| 385 } | 388 } |
| 386 | 389 |
| 390 - (void)revealToolbarForTabStripChanges { | |
| 391 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 392 switches::kEnableFullscreenToolbarReveal)) { | |
| 393 return; | |
| 394 } | |
| 395 | |
| 396 revealToolbarForTabStripChanges_ = YES; | |
| 397 [self ensureOverlayShownWithAnimation:YES delay:YES]; | |
|
Robert Sesek
2016/06/23 14:08:24
What if multiple tabs are inserted and this method
spqchan
2016/06/23 19:41:52
If the method calls before it fires, then hideTime
| |
| 398 } | |
| 399 | |
| 387 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode { | 400 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode { |
| 388 if (mode == systemFullscreenMode_) | 401 if (mode == systemFullscreenMode_) |
| 389 return; | 402 return; |
| 390 if (systemFullscreenMode_ == base::mac::kFullScreenModeNormal) | 403 if (systemFullscreenMode_ == base::mac::kFullScreenModeNormal) |
| 391 base::mac::RequestFullScreen(mode); | 404 base::mac::RequestFullScreen(mode); |
| 392 else if (mode == base::mac::kFullScreenModeNormal) | 405 else if (mode == base::mac::kFullScreenModeNormal) |
| 393 base::mac::ReleaseFullScreen(systemFullscreenMode_); | 406 base::mac::ReleaseFullScreen(systemFullscreenMode_); |
| 394 else | 407 else |
| 395 base::mac::SwitchFullScreenModes(systemFullscreenMode_, mode); | 408 base::mac::SwitchFullScreenModes(systemFullscreenMode_, mode); |
| 396 systemFullscreenMode_ = mode; | 409 systemFullscreenMode_ = mode; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 currentAnimation_.reset(); | 488 currentAnimation_.reset(); |
| 476 | 489 |
| 477 // Invariant says that the tracking area is not installed while animations are | 490 // Invariant says that the tracking area is not installed while animations are |
| 478 // in progress. Ensure this is true. | 491 // in progress. Ensure this is true. |
| 479 DCHECK(!trackingArea_); | 492 DCHECK(!trackingArea_); |
| 480 [self removeTrackingAreaIfNecessary]; // For paranoia. | 493 [self removeTrackingAreaIfNecessary]; // For paranoia. |
| 481 | 494 |
| 482 // Don't automatically set up a new tracking area. When explicitly stopped, | 495 // Don't automatically set up a new tracking area. When explicitly stopped, |
| 483 // either another animation is going to start immediately or the state will be | 496 // either another animation is going to start immediately or the state will be |
| 484 // changed immediately. | 497 // changed immediately. |
| 498 if (revealToolbarForTabStripChanges_) { | |
| 499 if (toolbarFraction_ > 0.0) { | |
| 500 // Set the timer to hide the toolbar. | |
| 501 [hideTimer_ invalidate]; | |
| 502 hideTimer_.reset([[NSTimer | |
| 503 scheduledTimerWithTimeInterval:kDropdownForTabStripChangesDuration | |
| 504 target:self | |
| 505 selector:@selector(hideTimerFire:) | |
| 506 userInfo:nil | |
| 507 repeats:NO] retain]); | |
| 508 } else { | |
| 509 revealToolbarForTabStripChanges_ = false; | |
|
Robert Sesek
2016/06/23 14:08:24
false -> NO
spqchan
2016/06/23 19:41:52
Done.
| |
| 510 } | |
| 511 } | |
| 485 } | 512 } |
| 486 | 513 |
| 487 - (void)animationDidEnd:(NSAnimation*)animation { | 514 - (void)animationDidEnd:(NSAnimation*)animation { |
| 488 [self animationDidStop:animation]; | 515 [self animationDidStop:animation]; |
| 489 | 516 |
| 490 // |trackingAreaBounds_| contains the correct tracking area bounds, including | 517 // |trackingAreaBounds_| contains the correct tracking area bounds, including |
| 491 // |any updates that may have come while the animation was running. Install a | 518 // |any updates that may have come while the animation was running. Install a |
| 492 // new tracking area with these bounds. | 519 // new tracking area with these bounds. |
| 493 [self setupTrackingArea]; | 520 [self setupTrackingArea]; |
| 494 | 521 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 [self updateMenuBarAndDockVisibility]; | 779 [self updateMenuBarAndDockVisibility]; |
| 753 | 780 |
| 754 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 | 781 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 |
| 755 } | 782 } |
| 756 | 783 |
| 757 - (BOOL)shouldShowMenubarInImmersiveFullscreen { | 784 - (BOOL)shouldShowMenubarInImmersiveFullscreen { |
| 758 return [self doesScreenHaveMenuBar] && toolbarFraction_ > 0.99; | 785 return [self doesScreenHaveMenuBar] && toolbarFraction_ > 0.99; |
| 759 } | 786 } |
| 760 | 787 |
| 761 @end | 788 @end |
| OLD | NEW |