| 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 CrTrackingArea; | |
| 16 @class FullscreenMenubarTracker; | 15 @class FullscreenMenubarTracker; |
| 17 class FullscreenToolbarAnimationController; | 16 class FullscreenToolbarAnimationController; |
| 17 @class FullscreenToolbarMouseTracker; |
| 18 | 18 |
| 19 enum class FullscreenSlidingStyle { | 19 enum class FullscreenSlidingStyle { |
| 20 OMNIBOX_TABS_PRESENT, // Tab strip and omnibox both visible. | 20 OMNIBOX_TABS_PRESENT, // Tab strip and omnibox both visible. |
| 21 OMNIBOX_TABS_HIDDEN, // Tab strip and omnibox both hidden. | 21 OMNIBOX_TABS_HIDDEN, // Tab strip and omnibox both hidden. |
| 22 OMNIBOX_TABS_NONE, // Tab strip and omnibox both hidden and never | 22 OMNIBOX_TABS_NONE, // Tab strip and omnibox both hidden and never |
| 23 // shown. | 23 // shown. |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 // Provides a controller to fullscreen toolbar for a single browser | 26 // Provides a controller to fullscreen toolbar for a single browser |
| 27 // window. This class handles running animations, showing and hiding the | 27 // window. This class handles running animations, showing and hiding the |
| 28 // fullscreen toolbar, and managing the tracking area associated with the | 28 // fullscreen toolbar, and managing the tracking area associated with the |
| 29 // toolbar. This class does not directly manage any views -- the | 29 // toolbar. This class does not directly manage any views -- the |
| 30 // BrowserWindowController is responsible for positioning and z-ordering views. | 30 // BrowserWindowController is responsible for positioning and z-ordering views. |
| 31 // | 31 // |
| 32 | 32 |
| 33 // TODO (spqchan): Write tests for this class. See crbug.com/640064. | 33 // TODO (spqchan): Write tests for this class. See crbug.com/640064. |
| 34 @interface FullscreenToolbarController : NSObject { | 34 @interface FullscreenToolbarController : NSObject { |
| 35 @private | 35 @private |
| 36 // Our parent controller. | 36 // Our parent controller. |
| 37 BrowserWindowController* browserController_; // weak | 37 BrowserWindowController* browserController_; // weak |
| 38 | 38 |
| 39 // Whether or not we are in fullscreen mode. | 39 // Whether or not we are in fullscreen mode. |
| 40 BOOL inFullscreenMode_; | 40 BOOL inFullscreenMode_; |
| 41 | 41 |
| 42 // The content view for the window. This is nil when not in fullscreen mode. | |
| 43 NSView* contentView_; // weak | |
| 44 | |
| 45 // The frame for the tracking area. The value is the toolbar overlay's frame | |
| 46 // with additional height added at the bottom. | |
| 47 NSRect trackingAreaFrame_; | |
| 48 | |
| 49 // The tracking area associated with the toolbar overlay bar. This tracking | |
| 50 // area is used to keep the toolbar active if the menubar had animated out | |
| 51 // but the mouse is still on the toolbar. | |
| 52 base::scoped_nsobject<CrTrackingArea> trackingArea_; | |
| 53 | |
| 54 // Updates the fullscreen toolbar layout for changes in the menubar. This | 42 // Updates the fullscreen toolbar layout for changes in the menubar. This |
| 55 // object is only set when the browser is in fullscreen mode. | 43 // object is only set when the browser is in fullscreen mode. |
| 56 base::scoped_nsobject<FullscreenMenubarTracker> menubarTracker_; | 44 base::scoped_nsobject<FullscreenMenubarTracker> menubarTracker_; |
| 57 | 45 |
| 58 // Manages the toolbar animations for the OMNIBOX_TABS_HIDDEN style. | 46 // Manages the toolbar animations for the OMNIBOX_TABS_HIDDEN style. |
| 59 std::unique_ptr<FullscreenToolbarAnimationController> animationController_; | 47 std::unique_ptr<FullscreenToolbarAnimationController> animationController_; |
| 60 | 48 |
| 49 // Mouse tracker to track the user's interactions with the toolbar. This |
| 50 // object is only set when the browser is in fullscreen mode. |
| 51 base::scoped_nsobject<FullscreenToolbarMouseTracker> mouseTracker_; |
| 52 |
| 61 // Tracks the currently requested system fullscreen mode, used to show or | 53 // Tracks the currently requested system fullscreen mode, used to show or |
| 62 // hide the menubar. This should be |kFullScreenModeNormal| when the window | 54 // hide the menubar. This should be |kFullScreenModeNormal| when the window |
| 63 // is not main or not fullscreen, |kFullScreenModeHideAll| while the overlay | 55 // is not main or not fullscreen, |kFullScreenModeHideAll| while the overlay |
| 64 // is hidden, and |kFullScreenModeHideDock| while the overlay is shown. If | 56 // is hidden, and |kFullScreenModeHideDock| while the overlay is shown. If |
| 65 // the window is not on the primary screen, this should always be | 57 // the window is not on the primary screen, this should always be |
| 66 // |kFullScreenModeNormal|. This value can get out of sync with the correct | 58 // |kFullScreenModeNormal|. This value can get out of sync with the correct |
| 67 // state if we miss a notification (which can happen when a window is closed). | 59 // state if we miss a notification (which can happen when a window is closed). |
| 68 // Used to track the current state and make sure we properly restore the menu | 60 // Used to track the current state and make sure we properly restore the menu |
| 69 // bar when this controller is destroyed. | 61 // bar when this controller is destroyed. |
| 70 base::mac::FullScreenMode systemFullscreenMode_; | 62 base::mac::FullScreenMode systemFullscreenMode_; |
| 71 | 63 |
| 72 // Whether the omnibox is hidden in fullscreen. | 64 // Whether the omnibox is hidden in fullscreen. |
| 73 FullscreenSlidingStyle slidingStyle_; | 65 FullscreenSlidingStyle slidingStyle_; |
| 74 } | 66 } |
| 75 | 67 |
| 76 @property(nonatomic, assign) FullscreenSlidingStyle slidingStyle; | 68 @property(nonatomic, assign) FullscreenSlidingStyle slidingStyle; |
| 77 | 69 |
| 78 // Designated initializer. | 70 // Designated initializer. |
| 79 - (id)initWithBrowserController:(BrowserWindowController*)controller | 71 - (id)initWithBrowserController:(BrowserWindowController*)controller |
| 80 style:(FullscreenSlidingStyle)style; | 72 style:(FullscreenSlidingStyle)style; |
| 81 | 73 |
| 82 // Informs the controller that the browser has entered or exited fullscreen | 74 // Informs the controller that the browser has entered or exited fullscreen |
| 83 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called | 75 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called |
| 84 // after the window is setup, just before it is shown. |-exitFullscreenMode| | 76 // after the window is setup, just before it is shown. |-exitFullscreenMode| |
| 85 // should be called before any views are moved back to the non-fullscreen | 77 // should be called before any views are moved back to the non-fullscreen |
| 86 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called, | 78 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called, |
| 87 // it must be balanced with a call to |-exitFullscreenMode| before the | 79 // it must be balanced with a call to |-exitFullscreenMode| before the |
| 88 // controller is released. | 80 // controller is released. |
| 89 - (void)setupFullscreenToolbarForContentView:(NSView*)contentView; | 81 - (void)enterFullscreenMode; |
| 90 - (void)exitFullscreenMode; | 82 - (void)exitFullscreenMode; |
| 91 | 83 |
| 92 // Informs the controller that the overlay should be shown/hidden, possibly | 84 // Informs the controller that the overlay should be shown/hidden, possibly |
| 93 // with animation. | 85 // with animation. |
| 94 - (void)ensureOverlayShownWithAnimation:(BOOL)animate; | 86 - (void)ensureOverlayShownWithAnimation:(BOOL)animate; |
| 95 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate; | 87 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate; |
| 96 | 88 |
| 97 // Cancels any running animation and timers. | 89 // Cancels any running animation and timers. |
| 98 - (void)cancelAnimationAndTimer; | 90 - (void)cancelAnimationAndTimer; |
| 99 | 91 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 112 - (CGFloat)toolbarFraction; | 104 - (CGFloat)toolbarFraction; |
| 113 | 105 |
| 114 // Returns YES if the fullscreen toolbar must be shown. | 106 // Returns YES if the fullscreen toolbar must be shown. |
| 115 - (BOOL)mustShowFullscreenToolbar; | 107 - (BOOL)mustShowFullscreenToolbar; |
| 116 | 108 |
| 117 // Returns YES if the mouse is on the window's screen. This is used to check | 109 // Returns YES if the mouse is on the window's screen. This is used to check |
| 118 // if the menubar events belong to window's screen since the menubar would | 110 // if the menubar events belong to window's screen since the menubar would |
| 119 // only be revealed if the mouse is there. | 111 // only be revealed if the mouse is there. |
| 120 - (BOOL)isMouseOnScreen; | 112 - (BOOL)isMouseOnScreen; |
| 121 | 113 |
| 122 // Sets |trackingAreaFrame_| from the given overlay frame. | 114 // Called by the BrowserWindowController to update toolbar frame. |
| 123 - (void)setTrackingAreaFromOverlayFrame:(NSRect)frame; | 115 - (void)updateToolbarFrame:(NSRect)frame; |
| 124 | 116 |
| 125 // 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 |
| 126 // fullscreen. | 118 // fullscreen. |
| 127 - (BOOL)isFullscreenTransitionInProgress; | 119 - (BOOL)isFullscreenTransitionInProgress; |
| 128 | 120 |
| 129 // Returns YES if the browser in in fullscreen. | 121 // Returns YES if the browser in in fullscreen. |
| 130 - (BOOL)isInFullscreen; | 122 - (BOOL)isInFullscreen; |
| 131 | 123 |
| 132 // Updates the toolbar by updating the layout, menubar and dock. | 124 // Updates the toolbar by updating the layout, menubar and dock. |
| 133 - (void)updateToolbar; | 125 - (void)updateToolbar; |
| 134 | 126 |
| 135 // Returns |browserController_|. | 127 // Returns |browserController_|. |
| 136 - (BrowserWindowController*)browserWindowController; | 128 - (BrowserWindowController*)browserWindowController; |
| 137 | 129 |
| 138 @end | 130 @end |
| 139 | 131 |
| 140 // Private methods exposed for testing. | 132 // Private methods exposed for testing. |
| 141 @interface FullscreenToolbarController (ExposedForTesting) | 133 @interface FullscreenToolbarController (ExposedForTesting) |
| 142 // Adjusts the AppKit Fullscreen options of the application. | 134 // Adjusts the AppKit Fullscreen options of the application. |
| 143 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; | 135 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; |
| 144 | 136 |
| 145 // Callback for menu bar animations. | 137 // Callback for menu bar animations. |
| 146 - (void)setMenuBarRevealProgress:(CGFloat)progress; | 138 - (void)setMenuBarRevealProgress:(CGFloat)progress; |
| 147 | 139 |
| 148 @end | 140 @end |
| 149 | 141 |
| 150 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ | 142 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ |
| OLD | NEW |