| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/fullscreen_toolbar_controller.h" | 5 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 10 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_menubar_tracker.h" | 10 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_menubar_tracker.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 - (void)dealloc { | 41 - (void)dealloc { |
| 42 DCHECK(!inFullscreenMode_); | 42 DCHECK(!inFullscreenMode_); |
| 43 [super dealloc]; | 43 [super dealloc]; |
| 44 } | 44 } |
| 45 | 45 |
| 46 - (void)enterFullscreenMode { | 46 - (void)enterFullscreenMode { |
| 47 DCHECK(!inFullscreenMode_); | 47 DCHECK(!inFullscreenMode_); |
| 48 inFullscreenMode_ = YES; | 48 inFullscreenMode_ = YES; |
| 49 | 49 |
| 50 // If the location bar is the first responder, don't let the toolbar hide. |
| 51 // This is a special signal to -mustShowFullscreenToolbar that the toolbar |
| 52 // should remain visible during the transition to fullscreen. |
| 53 if ([browserController_ locationBarHasFocus]) { |
| 54 [visibilityLockController_ lockToolbarVisibilityForOwner:self |
| 55 withAnimation:NO]; |
| 56 } |
| 57 |
| 50 [self updateToolbarStyleExitingTabFullscreen:NO]; | 58 [self updateToolbarStyleExitingTabFullscreen:NO]; |
| 51 | 59 |
| 52 if ([browserController_ isInImmersiveFullscreen]) { | 60 if ([browserController_ isInImmersiveFullscreen]) { |
| 53 immersiveFullscreenController_.reset([[ImmersiveFullscreenController alloc] | 61 immersiveFullscreenController_.reset([[ImmersiveFullscreenController alloc] |
| 54 initWithBrowserController:browserController_]); | 62 initWithBrowserController:browserController_]); |
| 55 [immersiveFullscreenController_ updateMenuBarAndDockVisibility]; | 63 [immersiveFullscreenController_ updateMenuBarAndDockVisibility]; |
| 56 } else { | 64 } else { |
| 57 menubarTracker_.reset([[FullscreenMenubarTracker alloc] | 65 menubarTracker_.reset([[FullscreenMenubarTracker alloc] |
| 58 initWithFullscreenToolbarController:self]); | 66 initWithFullscreenToolbarController:self]); |
| 59 mouseTracker_.reset([[FullscreenToolbarMouseTracker alloc] | 67 mouseTracker_.reset([[FullscreenToolbarMouseTracker alloc] |
| 60 initWithFullscreenToolbarController:self | 68 initWithFullscreenToolbarController:self |
| 61 animationController:animationController_.get()]); | 69 animationController:animationController_.get()]); |
| 62 } | 70 } |
| 71 |
| 72 // Let the location bar keep the toolbar locked in place from here on out |
| 73 // (if it's the first responder). |
| 74 [visibilityLockController_ releaseToolbarVisibilityForOwner:self |
| 75 withAnimation:YES]; |
| 63 } | 76 } |
| 64 | 77 |
| 65 - (void)exitFullscreenMode { | 78 - (void)exitFullscreenMode { |
| 66 DCHECK(inFullscreenMode_); | 79 DCHECK(inFullscreenMode_); |
| 67 inFullscreenMode_ = NO; | 80 inFullscreenMode_ = NO; |
| 68 | 81 |
| 69 animationController_->StopAnimationAndTimer(); | 82 animationController_->StopAnimationAndTimer(); |
| 70 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 83 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 71 | 84 |
| 72 menubarTracker_.reset(); | 85 menubarTracker_.reset(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 138 } |
| 126 layout.menubarOffset *= -[browserController_ menubarHeight]; | 139 layout.menubarOffset *= -[browserController_ menubarHeight]; |
| 127 | 140 |
| 128 return layout; | 141 return layout; |
| 129 } | 142 } |
| 130 | 143 |
| 131 - (BOOL)mustShowFullscreenToolbar { | 144 - (BOOL)mustShowFullscreenToolbar { |
| 132 if (!inFullscreenMode_) | 145 if (!inFullscreenMode_) |
| 133 return NO; | 146 return NO; |
| 134 | 147 |
| 148 // Check if the fullscreen toolbar controller wants the toolbar to remain |
| 149 // visible. |
| 150 if ([visibilityLockController_ isToolbarVisibilityLockedForOwner:self]) { |
| 151 return YES; |
| 152 } |
| 153 |
| 135 if (toolbarStyle_ == FullscreenToolbarStyle::TOOLBAR_PRESENT) | 154 if (toolbarStyle_ == FullscreenToolbarStyle::TOOLBAR_PRESENT) |
| 136 return YES; | 155 return YES; |
| 137 | 156 |
| 138 if (toolbarStyle_ == FullscreenToolbarStyle::TOOLBAR_NONE) | 157 if (toolbarStyle_ == FullscreenToolbarStyle::TOOLBAR_NONE) |
| 139 return NO; | 158 return NO; |
| 140 | 159 |
| 141 FullscreenMenubarState menubarState = [menubarTracker_ state]; | 160 FullscreenMenubarState menubarState = [menubarTracker_ state]; |
| 142 return menubarState == FullscreenMenubarState::SHOWN || | 161 return menubarState == FullscreenMenubarState::SHOWN || |
| 143 [mouseTracker_ mouseInsideTrackingArea] || | 162 [mouseTracker_ mouseInsideTrackingArea] || |
| 144 [visibilityLockController_ isToolbarVisibilityLocked]; | 163 [visibilityLockController_ isToolbarVisibilityLocked]; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 221 |
| 203 - (void)setToolbarStyle:(FullscreenToolbarStyle)style { | 222 - (void)setToolbarStyle:(FullscreenToolbarStyle)style { |
| 204 toolbarStyle_ = style; | 223 toolbarStyle_ = style; |
| 205 } | 224 } |
| 206 | 225 |
| 207 - (void)setTestFullscreenMode:(BOOL)isInFullscreen { | 226 - (void)setTestFullscreenMode:(BOOL)isInFullscreen { |
| 208 inFullscreenMode_ = isInFullscreen; | 227 inFullscreenMode_ = isInFullscreen; |
| 209 } | 228 } |
| 210 | 229 |
| 211 @end | 230 @end |
| OLD | NEW |