| 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/fullscreen_toolbar_controller.h" | 5 #import "chrome/browser/ui/cocoa/fullscreen_toolbar_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" |
| 11 #include "base/mac/sdk_forward_declarations.h" | 11 #include "base/mac/sdk_forward_declarations.h" |
| 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 12 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 13 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_menubar_tracker.h" | 13 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_menubar_tracker.h" |
| 14 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_animation_control
ler.h" | 14 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_animation_control
ler.h" |
| 15 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_mouse_tracker.h" | 15 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_mouse_tracker.h" |
| 16 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_visibility_lock_c
ontroller.h" |
| 16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 17 #include "ui/base/cocoa/appkit_utils.h" | 18 #include "ui/base/cocoa/appkit_utils.h" |
| 18 #import "ui/base/cocoa/nsview_additions.h" | 19 #import "ui/base/cocoa/nsview_additions.h" |
| 19 #import "ui/base/cocoa/tracking_area.h" | 20 #import "ui/base/cocoa/tracking_area.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // Visibility fractions for the menubar and toolbar. | 24 // Visibility fractions for the menubar and toolbar. |
| 24 const CGFloat kHideFraction = 0.0; | 25 const CGFloat kHideFraction = 0.0; |
| 25 const CGFloat kShowFraction = 1.0; | 26 const CGFloat kShowFraction = 1.0; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 61 |
| 61 @synthesize slidingStyle = slidingStyle_; | 62 @synthesize slidingStyle = slidingStyle_; |
| 62 | 63 |
| 63 - (id)initWithBrowserController:(BrowserWindowController*)controller | 64 - (id)initWithBrowserController:(BrowserWindowController*)controller |
| 64 style:(FullscreenSlidingStyle)style { | 65 style:(FullscreenSlidingStyle)style { |
| 65 if ((self = [super init])) { | 66 if ((self = [super init])) { |
| 66 browserController_ = controller; | 67 browserController_ = controller; |
| 67 systemFullscreenMode_ = base::mac::kFullScreenModeNormal; | 68 systemFullscreenMode_ = base::mac::kFullScreenModeNormal; |
| 68 slidingStyle_ = style; | 69 slidingStyle_ = style; |
| 69 animationController_.reset(new FullscreenToolbarAnimationController(self)); | 70 animationController_.reset(new FullscreenToolbarAnimationController(self)); |
| 71 visibilityLockController_.reset( |
| 72 [[FullscreenToolbarVisibilityLockController alloc] |
| 73 initWithFullscreenToolbarController:self |
| 74 animationController:animationController_.get()]); |
| 70 } | 75 } |
| 71 | 76 |
| 72 return self; | 77 return self; |
| 73 } | 78 } |
| 74 | 79 |
| 75 - (void)dealloc { | 80 - (void)dealloc { |
| 76 DCHECK(!inFullscreenMode_); | 81 DCHECK(!inFullscreenMode_); |
| 77 [super dealloc]; | 82 [super dealloc]; |
| 78 } | 83 } |
| 79 | 84 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 125 } |
| 121 | 126 |
| 122 - (void)windowDidBecomeMain:(NSNotification*)notification { | 127 - (void)windowDidBecomeMain:(NSNotification*)notification { |
| 123 [self updateMenuBarAndDockVisibility]; | 128 [self updateMenuBarAndDockVisibility]; |
| 124 } | 129 } |
| 125 | 130 |
| 126 - (void)windowDidResignMain:(NSNotification*)notification { | 131 - (void)windowDidResignMain:(NSNotification*)notification { |
| 127 [self updateMenuBarAndDockVisibility]; | 132 [self updateMenuBarAndDockVisibility]; |
| 128 } | 133 } |
| 129 | 134 |
| 130 - (void)ensureOverlayShownWithAnimation:(BOOL)animate { | |
| 131 animationController_->AnimateToolbarIn(); | |
| 132 } | |
| 133 | |
| 134 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate { | |
| 135 animationController_->AnimateToolbarOutIfPossible(); | |
| 136 } | |
| 137 | |
| 138 // Cancels any running animation and timers. | 135 // Cancels any running animation and timers. |
| 139 - (void)cancelAnimationAndTimer { | 136 - (void)cancelAnimationAndTimer { |
| 140 animationController_->StopAnimationAndTimer(); | 137 animationController_->StopAnimationAndTimer(); |
| 141 } | 138 } |
| 142 | 139 |
| 143 - (void)revealToolbarForTabStripChanges { | 140 - (void)revealToolbarForTabStripChanges { |
| 144 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 141 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 145 switches::kEnableFullscreenToolbarReveal)) { | 142 switches::kEnableFullscreenToolbarReveal)) { |
| 146 return; | 143 return; |
| 147 } | 144 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 169 // In AppKit fullscreen, moving the mouse to the top of the screen toggles | 166 // In AppKit fullscreen, moving the mouse to the top of the screen toggles |
| 170 // menu visibility. Replicate the same effect for immersive fullscreen. | 167 // menu visibility. Replicate the same effect for immersive fullscreen. |
| 171 if ([browserController_ isInImmersiveFullscreen]) | 168 if ([browserController_ isInImmersiveFullscreen]) |
| 172 [self updateMenuBarAndDockVisibility]; | 169 [self updateMenuBarAndDockVisibility]; |
| 173 } | 170 } |
| 174 | 171 |
| 175 - (BrowserWindowController*)browserWindowController { | 172 - (BrowserWindowController*)browserWindowController { |
| 176 return browserController_; | 173 return browserController_; |
| 177 } | 174 } |
| 178 | 175 |
| 176 - (FullscreenToolbarVisibilityLockController*)visibilityLockController { |
| 177 return visibilityLockController_.get(); |
| 178 } |
| 179 |
| 179 // This method works, but is fragile. | 180 // This method works, but is fragile. |
| 180 // | 181 // |
| 181 // It gets used during view layout, which sometimes needs to be done at the | 182 // It gets used during view layout, which sometimes needs to be done at the |
| 182 // beginning of an animation. As such, this method needs to reflect the | 183 // beginning of an animation. As such, this method needs to reflect the |
| 183 // menubarOffset expected at the end of the animation. This information is not | 184 // menubarOffset expected at the end of the animation. This information is not |
| 184 // readily available. (The layout logic needs a refactor). | 185 // readily available. (The layout logic needs a refactor). |
| 185 // | 186 // |
| 186 // For AppKit Fullscreen, the menubar always starts hidden, and | 187 // For AppKit Fullscreen, the menubar always starts hidden, and |
| 187 // menubarFraction_ always starts at 0, so the logic happens to work. For | 188 // menubarFraction_ always starts at 0, so the logic happens to work. For |
| 188 // Immersive Fullscreen, this class controls the visibility of the menu bar, so | 189 // Immersive Fullscreen, this class controls the visibility of the menu bar, so |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 224 |
| 224 if (slidingStyle_ == FullscreenSlidingStyle::OMNIBOX_TABS_PRESENT) | 225 if (slidingStyle_ == FullscreenSlidingStyle::OMNIBOX_TABS_PRESENT) |
| 225 return YES; | 226 return YES; |
| 226 | 227 |
| 227 if (slidingStyle_ == FullscreenSlidingStyle::OMNIBOX_TABS_NONE) | 228 if (slidingStyle_ == FullscreenSlidingStyle::OMNIBOX_TABS_NONE) |
| 228 return NO; | 229 return NO; |
| 229 | 230 |
| 230 FullscreenMenubarState menubarState = [menubarTracker_ state]; | 231 FullscreenMenubarState menubarState = [menubarTracker_ state]; |
| 231 return menubarState == FullscreenMenubarState::SHOWN || | 232 return menubarState == FullscreenMenubarState::SHOWN || |
| 232 [mouseTracker_ mouseInsideTrackingArea] || | 233 [mouseTracker_ mouseInsideTrackingArea] || |
| 233 [browserController_ isBarVisibilityLockedForOwner:nil]; | 234 [visibilityLockController_ isToolbarVisibilityLocked]; |
| 234 } | 235 } |
| 235 | 236 |
| 236 - (BOOL)isFullscreenTransitionInProgress { | 237 - (BOOL)isFullscreenTransitionInProgress { |
| 237 return [browserController_ isFullscreenTransitionInProgress]; | 238 return [browserController_ isFullscreenTransitionInProgress]; |
| 238 } | 239 } |
| 239 | 240 |
| 240 - (BOOL)isInFullscreen { | 241 - (BOOL)isInFullscreen { |
| 241 return inFullscreenMode_; | 242 return inFullscreenMode_; |
| 242 } | 243 } |
| 243 | 244 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 307 |
| 307 // No more calls back up to the BWC. | 308 // No more calls back up to the BWC. |
| 308 browserController_ = nil; | 309 browserController_ = nil; |
| 309 } | 310 } |
| 310 | 311 |
| 311 - (BOOL)shouldShowMenubarInImmersiveFullscreen { | 312 - (BOOL)shouldShowMenubarInImmersiveFullscreen { |
| 312 return [self doesScreenHaveMenuBar] && [self toolbarFraction] > 0.99; | 313 return [self doesScreenHaveMenuBar] && [self toolbarFraction] > 0.99; |
| 313 } | 314 } |
| 314 | 315 |
| 315 @end | 316 @end |
| OLD | NEW |