Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h

Issue 2505653003: [Mac[ FullscreenToolbarController Refactor (Closed)
Patch Set: nits Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_
7
8 #include <Carbon/Carbon.h>
9 #import <Cocoa/Cocoa.h>
10
11 #include "base/mac/mac_util.h"
12 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
13
14 @class BrowserWindowController;
15 @class FullscreenMenubarTracker;
16 class FullscreenToolbarAnimationController;
17 @class FullscreenToolbarMouseTracker;
18 @class FullscreenToolbarVisibilityLockController;
19 @class ImmersiveFullscreenController;
20
21 // This enum class represents the appearance of the fullscreen toolbar, which
22 // includes the tab strip and omnibox.
23 enum class FullscreenToolbarStyle {
24 // The toolbar is present. Moving the cursor to the top
25 // causes the menubar to appear and the toolbar to slide down.
26 TOOLBAR_PRESENT,
27 // The toolbar is hidden. Moving cursor to top shows the
28 // toolbar and menubar.
29 TOOLBAR_HIDDEN,
30 // Toolbar is hidden. Moving cursor to top causes the menubar
31 // to appear, but not the toolbar.
32 TOOLBAR_NONE,
33 };
34
35 // Provides a controller to fullscreen toolbar for a single browser
36 // window. This class handles running animations, showing and hiding the
37 // fullscreen toolbar, and managing the tracking area associated with the
38 // toolbar. This class does not directly manage any views -- the
39 // BrowserWindowController is responsible for positioning and z-ordering views.
40 //
41
42 // TODO (spqchan): Write tests for this class. See crbug.com/640064.
43 @interface FullscreenToolbarController : NSObject {
44 @private
45 // Our parent controller.
46 BrowserWindowController* browserController_; // weak
47
48 // Whether or not we are in fullscreen mode.
49 BOOL inFullscreenMode_;
50
51 // Updates the fullscreen toolbar layout for changes in the menubar. This
52 // object is only set when the browser is in fullscreen mode.
53 base::scoped_nsobject<FullscreenMenubarTracker> menubarTracker_;
54
55 // Maintains the toolbar's visibility locks for the TOOLBAR_HIDDEN style.
56 base::scoped_nsobject<FullscreenToolbarVisibilityLockController>
57 visibilityLockController_;
58
59 // Manages the toolbar animations for the TOOLBAR_HIDDEN style.
60 std::unique_ptr<FullscreenToolbarAnimationController> animationController_;
61
62 // Mouse tracker to track the user's interactions with the toolbar. This
63 // object is only set when the browser is in fullscreen mode.
64 base::scoped_nsobject<FullscreenToolbarMouseTracker> mouseTracker_;
65
66 // Controller for immersive fullscreen.
67 base::scoped_nsobject<ImmersiveFullscreenController>
68 immersiveFullscreenController_;
69 }
70
71 @property(nonatomic, assign) FullscreenToolbarStyle toolbarStyle;
72
73 // Designated initializer.
74 - (id)initWithBrowserController:(BrowserWindowController*)controller;
75
76 // Informs the controller that the browser has entered or exited fullscreen
77 // mode. |-enterFullscreenMode| should be called when the window is about to
78 // enter fullscreen. |-exitFullscreenMode| should be called before any views
79 // are moved back to the non-fullscreen window.
80 - (void)enterFullscreenMode;
81 - (void)exitFullscreenMode;
82
83 // Cancels any running animation and timers.
84 - (void)cancelAnimationAndTimer;
85
86 // Animates the toolbar dropping down to show changes to the tab strip.
87 - (void)revealToolbarForTabStripChanges;
88
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.
95 // 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
97 // return a float that ranges from (0, 1).
98 - (CGFloat)toolbarFraction;
99
100 // Returns YES if the fullscreen toolbar must be shown.
101 - (BOOL)mustShowFullscreenToolbar;
102
103 // Called by the BrowserWindowController to update toolbar frame.
104 - (void)updateToolbarFrame:(NSRect)frame;
105
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
110 // relayout.
111 - (void)updateToolbarStyleExitingTabFullscreen:(BOOL)isExitingTabFullscreen;
112
113 // Updates the toolbar by updating the layout, menubar and dock.
114 - (void)updateToolbar;
115
116 // Returns |browserController_|.
117 - (BrowserWindowController*)browserWindowController;
118
119 // Returns the object in |visibilityLockController_|;
120 - (FullscreenToolbarVisibilityLockController*)visibilityLockController;
121
122 @end
123
124 // Private methods exposed for testing.
125 @interface FullscreenToolbarController (ExposedForTesting)
126 // Adjusts the AppKit Fullscreen options of the application.
127 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode;
128
129 // Callback for menu bar animations.
130 - (void)setMenuBarRevealProgress:(CGFloat)progress;
131
132 @end
133
134 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698