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

Unified Diff: chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_layout_manager.h

Issue 2355413007: [Mac] Refactor the Fullscreen Toolbar (Closed)
Patch Set: Nits and grits Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_layout_manager.h
diff --git a/chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_layout_manager.h b/chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_layout_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..13c6c386eb1443a6e8d1aff488c0701dc02a1550
--- /dev/null
+++ b/chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_layout_manager.h
@@ -0,0 +1,138 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_COCOA_FULLSCREEN_FULLSCREEN_TOOLBAR_LAYOUT_MANAGER_H_
+#define CHROME_BROWSER_UI_COCOA_FULLSCREEN_FULLSCREEN_TOOLBAR_LAYOUT_MANAGER_H_
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/mac/mac_util.h"
+#include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
+
+namespace {
+class FullscreenToolbarLayoutTest;
+}
+
+@class BrowserWindowController;
+@class DropdownAnimation;
+@class FullscreenMenubarTracker;
+class FullscreenToolbarAnimationManager;
+@class FullscreenToolbarMouseTracker;
+@class FullscreenToolbarVisibilityLocksController;
+@class ImmersiveFullscreenController;
+
+// This enum class represents the appearance of the fullscreen toolbar, which
+// includes the tab strip and omnibox. There are 3 different styles:
+// + TOOLBAR_PRESENT: The toolbar is present. Moving the cursor to the top
+// causes the menubar to appear and the toolbar to slide down.
+// + TOOLBAR_HIDDEN: The toolbar is hidden. Moving cursor to top shows the
+// toolbar and menubar.
+// + TOOLBAR_NONE: Toolbar is hidden. Moving cursor to top causes the menubar
+// to appear, but not the toolbar.
+enum class FullscreenToolbarStyle {
+ TOOLBAR_PRESENT,
+ TOOLBAR_HIDDEN,
+ TOOLBAR_NONE,
+};
+
+// This struct contains the calculated values of the fullscreen toolbar layout.
+struct FullscreenToolbarLayout {
+ // The toolbar style.
+ FullscreenToolbarStyle toolbarStyle;
+
+ // The fraction of the toolbar that is shown in the screen.
+ CGFloat toolbarFraction;
+
+ // The amount the menuber should be offset from the top of the screen.
+ CGFloat menubarOffset;
+};
+
+// This class manages the layout of the fullscreen toolbar for a single
+// browser window. This class sets up trackers for the menubar, mouse, toolbar
+// animations, and visibility locks. The trackers will update the class, which
+// will then update the BrowserWindowController.
+class FullscreenToolbarLayoutManager {
+ public:
+ FullscreenToolbarLayoutManager(BrowserWindowController* controller);
+
+ ~FullscreenToolbarLayoutManager();
+
+ // Called when the window enters fullscreen.
+ void EnterFullscreenMode();
+
+ // Called when the window exits fullscreen.
+ void ExitFullscreenMode();
+
+ // Called when the tabstrip is changed. Kickstarts the animation to show
+ // and hide the toolbar. This is virtual so that tests can override it.
+ virtual void RevealToolbarForTabStripChanges();
+
+ // Computes and returns toolbar layout.
+ FullscreenToolbarLayout ComputeToolbarLayout() const;
+
+ // Returns true if the fullscreen toolbar must be shown.
+ bool MustShowFullscreenToolbar() const;
+
+ // Called by the BrowserWindowController to update toolbar frame.
+ void UpdateFullscreenToolbarFrame(NSRect frame);
+
+ // Updates the window's layout.
+ void Layout();
+
+ // Updates the toolbar style. If the style has changed, then the toolbar
+ // will relayout.
+ void UpdateToolbarStyle();
+
+ FullscreenToolbarVisibilityLocksController* toolbar_visibility_locks() const {
+ return toolbar_visibility_locks_;
+ }
+
+ BOOL in_fullscreen_mode() const { return in_fullscreen_; }
+
+ BrowserWindowController* browser_window_controller() const {
+ return browser_controller_;
+ }
+
+ private:
+ friend class ::FullscreenToolbarLayoutTest;
+
+ // Computes and returns the toolbar fraction.
+ CGFloat ComputeToolbarFraction() const;
+
+ // Cleans up and reset the tracker objects.
+ void CleanUp();
+
+ // Our parent controller.
+ BrowserWindowController* browser_controller_; // weak
+
+ // Whether or not we are in fullscreen mode.
+ BOOL in_fullscreen_;
+
+ // True if the fullscreen toolbar shown be shown for browser fullscreen.
+ BOOL shouldShowFullscreenToolbar_;
+
+ // Updates the fullscreen layout for changes in the menubar. This object is
+ // only set when the browser is in fullscreen mode.
+ base::scoped_nsobject<FullscreenMenubarTracker> menubar_tracker_;
+
+ // Mouse tracker to track the user's interactions with the toolbar. This
+ // object is only set when the browser is in fullscreen mode.
+ base::scoped_nsobject<FullscreenToolbarMouseTracker> mouse_tracker_;
+
+ // Maintains the toolbar's visibility locks for the TOOLBAR_HIDDEN style.
+ base::scoped_nsobject<FullscreenToolbarVisibilityLocksController>
+ toolbar_visibility_locks_;
+
+ // Manages the toolbar animations for the TOOLBAR_HIDDEN style.
+ std::unique_ptr<FullscreenToolbarAnimationManager> animation_manager_;
+
+ // Controller for immersive fullscreen.
+ base::scoped_nsobject<ImmersiveFullscreenController>
+ immersive_fullscreen_controller_;
+
+ // The current toolbar style.
+ FullscreenToolbarStyle toolbar_style_;
+};
+
+#endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_FULLSCREEN_TOOLBAR_LAYOUT_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698