| 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 #ifndef CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <Carbon/Carbon.h> | 8 #include <Carbon/Carbon.h> |
| 9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
| 10 | 10 |
| 11 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
| 12 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 12 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 13 | 13 |
| 14 @class BrowserWindowController; | 14 @class BrowserWindowController; |
| 15 @class FullscreenMenubarTracker; | 15 @class FullscreenMenubarTracker; |
| 16 class FullscreenToolbarAnimationController; | 16 class FullscreenToolbarAnimationController; |
| 17 @class FullscreenToolbarMouseTracker; | 17 @class FullscreenToolbarMouseTracker; |
| 18 @class FullscreenToolbarVisibilityLockController; | 18 @class FullscreenToolbarVisibilityLockController; |
| 19 | 19 |
| 20 enum class FullscreenSlidingStyle { | 20 // This enum class represents the appearance of the fullscreen toolbar, which |
| 21 OMNIBOX_TABS_PRESENT, // Tab strip and omnibox both visible. | 21 // includes the tab strip and omnibox. |
| 22 OMNIBOX_TABS_HIDDEN, // Tab strip and omnibox both hidden. | 22 enum class FullscreenToolbarStyle { |
| 23 OMNIBOX_TABS_NONE, // Tab strip and omnibox both hidden and never | 23 // The toolbar is present. Moving the cursor to the top |
| 24 // shown. | 24 // causes the menubar to appear and the toolbar to slide down. |
| 25 TOOLBAR_PRESENT, |
| 26 // The toolbar is hidden. Moving cursor to top shows the |
| 27 // toolbar and menubar. |
| 28 TOOLBAR_HIDDEN, |
| 29 // Toolbar is hidden. Moving cursor to top causes the menubar |
| 30 // to appear, but not the toolbar. |
| 31 TOOLBAR_NONE, |
| 25 }; | 32 }; |
| 26 | 33 |
| 27 // Provides a controller to fullscreen toolbar for a single browser | 34 // Provides a controller to fullscreen toolbar for a single browser |
| 28 // window. This class handles running animations, showing and hiding the | 35 // window. This class handles running animations, showing and hiding the |
| 29 // fullscreen toolbar, and managing the tracking area associated with the | 36 // fullscreen toolbar, and managing the tracking area associated with the |
| 30 // toolbar. This class does not directly manage any views -- the | 37 // toolbar. This class does not directly manage any views -- the |
| 31 // BrowserWindowController is responsible for positioning and z-ordering views. | 38 // BrowserWindowController is responsible for positioning and z-ordering views. |
| 32 // | 39 // |
| 33 | 40 |
| 34 // TODO (spqchan): Write tests for this class. See crbug.com/640064. | 41 // TODO (spqchan): Write tests for this class. See crbug.com/640064. |
| 35 @interface FullscreenToolbarController : NSObject { | 42 @interface FullscreenToolbarController : NSObject { |
| 36 @private | 43 @private |
| 37 // Our parent controller. | 44 // Our parent controller. |
| 38 BrowserWindowController* browserController_; // weak | 45 BrowserWindowController* browserController_; // weak |
| 39 | 46 |
| 40 // Whether or not we are in fullscreen mode. | 47 // Whether or not we are in fullscreen mode. |
| 41 BOOL inFullscreenMode_; | 48 BOOL inFullscreenMode_; |
| 42 | 49 |
| 43 // Updates the fullscreen toolbar layout for changes in the menubar. This | 50 // Updates the fullscreen toolbar layout for changes in the menubar. This |
| 44 // object is only set when the browser is in fullscreen mode. | 51 // object is only set when the browser is in fullscreen mode. |
| 45 base::scoped_nsobject<FullscreenMenubarTracker> menubarTracker_; | 52 base::scoped_nsobject<FullscreenMenubarTracker> menubarTracker_; |
| 46 | 53 |
| 47 // Maintains the toolbar's visibility locks for the | 54 // Maintains the toolbar's visibility locks for the TOOLBAR_HIDDEN style. |
| 48 // OMNIBOX_TABS_HIDDEN style. | |
| 49 base::scoped_nsobject<FullscreenToolbarVisibilityLockController> | 55 base::scoped_nsobject<FullscreenToolbarVisibilityLockController> |
| 50 visibilityLockController_; | 56 visibilityLockController_; |
| 51 | 57 |
| 52 // Manages the toolbar animations for the OMNIBOX_TABS_HIDDEN style. | 58 // Manages the toolbar animations for the TOOLBAR_HIDDEN style. |
| 53 std::unique_ptr<FullscreenToolbarAnimationController> animationController_; | 59 std::unique_ptr<FullscreenToolbarAnimationController> animationController_; |
| 54 | 60 |
| 55 // Mouse tracker to track the user's interactions with the toolbar. This | 61 // Mouse tracker to track the user's interactions with the toolbar. This |
| 56 // object is only set when the browser is in fullscreen mode. | 62 // object is only set when the browser is in fullscreen mode. |
| 57 base::scoped_nsobject<FullscreenToolbarMouseTracker> mouseTracker_; | 63 base::scoped_nsobject<FullscreenToolbarMouseTracker> mouseTracker_; |
| 58 | 64 |
| 59 // Tracks the currently requested system fullscreen mode, used to show or | 65 // Tracks the currently requested system fullscreen mode, used to show or |
| 60 // hide the menubar. This should be |kFullScreenModeNormal| when the window | 66 // hide the menubar. This should be |kFullScreenModeNormal| when the window |
| 61 // is not main or not fullscreen, |kFullScreenModeHideAll| while the overlay | 67 // is not main or not fullscreen, |kFullScreenModeHideAll| while the overlay |
| 62 // is hidden, and |kFullScreenModeHideDock| while the overlay is shown. If | 68 // is hidden, and |kFullScreenModeHideDock| while the overlay is shown. If |
| 63 // the window is not on the primary screen, this should always be | 69 // the window is not on the primary screen, this should always be |
| 64 // |kFullScreenModeNormal|. This value can get out of sync with the correct | 70 // |kFullScreenModeNormal|. This value can get out of sync with the correct |
| 65 // state if we miss a notification (which can happen when a window is closed). | 71 // state if we miss a notification (which can happen when a window is closed). |
| 66 // Used to track the current state and make sure we properly restore the menu | 72 // Used to track the current state and make sure we properly restore the menu |
| 67 // bar when this controller is destroyed. | 73 // bar when this controller is destroyed. |
| 68 base::mac::FullScreenMode systemFullscreenMode_; | 74 base::mac::FullScreenMode systemFullscreenMode_; |
| 69 | |
| 70 // Whether the omnibox is hidden in fullscreen. | |
| 71 FullscreenSlidingStyle slidingStyle_; | |
| 72 } | 75 } |
| 73 | 76 |
| 74 @property(nonatomic, assign) FullscreenSlidingStyle slidingStyle; | 77 @property(nonatomic, assign) FullscreenToolbarStyle toolbarStyle; |
| 75 | 78 |
| 76 // Designated initializer. | 79 // Designated initializer. |
| 77 - (id)initWithBrowserController:(BrowserWindowController*)controller | 80 - (id)initWithBrowserController:(BrowserWindowController*)controller; |
| 78 style:(FullscreenSlidingStyle)style; | |
| 79 | 81 |
| 80 // Informs the controller that the browser has entered or exited fullscreen | 82 // Informs the controller that the browser has entered or exited fullscreen |
| 81 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called | 83 // mode. |-enterFullscreenMode| should be called when the window is about to |
| 82 // after the window is setup, just before it is shown. |-exitFullscreenMode| | 84 // enter fullscreen. |-exitFullscreenMode| should be called before any views |
| 83 // should be called before any views are moved back to the non-fullscreen | 85 // are moved back to the non-fullscreen window. |
| 84 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called, | |
| 85 // it must be balanced with a call to |-exitFullscreenMode| before the | |
| 86 // controller is released. | |
| 87 - (void)enterFullscreenMode; | 86 - (void)enterFullscreenMode; |
| 88 - (void)exitFullscreenMode; | 87 - (void)exitFullscreenMode; |
| 89 | 88 |
| 90 // Cancels any running animation and timers. | 89 // Cancels any running animation and timers. |
| 91 - (void)cancelAnimationAndTimer; | 90 - (void)cancelAnimationAndTimer; |
| 92 | 91 |
| 93 // Animates the toolbar dropping down to show changes to the tab strip. | 92 // Animates the toolbar dropping down to show changes to the tab strip. |
| 94 - (void)revealToolbarForTabStripChanges; | 93 - (void)revealToolbarForTabStripChanges; |
| 95 | 94 |
| 96 // In any fullscreen mode, the y offset to use for the content at the top of | 95 // In any fullscreen mode, the y offset to use for the content at the top of |
| (...skipping 18 matching lines...) Expand all Loading... |
| 115 // Called by the BrowserWindowController to update toolbar frame. | 114 // Called by the BrowserWindowController to update toolbar frame. |
| 116 - (void)updateToolbarFrame:(NSRect)frame; | 115 - (void)updateToolbarFrame:(NSRect)frame; |
| 117 | 116 |
| 118 // Returns YES if the browser is in the process of entering/exiting | 117 // Returns YES if the browser is in the process of entering/exiting |
| 119 // fullscreen. | 118 // fullscreen. |
| 120 - (BOOL)isFullscreenTransitionInProgress; | 119 - (BOOL)isFullscreenTransitionInProgress; |
| 121 | 120 |
| 122 // Returns YES if the browser in in fullscreen. | 121 // Returns YES if the browser in in fullscreen. |
| 123 - (BOOL)isInFullscreen; | 122 - (BOOL)isInFullscreen; |
| 124 | 123 |
| 124 // Updates the toolbar style. If the style has changed, then the toolbar will |
| 125 // relayout. |
| 126 - (void)updateToolbarStyle; |
| 127 |
| 125 // Updates the toolbar by updating the layout, menubar and dock. | 128 // Updates the toolbar by updating the layout, menubar and dock. |
| 126 - (void)updateToolbar; | 129 - (void)updateToolbar; |
| 127 | 130 |
| 128 // Returns |browserController_|. | 131 // Returns |browserController_|. |
| 129 - (BrowserWindowController*)browserWindowController; | 132 - (BrowserWindowController*)browserWindowController; |
| 130 | 133 |
| 131 // Returns the object in |visibilityLockController_|; | 134 // Returns the object in |visibilityLockController_|; |
| 132 - (FullscreenToolbarVisibilityLockController*)visibilityLockController; | 135 - (FullscreenToolbarVisibilityLockController*)visibilityLockController; |
| 133 | 136 |
| 134 @end | 137 @end |
| 135 | 138 |
| 136 // Private methods exposed for testing. | 139 // Private methods exposed for testing. |
| 137 @interface FullscreenToolbarController (ExposedForTesting) | 140 @interface FullscreenToolbarController (ExposedForTesting) |
| 138 // Adjusts the AppKit Fullscreen options of the application. | 141 // Adjusts the AppKit Fullscreen options of the application. |
| 139 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; | 142 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; |
| 140 | 143 |
| 141 // Callback for menu bar animations. | 144 // Callback for menu bar animations. |
| 142 - (void)setMenuBarRevealProgress:(CGFloat)progress; | 145 - (void)setMenuBarRevealProgress:(CGFloat)progress; |
| 143 | 146 |
| 144 @end | 147 @end |
| 145 | 148 |
| 146 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ | 149 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ |
| OLD | NEW |