Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_FULLSCREEN_FULLSCREEN_TOOLBAR_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_FULLSCREEN_FULLSCREEN_TOOLBAR_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <Carbon/Carbon.h> | |
| 9 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 10 | 9 |
| 11 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| 12 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 11 #include "base/mac/scoped_nsobject.h" |
| 13 | 12 |
| 14 @class BrowserWindowController; | 13 @class BrowserWindowController; |
| 15 @class FullscreenMenubarTracker; | 14 @class FullscreenMenubarTracker; |
| 16 class FullscreenToolbarAnimationController; | 15 class FullscreenToolbarAnimationController; |
| 17 @class FullscreenToolbarMouseTracker; | 16 @class FullscreenToolbarMouseTracker; |
| 18 @class FullscreenToolbarVisibilityLockController; | 17 @class FullscreenToolbarVisibilityLockController; |
| 19 @class ImmersiveFullscreenController; | 18 @class ImmersiveFullscreenController; |
| 20 | 19 |
| 21 // This enum class represents the appearance of the fullscreen toolbar, which | 20 // This enum class represents the appearance of the fullscreen toolbar, which |
| 22 // includes the tab strip and omnibox. | 21 // includes the tab strip and omnibox. |
| 23 enum class FullscreenToolbarStyle { | 22 enum class FullscreenToolbarStyle { |
| 24 // The toolbar is present. Moving the cursor to the top | 23 // The toolbar is present. Moving the cursor to the top |
| 25 // causes the menubar to appear and the toolbar to slide down. | 24 // causes the menubar to appear and the toolbar to slide down. |
| 26 TOOLBAR_PRESENT, | 25 TOOLBAR_PRESENT, |
| 27 // The toolbar is hidden. Moving cursor to top shows the | 26 // The toolbar is hidden. Moving cursor to top shows the |
| 28 // toolbar and menubar. | 27 // toolbar and menubar. |
| 29 TOOLBAR_HIDDEN, | 28 TOOLBAR_HIDDEN, |
| 30 // Toolbar is hidden. Moving cursor to top causes the menubar | 29 // Toolbar is hidden. Moving cursor to top causes the menubar |
| 31 // to appear, but not the toolbar. | 30 // to appear, but not the toolbar. |
| 32 TOOLBAR_NONE, | 31 TOOLBAR_NONE, |
| 33 }; | 32 }; |
| 34 | 33 |
| 35 // Provides a controller to fullscreen toolbar for a single browser | 34 // This struct contains the calculated values of the fullscreen toolbar layout. |
| 36 // window. This class handles running animations, showing and hiding the | 35 struct FullscreenToolbarLayout { |
|
erikchen
2016/11/16 18:52:35
Nice.
| |
| 37 // fullscreen toolbar, and managing the tracking area associated with the | 36 // The toolbar style. |
| 38 // toolbar. This class does not directly manage any views -- the | 37 FullscreenToolbarStyle toolbarStyle; |
| 39 // BrowserWindowController is responsible for positioning and z-ordering views. | 38 |
| 40 // | 39 // The fraction of the toolbar that is shown in the screen. |
| 40 CGFloat toolbarFraction; | |
| 41 | |
| 42 // The amount the menuber should be offset from the top of the screen. | |
| 43 CGFloat menubarOffset; | |
| 44 }; | |
| 45 | |
| 46 // Provides a controller to the fullscreen toolbar for a single browser | |
| 47 // window. This class sets up the animation manager, visibility locks, menubar | |
| 48 // tracking, and mouse tracking associated with the toolbar. It receives input | |
| 49 // from these objects to update and recompute the fullscreen toolbar laytout. | |
| 41 | 50 |
| 42 // TODO (spqchan): Write tests for this class. See crbug.com/640064. | 51 // TODO (spqchan): Write tests for this class. See crbug.com/640064. |
| 43 @interface FullscreenToolbarController : NSObject { | 52 @interface FullscreenToolbarController : NSObject { |
| 44 @private | 53 @private |
| 45 // Our parent controller. | 54 // Our parent controller. |
| 46 BrowserWindowController* browserController_; // weak | 55 BrowserWindowController* browserController_; // weak |
| 47 | 56 |
| 48 // Whether or not we are in fullscreen mode. | 57 // Whether or not we are in fullscreen mode. |
| 49 BOOL inFullscreenMode_; | 58 BOOL inFullscreenMode_; |
| 50 | 59 |
| 51 // Updates the fullscreen toolbar layout for changes in the menubar. This | 60 // Updates the fullscreen toolbar layout for changes in the menubar. This |
| 52 // object is only set when the browser is in fullscreen mode. | 61 // object is only set when the browser is in fullscreen mode. |
| 53 base::scoped_nsobject<FullscreenMenubarTracker> menubarTracker_; | 62 base::scoped_nsobject<FullscreenMenubarTracker> menubarTracker_; |
| 54 | 63 |
| 55 // Maintains the toolbar's visibility locks for the TOOLBAR_HIDDEN style. | 64 // Maintains the toolbar's visibility locks for the TOOLBAR_HIDDEN style. |
| 56 base::scoped_nsobject<FullscreenToolbarVisibilityLockController> | 65 base::scoped_nsobject<FullscreenToolbarVisibilityLockController> |
| 57 visibilityLockController_; | 66 visibilityLockController_; |
| 58 | 67 |
| 59 // Manages the toolbar animations for the TOOLBAR_HIDDEN style. | 68 // Manages the toolbar animations for the TOOLBAR_HIDDEN style. |
| 60 std::unique_ptr<FullscreenToolbarAnimationController> animationController_; | 69 std::unique_ptr<FullscreenToolbarAnimationController> animationController_; |
| 61 | 70 |
| 62 // Mouse tracker to track the user's interactions with the toolbar. This | 71 // Mouse tracker to track the user's interactions with the toolbar. This |
| 63 // object is only set when the browser is in fullscreen mode. | 72 // object is only set when the browser is in fullscreen mode. |
| 64 base::scoped_nsobject<FullscreenToolbarMouseTracker> mouseTracker_; | 73 base::scoped_nsobject<FullscreenToolbarMouseTracker> mouseTracker_; |
| 65 | 74 |
| 66 // Controller for immersive fullscreen. | 75 // Controller for immersive fullscreen. |
| 67 base::scoped_nsobject<ImmersiveFullscreenController> | 76 base::scoped_nsobject<ImmersiveFullscreenController> |
| 68 immersiveFullscreenController_; | 77 immersiveFullscreenController_; |
| 78 | |
| 79 // The style of the fullscreen toolbar. | |
| 80 FullscreenToolbarStyle toolbarStyle_; | |
| 69 } | 81 } |
| 70 | 82 |
| 71 @property(nonatomic, assign) FullscreenToolbarStyle toolbarStyle; | |
| 72 | |
| 73 // Designated initializer. | 83 // Designated initializer. |
| 74 - (id)initWithBrowserController:(BrowserWindowController*)controller; | 84 - (id)initWithBrowserController:(BrowserWindowController*)controller; |
| 75 | 85 |
| 76 // Informs the controller that the browser has entered or exited fullscreen | 86 // Informs the controller that the browser has entered or exited fullscreen |
| 77 // mode. |-enterFullscreenMode| should be called when the window is about to | 87 // mode. |-enterFullscreenMode| should be called when the window is about to |
| 78 // enter fullscreen. |-exitFullscreenMode| should be called before any views | 88 // enter fullscreen. |-exitFullscreenMode| should be called before any views |
| 79 // are moved back to the non-fullscreen window. | 89 // are moved back to the non-fullscreen window. |
| 80 - (void)enterFullscreenMode; | 90 - (void)enterFullscreenMode; |
| 81 - (void)exitFullscreenMode; | 91 - (void)exitFullscreenMode; |
| 82 | 92 |
| 83 // Cancels any running animation and timers. | 93 // Cancels any running animation and timers. |
| 84 - (void)cancelAnimationAndTimer; | 94 - (void)cancelAnimationAndTimer; |
| 85 | 95 |
| 86 // Animates the toolbar dropping down to show changes to the tab strip. | 96 // Animates the toolbar dropping down to show changes to the tab strip. |
| 87 - (void)revealToolbarForTabStripChanges; | 97 - (void)revealToolbarForTabStripChanges; |
| 88 | 98 |
| 89 // In any fullscreen mode, the y offset to use for the content at the top of | |
| 90 // the screen (tab strip, omnibox, bookmark bar, etc). | |
| 91 // Ranges from 0 to -22. | |
| 92 - (CGFloat)menubarOffset; | |
| 93 | |
| 94 // Returns the fraction of the toolbar exposed at the top. | 99 // Returns the fraction of the toolbar exposed at the top. |
| 95 // It returns 1.0 if the toolbar is fully shown and 0.0 if the toolbar is | 100 // It returns 1.0 if the toolbar is fully shown and 0.0 if the toolbar is |
| 96 // hidden. Otherwise, if the toolbar is in progress of animating, it will | 101 // hidden. Otherwise, if the toolbar is in progress of animating, it will |
| 97 // return a float that ranges from (0, 1). | 102 // return a float that ranges from (0, 1). |
| 98 - (CGFloat)toolbarFraction; | 103 - (CGFloat)toolbarFraction; |
| 99 | 104 |
| 105 // Computes and return the layout for the fullscreen toolbar. | |
| 106 - (FullscreenToolbarLayout)computeLayout; | |
| 107 | |
| 100 // Returns YES if the fullscreen toolbar must be shown. | 108 // Returns YES if the fullscreen toolbar must be shown. |
| 101 - (BOOL)mustShowFullscreenToolbar; | 109 - (BOOL)mustShowFullscreenToolbar; |
| 102 | 110 |
| 103 // Called by the BrowserWindowController to update toolbar frame. | 111 // Called by the BrowserWindowController to update toolbar frame. |
| 104 - (void)updateToolbarFrame:(NSRect)frame; | 112 - (void)updateToolbarFrame:(NSRect)frame; |
| 105 | 113 |
| 106 // Returns YES if the browser in in fullscreen. | |
| 107 - (BOOL)isInFullscreen; | |
| 108 | |
| 109 // Updates the toolbar style. If the style has changed, then the toolbar will | 114 // Updates the toolbar style. If the style has changed, then the toolbar will |
| 110 // relayout. | 115 // relayout. |
| 111 - (void)updateToolbarStyleExitingTabFullscreen:(BOOL)isExitingTabFullscreen; | 116 - (void)updateToolbarStyleExitingTabFullscreen:(BOOL)isExitingTabFullscreen; |
| 112 | 117 |
| 113 // Updates the toolbar by updating the layout, menubar and dock. | 118 // Updates the toolbar by updating the layout. |
| 114 - (void)updateToolbar; | 119 - (void)updateToolbarLayout; |
| 120 | |
| 121 // Returns YES if the browser in in fullscreen. | |
| 122 - (BOOL)isInFullscreen; | |
| 115 | 123 |
| 116 // Returns |browserController_|. | 124 // Returns |browserController_|. |
| 117 - (BrowserWindowController*)browserWindowController; | 125 - (BrowserWindowController*)browserWindowController; |
| 118 | 126 |
| 119 // Returns the object in |visibilityLockController_|; | 127 // Returns the object in |visibilityLockController_|; |
| 120 - (FullscreenToolbarVisibilityLockController*)visibilityLockController; | 128 - (FullscreenToolbarVisibilityLockController*)visibilityLockController; |
| 121 | 129 |
| 122 @end | 130 @end |
| 123 | 131 |
| 124 // Private methods exposed for testing. | 132 // Private methods exposed for testing. |
| 125 @interface FullscreenToolbarController (ExposedForTesting) | 133 @interface FullscreenToolbarController (ExposedForTesting) |
| 126 // Adjusts the AppKit Fullscreen options of the application. | 134 // Adjusts the AppKit Fullscreen options of the application. |
| 127 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; | 135 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; |
| 128 | 136 |
| 129 // Callback for menu bar animations. | 137 // Callback for menu bar animations. |
| 130 - (void)setMenuBarRevealProgress:(CGFloat)progress; | 138 - (void)setMenuBarRevealProgress:(CGFloat)progress; |
| 131 | 139 |
| 132 @end | 140 @end |
| 133 | 141 |
| 134 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ | 142 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_FULLSCREEN_TOOLBAR_CONTROLLER_H_ |
| OLD | NEW |