Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/browser/ui/cocoa/presentation_mode_controller.mm

Issue 2086273003: [Mac] Reveal Fullscreen Toolbar for Tab Strip Changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scoped_nsobject Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 23
24 // The activation zone for the main menu is 4 pixels high; if we make it any 24 // 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. 25 // smaller, then the menu can be made to appear without the bar sliding down.
26 const CGFloat kDropdownActivationZoneHeight = 4; 26 const CGFloat kDropdownActivationZoneHeight = 4;
27 const NSTimeInterval kDropdownAnimationDuration = 0.12; 27 const NSTimeInterval kDropdownAnimationDuration = 0.12;
28 const NSTimeInterval kMouseExitCheckDelay = 0.1; 28 const NSTimeInterval kMouseExitCheckDelay = 0.1;
29 // This show delay attempts to match the delay for the main menu. 29 // This show delay attempts to match the delay for the main menu.
30 const NSTimeInterval kDropdownShowDelay = 0.3; 30 const NSTimeInterval kDropdownShowDelay = 0.3;
31 const NSTimeInterval kDropdownHideDelay = 0.2; 31 const NSTimeInterval kDropdownHideDelay = 0.2;
32 32
33 // The duration the toolbar is revealed for tab strip changes.
34 const NSTimeInterval kDropdownForTabStripChangesDuration = 0.75;
35
33 // The event kind value for a undocumented menubar show/hide Carbon event. 36 // The event kind value for a undocumented menubar show/hide Carbon event.
34 const CGFloat kMenuBarRevealEventKind = 2004; 37 const CGFloat kMenuBarRevealEventKind = 2004;
35 38
36 // The amount by which the floating bar is offset downwards (to avoid the menu) 39 // The amount by which the floating bar is offset downwards (to avoid the menu)
37 // in presentation mode. (We can't use |-[NSMenu menuBarHeight]| since it 40 // in presentation mode. (We can't use |-[NSMenu menuBarHeight]| since it
38 // returns 0 when the menu bar is hidden.) 41 // returns 0 when the menu bar is hidden.)
39 const CGFloat kFloatingBarVerticalOffset = 22; 42 const CGFloat kFloatingBarVerticalOffset = 22;
40 43
41 OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, 44 OSStatus MenuBarRevealHandler(EventHandlerCallRef handler,
42 EventRef event, 45 EventRef event,
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 [self changeOverlayToFraction:0 withAnimation:NO]; 379 [self changeOverlayToFraction:0 withAnimation:NO];
377 } 380 }
378 } 381 }
379 382
380 - (void)cancelAnimationAndTimers { 383 - (void)cancelAnimationAndTimers {
381 [self cancelAllTimers]; 384 [self cancelAllTimers];
382 [currentAnimation_ stopAnimation]; 385 [currentAnimation_ stopAnimation];
383 currentAnimation_.reset(); 386 currentAnimation_.reset();
384 } 387 }
385 388
389 - (void)revealToolbarForTabStripChanges {
390 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
391 switches::kEnableFullscreenToolbarReveal)) {
392 return;
393 }
394
395 revealToolbarForTabStripChanges_ = YES;
396 [self ensureOverlayShownWithAnimation:YES delay:NO];
397 }
398
386 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode { 399 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode {
387 if (mode == systemFullscreenMode_) 400 if (mode == systemFullscreenMode_)
388 return; 401 return;
389 if (systemFullscreenMode_ == base::mac::kFullScreenModeNormal) 402 if (systemFullscreenMode_ == base::mac::kFullScreenModeNormal)
390 base::mac::RequestFullScreen(mode); 403 base::mac::RequestFullScreen(mode);
391 else if (mode == base::mac::kFullScreenModeNormal) 404 else if (mode == base::mac::kFullScreenModeNormal)
392 base::mac::ReleaseFullScreen(systemFullscreenMode_); 405 base::mac::ReleaseFullScreen(systemFullscreenMode_);
393 else 406 else
394 base::mac::SwitchFullScreenModes(systemFullscreenMode_, mode); 407 base::mac::SwitchFullScreenModes(systemFullscreenMode_, mode);
395 systemFullscreenMode_ = mode; 408 systemFullscreenMode_ = mode;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 currentAnimation_.reset(); 491 currentAnimation_.reset();
479 492
480 // Invariant says that the tracking area is not installed while animations are 493 // Invariant says that the tracking area is not installed while animations are
481 // in progress. Ensure this is true. 494 // in progress. Ensure this is true.
482 DCHECK(!trackingArea_); 495 DCHECK(!trackingArea_);
483 [self removeTrackingAreaIfNecessary]; // For paranoia. 496 [self removeTrackingAreaIfNecessary]; // For paranoia.
484 497
485 // Don't automatically set up a new tracking area. When explicitly stopped, 498 // Don't automatically set up a new tracking area. When explicitly stopped,
486 // either another animation is going to start immediately or the state will be 499 // either another animation is going to start immediately or the state will be
487 // changed immediately. 500 // changed immediately.
501 if (revealToolbarForTabStripChanges_) {
502 if (toolbarFraction_ > 0.0) {
503 // Set the timer to hide the toolbar.
504 [hideTimer_ invalidate];
505 hideTimer_.reset([[NSTimer
506 scheduledTimerWithTimeInterval:kDropdownForTabStripChangesDuration
507 target:self
508 selector:@selector(hideTimerFire:)
509 userInfo:nil
510 repeats:NO] retain]);
511 } else {
512 revealToolbarForTabStripChanges_ = NO;
513 }
514 }
488 } 515 }
489 516
490 - (void)animationDidEnd:(NSAnimation*)animation { 517 - (void)animationDidEnd:(NSAnimation*)animation {
491 [self animationDidStop:animation]; 518 [self animationDidStop:animation];
492 519
493 // |trackingAreaBounds_| contains the correct tracking area bounds, including 520 // |trackingAreaBounds_| contains the correct tracking area bounds, including
494 // |any updates that may have come while the animation was running. Install a 521 // |any updates that may have come while the animation was running. Install a
495 // new tracking area with these bounds. 522 // new tracking area with these bounds.
496 [self setupTrackingArea]; 523 [self setupTrackingArea];
497 524
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 [self updateMenuBarAndDockVisibility]; 782 [self updateMenuBarAndDockVisibility];
756 783
757 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 784 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956
758 } 785 }
759 786
760 - (BOOL)shouldShowMenubarInImmersiveFullscreen { 787 - (BOOL)shouldShowMenubarInImmersiveFullscreen {
761 return [self doesScreenHaveMenuBar] && toolbarFraction_ > 0.99; 788 return [self doesScreenHaveMenuBar] && toolbarFraction_ > 0.99;
762 } 789 }
763 790
764 @end 791 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/presentation_mode_controller.h ('k') | chrome/browser/ui/cocoa/tabs/tab_strip_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698