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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 2459653005: [Mac] Refactor the Fullscreen Toolbar Visibility Locks (Closed)
Patch Set: nits and grits 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
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 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #import "base/auto_reset.h" 9 #import "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 359
360 // Close the bookmark bubble, if it's open. Use |-ok:| instead of |-cancel:| 360 // Close the bookmark bubble, if it's open. Use |-ok:| instead of |-cancel:|
361 // or |-close| because that matches the behavior when the bubble loses key 361 // or |-close| because that matches the behavior when the bubble loses key
362 // status. 362 // status.
363 [bookmarkBubbleController_ ok:self]; 363 [bookmarkBubbleController_ ok:self];
364 364
365 // Save the current first responder so we can restore after views are moved. 365 // Save the current first responder so we can restore after views are moved.
366 base::scoped_nsobject<FocusTracker> focusTracker( 366 base::scoped_nsobject<FocusTracker> focusTracker(
367 [[FocusTracker alloc] initWithWindow:sourceWindow]); 367 [[FocusTracker alloc] initWithWindow:sourceWindow]);
368 368
369 // While we move views (and focus) around, disable any bar visibility changes.
370 [self disableBarVisibilityUpdates];
371
spqchan 2016/10/28 17:00:05 FYI, I removed these because we no longer show the
372 // Retain the tab strip view while we remove it from its superview. 369 // Retain the tab strip view while we remove it from its superview.
373 base::scoped_nsobject<NSView> tabStripView; 370 base::scoped_nsobject<NSView> tabStripView;
374 if ([self hasTabStrip]) { 371 if ([self hasTabStrip]) {
375 tabStripView.reset([[self tabStripView] retain]); 372 tabStripView.reset([[self tabStripView] retain]);
376 [tabStripView removeFromSuperview]; 373 [tabStripView removeFromSuperview];
377 } 374 }
378 375
379 // Disable autoresizing of subviews while we move views around. This prevents 376 // Disable autoresizing of subviews while we move views around. This prevents
380 // spurious renderer resizes. 377 // spurious renderer resizes.
381 [self.chromeContentView setAutoresizesSubviews:NO]; 378 [self.chromeContentView setAutoresizesSubviews:NO];
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 [destWindow setCollectionBehavior:behavior]; 432 [destWindow setCollectionBehavior:behavior];
436 433
437 if (![focusTracker restoreFocusInWindow:destWindow]) { 434 if (![focusTracker restoreFocusInWindow:destWindow]) {
438 // During certain types of fullscreen transitions, the view that had focus 435 // During certain types of fullscreen transitions, the view that had focus
439 // may have gone away (e.g., the one for a Flash FS widget). In this case, 436 // may have gone away (e.g., the one for a Flash FS widget). In this case,
440 // FocusTracker will fail to restore focus to anything, so we set the focus 437 // FocusTracker will fail to restore focus to anything, so we set the focus
441 // to the tab contents as a reasonable fall-back. 438 // to the tab contents as a reasonable fall-back.
442 [self focusTabContents]; 439 [self focusTabContents];
443 } 440 }
444 [sourceWindow orderOut:self]; 441 [sourceWindow orderOut:self];
445
446 // We're done moving focus, so re-enable bar visibility changes.
447 [self enableBarVisibilityUpdates];
448 } 442 }
449 443
450 - (void)updatePermissionBubbleAnchor { 444 - (void)updatePermissionBubbleAnchor {
451 PermissionRequestManager* manager = [self permissionRequestManager]; 445 PermissionRequestManager* manager = [self permissionRequestManager];
452 if (manager) 446 if (manager)
453 manager->UpdateAnchorPosition(); 447 manager->UpdateAnchorPosition();
454 } 448 }
455 449
456 - (void)adjustUIForExitingFullscreenAndStopOmniboxSliding { 450 - (void)adjustUIForExitingFullscreenAndStopOmniboxSliding {
457 [fullscreenToolbarController_ exitFullscreenMode]; 451 [fullscreenToolbarController_ exitFullscreenMode];
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 - (void)showFullscreenExitBubbleIfNecessary { 588 - (void)showFullscreenExitBubbleIfNecessary {
595 // This method is called in response to 589 // This method is called in response to
596 // |-updateFullscreenExitBubbleURL:bubbleType:|. If we're in the middle of the 590 // |-updateFullscreenExitBubbleURL:bubbleType:|. If we're in the middle of the
597 // transition into fullscreen (i.e., using the AppKit Fullscreen API), do not 591 // transition into fullscreen (i.e., using the AppKit Fullscreen API), do not
598 // show the bubble because it will cause visual jank 592 // show the bubble because it will cause visual jank
599 // (http://crbug.com/130649). This will be called again as part of 593 // (http://crbug.com/130649). This will be called again as part of
600 // |-windowDidEnterFullScreen:|, so arrange to do that work then instead. 594 // |-windowDidEnterFullScreen:|, so arrange to do that work then instead.
601 if (enteringAppKitFullscreen_) 595 if (enteringAppKitFullscreen_)
602 return; 596 return;
603 597
604 [self hideOverlayIfPossibleWithAnimation:NO];
605
606 switch (exclusiveAccessController_->bubble_type()) { 598 switch (exclusiveAccessController_->bubble_type()) {
607 case EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE: 599 case EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE:
608 case EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION: 600 case EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION:
609 // Show no exit instruction bubble on Mac when in Browser Fullscreen. 601 // Show no exit instruction bubble on Mac when in Browser Fullscreen.
610 exclusiveAccessController_->Destroy(); 602 exclusiveAccessController_->Destroy();
611 break; 603 break;
612 604
613 default: 605 default:
614 exclusiveAccessController_->Show(); 606 exclusiveAccessController_->Show();
615 } 607 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 - (void)adjustUIForEnteringFullscreen { 820 - (void)adjustUIForEnteringFullscreen {
829 FullscreenSlidingStyle style = FullscreenSlidingStyle::OMNIBOX_TABS_PRESENT; 821 FullscreenSlidingStyle style = FullscreenSlidingStyle::OMNIBOX_TABS_PRESENT;
830 if ([self isFullscreenForTabContentOrExtension]) 822 if ([self isFullscreenForTabContentOrExtension])
831 style = FullscreenSlidingStyle::OMNIBOX_TABS_NONE; 823 style = FullscreenSlidingStyle::OMNIBOX_TABS_NONE;
832 else if (!shouldShowFullscreenToolbar_) 824 else if (!shouldShowFullscreenToolbar_)
833 style = FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN; 825 style = FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN;
834 826
835 [self adjustUIForSlidingFullscreenStyle:style]; 827 [self adjustUIForSlidingFullscreenStyle:style];
836 } 828 }
837 829
838 - (void)enableBarVisibilityUpdates {
839 // Early escape if there's nothing to do.
840 if (barVisibilityUpdatesEnabled_)
841 return;
842
843 barVisibilityUpdatesEnabled_ = YES;
844
845 if ([barVisibilityLocks_ count])
846 [fullscreenToolbarController_ ensureOverlayShownWithAnimation:NO];
847 else
848 [fullscreenToolbarController_ ensureOverlayHiddenWithAnimation:NO];
849 }
850
851 - (void)disableBarVisibilityUpdates {
852 // Early escape if there's nothing to do.
853 if (!barVisibilityUpdatesEnabled_)
854 return;
855
856 barVisibilityUpdatesEnabled_ = NO;
857 [fullscreenToolbarController_ cancelAnimationAndTimer];
858 }
859
860 - (void)hideOverlayIfPossibleWithAnimation:(BOOL)animation {
861 if (!barVisibilityUpdatesEnabled_ || [barVisibilityLocks_ count])
862 return;
863
864 [fullscreenToolbarController_ ensureOverlayHiddenWithAnimation:animation];
865 }
866
867 - (CGFloat)toolbarDividerOpacity { 830 - (CGFloat)toolbarDividerOpacity {
868 return [bookmarkBarController_ toolbarDividerOpacity]; 831 return [bookmarkBarController_ toolbarDividerOpacity];
869 } 832 }
870 833
871 - (void)updateInfoBarTipVisibility { 834 - (void)updateInfoBarTipVisibility {
872 // If there's no toolbar then hide the infobar tip. 835 // If there's no toolbar then hide the infobar tip.
873 [infoBarContainerController_ 836 [infoBarContainerController_
874 setShouldSuppressTopInfoBarTip:![self hasToolbar]]; 837 setShouldSuppressTopInfoBarTip:![self hasToolbar]];
875 } 838 }
876 839
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 if (fullscreenLowPowerCoordinator_) 1211 if (fullscreenLowPowerCoordinator_)
1249 fullscreenLowPowerCoordinator_->SetHasActiveSheet(false); 1212 fullscreenLowPowerCoordinator_->SetHasActiveSheet(false);
1250 } 1213 }
1251 1214
1252 - (void)childWindowsDidChange { 1215 - (void)childWindowsDidChange {
1253 if (fullscreenLowPowerCoordinator_) 1216 if (fullscreenLowPowerCoordinator_)
1254 fullscreenLowPowerCoordinator_->ChildWindowsChanged(); 1217 fullscreenLowPowerCoordinator_->ChildWindowsChanged();
1255 } 1218 }
1256 1219
1257 @end // @implementation BrowserWindowController(Private) 1220 @end // @implementation BrowserWindowController(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698