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

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller.mm

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/browser_window_controller.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index 3f9f5a88871ab750d2c746cd009394b49cfe2330..37c3996dccff1b278ad2dc1cfcef3108b07ac073 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -55,11 +55,12 @@
#import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
#import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
#import "chrome/browser/ui/cocoa/framed_browser_window.h"
+#import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_visibility_locks_controller.h"
#include "chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.h"
#import "chrome/browser/ui/cocoa/fullscreen_window.h"
#import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
#import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
-#import "chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h"
+#import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_layout_manager.h"
#include "chrome/browser/ui/cocoa/l10n_util.h"
#import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h"
#import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h"
@@ -81,7 +82,6 @@
#include "chrome/browser/ui/window_sizer/window_sizer.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/command.h"
-#include "chrome/common/pref_names.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/managed/managed_bookmark_service.h"
#include "components/signin/core/common/profile_management_switches.h"
@@ -245,10 +245,6 @@ bool IsTabDetachingInFullscreenEnabled() {
NSMakeSize(400, 272) : NSMakeSize(100, 122);
[[self window] setMinSize:minSize];
- // Create the bar visibility lock set; 10 is arbitrary, but should hopefully
- // be big enough to hold all locks that'll ever be needed.
- barVisibilityLocks_.reset([[NSMutableSet setWithCapacity:10] retain]);
-
// Lion will attempt to automagically save and restore the UI. This
// functionality appears to be leaky (or at least interacts badly with our
// architecture) and thus BrowserWindowController never gets released. This
@@ -341,17 +337,16 @@ bool IsTabDetachingInFullscreenEnabled() {
[[InfoBarContainerController alloc] initWithResizeDelegate:self]);
[self updateInfoBarTipVisibility];
+ fullscreenToolbarLayoutManager_.reset(
+ new FullscreenToolbarLayoutManager(self));
+
// We don't want to try and show the bar before it gets placed in its parent
// view, so this step shoudn't be inside the bookmark bar controller's
// |-awakeFromNib|.
windowShim_->BookmarkBarStateChanged(
BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
- // Allow bar visibility to be changed.
- [self enableBarVisibilityUpdates];
-
[self updateFullscreenCollectionBehavior];
-
[self layoutSubviews];
// For non-trusted, non-app popup windows, |desiredContentRect| contains the
@@ -389,9 +384,6 @@ bool IsTabDetachingInFullscreenEnabled() {
extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS,
windowShim_.get()));
- PrefService* prefs = browser_->profile()->GetPrefs();
- shouldShowFullscreenToolbar_ =
- prefs->GetBoolean(prefs::kShowFullscreenToolbar);
blockLayoutSubviews_ = NO;
// We are done initializing now.
@@ -403,11 +395,10 @@ bool IsTabDetachingInFullscreenEnabled() {
- (void)dealloc {
browser_->tab_strip_model()->CloseAllTabs();
- // Explicitly release |fullscreenToolbarController_| here, as it may call back
- // to this BWC in |-dealloc|. We are required to call |-exitFullscreenMode|
- // before releasing the controller.
- [fullscreenToolbarController_ exitFullscreenMode];
- fullscreenToolbarController_.reset();
+ // Explicitly release |fullscreenToolbarLayoutManager_| here, as it may call
+ // back to this BWC in |-dealloc|. We are required to call
+ //|-exitFullscreenMode| before releasing the object.
+ fullscreenToolbarLayoutManager_.reset();
// Explicitly release |fullscreenTransition_| here since it may call back to
// this BWC in |-dealloc|. Reset the fullscreen variables.
@@ -1008,7 +999,7 @@ bool IsTabDetachingInFullscreenEnabled() {
bool willFocusLocationBar =
newContents && newContents->FocusLocationBarByDefault();
if ([self isInAnyFullscreenMode] && !willFocusLocationBar)
- [[self fullscreenToolbarController] revealToolbarForTabStripChanges];
+ fullscreenToolbarLayoutManager_->RevealToolbarForTabStripChanges();
}
- (void)zoomChangedForActiveTab:(BOOL)canShowBubble {
@@ -1443,7 +1434,7 @@ bool IsTabDetachingInFullscreenEnabled() {
- (void)onTabInsertedInForeground:(BOOL)inForeground {
if ([self isInAnyFullscreenMode] && !inForeground &&
![toolbarController_ isLocationBarFocused]) {
- [[self fullscreenToolbarController] revealToolbarForTabStripChanges];
+ fullscreenToolbarLayoutManager_->RevealToolbarForTabStripChanges();
}
}
@@ -1796,13 +1787,13 @@ willAnimateFromState:(BookmarkBar::State)oldState
[sheet orderOut:self];
}
-- (FullscreenToolbarController*)fullscreenToolbarController {
- return fullscreenToolbarController_.get();
+- (FullscreenToolbarLayoutManager*)fullscreenToolbarLayoutManager {
+ return fullscreenToolbarLayoutManager_.get();
}
-- (void)setFullscreenToolbarController:
- (FullscreenToolbarController*)controller {
- fullscreenToolbarController_.reset([controller retain]);
+- (void)setFullscreenToolbarLayoutManager:
+ (FullscreenToolbarLayoutManager*)controller {
+ fullscreenToolbarLayoutManager_.reset(controller);
}
- (void)executeExtensionCommand:(const std::string&)extension_id
@@ -1834,16 +1825,7 @@ willAnimateFromState:(BookmarkBar::State)oldState
- (void)updateUIForTabFullscreen:
(ExclusiveAccessContext::TabFullscreenState)state {
DCHECK([self isInAnyFullscreenMode]);
- if (state == ExclusiveAccessContext::STATE_ENTER_TAB_FULLSCREEN) {
- [self adjustUIForSlidingFullscreenStyle:FullscreenSlidingStyle::
- OMNIBOX_TABS_NONE];
- return;
- }
-
- [self adjustUIForSlidingFullscreenStyle:
- shouldShowFullscreenToolbar_
- ? FullscreenSlidingStyle::OMNIBOX_TABS_PRESENT
- : FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN];
+ fullscreenToolbarLayoutManager_->UpdateToolbarStyle();
}
- (void)updateFullscreenExitBubble {
@@ -1860,17 +1842,6 @@ willAnimateFromState:(BookmarkBar::State)oldState
return NO;
}
-- (void)setFullscreenToolbarVisible:(BOOL)visible {
- if (shouldShowFullscreenToolbar_ == visible)
- return;
-
- shouldShowFullscreenToolbar_ = visible;
- [self adjustUIForSlidingFullscreenStyle:
- shouldShowFullscreenToolbar_
- ? FullscreenSlidingStyle::OMNIBOX_TABS_PRESENT
- : FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN];
-}
-
- (BOOL)isInAnyFullscreenMode {
return [self isInImmersiveFullscreen] || [self isInAppKitFullscreen];
}
@@ -1886,8 +1857,15 @@ willAnimateFromState:(BookmarkBar::State)oldState
enteringAppKitFullscreen_);
}
+- (BOOL)isFullscreenForTabContentOrExtension {
+ FullscreenController* controller =
+ browser_->exclusive_access_manager()->fullscreen_controller();
+ return controller->IsWindowFullscreenForTabOrPending() ||
+ controller->IsExtensionFullscreenOrPending();
+}
+
- (CGFloat)menubarOffset {
- return [fullscreenToolbarController_ menubarOffset];
+ return fullscreenToolbarLayoutManager_->ComputeToolbarLayout().menubarOffset;
}
- (NSView*)avatarView {
@@ -1938,35 +1916,21 @@ willAnimateFromState:(BookmarkBar::State)oldState
[self layoutSubviews];
}
-- (BOOL)isBarVisibilityLockedForOwner:(id)owner {
- DCHECK(barVisibilityLocks_);
- return owner ? [barVisibilityLocks_ containsObject:owner]
- : [barVisibilityLocks_ count];
+- (BOOL)isToolbarVisibilityLockedForOwner:(id)owner {
+ return [[self fullscreenToolbarVisibilityLocksController]
+ isToolbarVisibilityLockedForOwner:owner];
}
-- (void)lockBarVisibilityForOwner:(id)owner withAnimation:(BOOL)animate {
- if (![self isBarVisibilityLockedForOwner:owner]) {
- [barVisibilityLocks_ addObject:owner];
-
- // If enabled, show the overlay if necessary (and if the fullscreen
- // toolbar is hidden).
- if (barVisibilityUpdatesEnabled_) {
- [fullscreenToolbarController_ lockBarVisibilityWithAnimation:animate];
- }
- }
+- (void)lockToolbarVisibilityForOwner:(id)owner withAnimation:(BOOL)animate {
+ [[self fullscreenToolbarVisibilityLocksController]
+ lockToolbarVisibilityForOwner:owner
+ withAnimation:animate];
}
-- (void)releaseBarVisibilityForOwner:(id)owner withAnimation:(BOOL)animate {
- if ([self isBarVisibilityLockedForOwner:owner]) {
- [barVisibilityLocks_ removeObject:owner];
-
- // If enabled, hide the overlay if necessary (and if the fullscreen
- // toolbar is hidden).
- if (barVisibilityUpdatesEnabled_ &&
- ![barVisibilityLocks_ count]) {
- [fullscreenToolbarController_ releaseBarVisibilityWithAnimation:animate];
- }
- }
+- (void)releaseToolbarVisibilityForOwner:(id)owner withAnimation:(BOOL)animate {
+ [[self fullscreenToolbarVisibilityLocksController]
+ releaseToolbarVisibilityForOwner:owner
+ withAnimation:animate];
}
- (BOOL)floatingBarHasFocus {
@@ -1978,6 +1942,15 @@ willAnimateFromState:(BookmarkBar::State)oldState
return exclusiveAccessController_.get();
}
+- (FullscreenToolbarLayoutManager*)fullscreenToolbarLayoutManager {
+ return fullscreenToolbarLayoutManager_.get();
+}
+
+- (FullscreenToolbarVisibilityLocksController*)
+ fullscreenToolbarVisibilityLocksController {
+ return fullscreenToolbarLayoutManager_->toolbar_visibility_locks();
+}
+
@end // @implementation BrowserWindowController(Fullscreen)
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.h ('k') | chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698