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
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_UI_COCOA_FULLSCREEN_FULLSCREEN_TOOLBAR_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_FULLSCREEN_FULLSCREEN_TOOLBAR_CONTROLLER_H_
7 
8 #import <Cocoa/Cocoa.h>
9 
10 #include "base/mac/mac_util.h"
11 
12 class BrowserView;
13 @class FullscreenMenubarTracker;
14 
15 namespace content {
16 class WebContents;
17 }
18 
19 // This enum class represents the appearance of the fullscreen toolbar, which
20 // includes the tab strip and omnibox.
21 enum class FullscreenToolbarStyle {
22   // The toolbar is present. Moving the cursor to the top
23   // causes the menubar to appear and the toolbar to slide down.
24   TOOLBAR_PRESENT = 0,
25   // The toolbar is hidden. Moving cursor to top shows the
26   // toolbar and menubar.
27   TOOLBAR_HIDDEN,
28   // Toolbar is hidden. Moving cursor to top causes the menubar
29   // to appear, but not the toolbar.
30   TOOLBAR_NONE,
31 };
32 
33 // The protocol to query the status of the fullscreen mode and to provide
34 // the context.
35 @protocol FullscreenToolbarContextDelegate
36 
37 // Whether in any kind of fullscreen mode including AppKit fullscreen mode and
38 // immersive fullscreen mode.
39 - (BOOL)isInAnyFullscreenMode;
40 // Whether in the process of transitioning in or out of the AppKit fullscreen
41 // mode.
42 - (BOOL)isFullscreenTransitionInProgress;
43 // The native window associated with the fullscreen controller.
44 - (NSWindow*)window;
45 
46 @end
47 
48 // Provides a controller to the fullscreen toolbar for a single browser
49 // window. This class sets up the animation manager, visibility locks, menubar
50 // tracking, and mouse tracking associated with the toolbar. It receives input
51 // from these objects to update and recompute the fullscreen toolbar laytout.
52 @interface FullscreenToolbarController
53     : NSObject <FullscreenToolbarContextDelegate>
54 
55 // Designated initializer.
56 - (id)initWithBrowserView:(BrowserView*)browserView;
57 
58 // Informs the controller that the browser has entered or exited fullscreen
59 // mode. |-enterFullscreenMode| should be called when the window is about to
60 // enter fullscreen. |-exitFullscreenMode| should be called before any views
61 // are moved back to the non-fullscreen window.
62 - (void)enterFullscreenMode;
63 - (void)exitFullscreenMode;
64 
65 // Animates the toolbar dropping down to show changes to the tab strip.
66 - (void)revealToolbarForWebContents:(content::WebContents*)contents
67                        inForeground:(BOOL)inForeground;
68 
69 // Returns the fraction of the toolbar exposed at the top.
70 // It returns 1.0 if the toolbar is fully shown and 0.0 if the toolbar is
71 // hidden. Otherwise, if the toolbar is in progress of animating, it will
72 // return a float that ranges from (0, 1).
73 - (CGFloat)toolbarFraction;
74 
75 // Returns |toolbarStyle_|.
76 - (FullscreenToolbarStyle)toolbarStyle;
77 
78 // Returns YES if the fullscreen toolbar must be shown.
79 - (BOOL)mustShowFullscreenToolbar;
80 
81 // Called to update toolbar frame such as the frame layout may be changed.
82 - (void)updateToolbarFrame:(NSRect)frame;
83 
84 // Updates the toolbar by updating the layout.
85 - (void)layoutToolbar;
86 
87 // Returns YES if the browser in in fullscreen.
88 - (BOOL)isInFullscreen;
89 
90 // Returns the object in |menubarTracker_|;
91 - (FullscreenMenubarTracker*)menubarTracker;
92 
93 // Sets the value of |toolbarStyle_|.
94 - (void)setToolbarStyle:(FullscreenToolbarStyle)style;
95 
96 @end
97 
98 #endif  // CHROME_BROWSER_UI_COCOA_FULLSCREEN_FULLSCREEN_TOOLBAR_CONTROLLER_H_
99