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

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

Issue 2467833003: [Mac] Move the fullscreen toolbar style to FullscreenToolbarController (Closed)
Patch Set: fix for rsesek 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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 } 440 }
441 [sourceWindow orderOut:self]; 441 [sourceWindow orderOut:self];
442 } 442 }
443 443
444 - (void)updatePermissionBubbleAnchor { 444 - (void)updatePermissionBubbleAnchor {
445 PermissionRequestManager* manager = [self permissionRequestManager]; 445 PermissionRequestManager* manager = [self permissionRequestManager];
446 if (manager) 446 if (manager)
447 manager->UpdateAnchorPosition(); 447 manager->UpdateAnchorPosition();
448 } 448 }
449 449
450 - (void)adjustUIForExitingFullscreenAndStopOmniboxSliding {
451 [fullscreenToolbarController_ exitFullscreenMode];
452 fullscreenToolbarController_.reset();
453
454 // Force the bookmark bar z-order to update.
455 [[bookmarkBarController_ view] removeFromSuperview];
456 [self layoutSubviews];
457 }
458
459 - (void)adjustUIForSlidingFullscreenStyle:(FullscreenSlidingStyle)style {
460 // The UI should only be adjusted in fullscreen mode.
461 if (![self isInAnyFullscreenMode])
462 return;
463
464 if (!fullscreenToolbarController_) {
465 fullscreenToolbarController_.reset(
466 [self newFullscreenToolbarControllerWithStyle:style]);
467 [fullscreenToolbarController_ enterFullscreenMode];
468 } else {
469 fullscreenToolbarController_.get().slidingStyle = style;
470 }
471
472 if (!floatingBarBackingView_.get() &&
473 ([self hasTabStrip] || [self hasToolbar] || [self hasLocationBar])) {
474 floatingBarBackingView_.reset(
475 [[FloatingBarBackingView alloc] initWithFrame:NSZeroRect]);
476 [floatingBarBackingView_
477 setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)];
478 }
479
480 // Force the bookmark bar z-order to update.
481 [[bookmarkBarController_ view] removeFromSuperview];
482 [self layoutSubviews];
483 }
484
485 - (FullscreenToolbarController*)newFullscreenToolbarControllerWithStyle:
486 (FullscreenSlidingStyle)style {
487 return [[FullscreenToolbarController alloc] initWithBrowserController:self
488 style:style];
489 }
490
491 - (void)enterImmersiveFullscreen { 450 - (void)enterImmersiveFullscreen {
492 RecordFullscreenWindowLocation([self window]); 451 RecordFullscreenWindowLocation([self window]);
493 RecordFullscreenStyle(IMMERSIVE_FULLSCREEN); 452 RecordFullscreenStyle(IMMERSIVE_FULLSCREEN);
494 453
495 // Set to NO by |-windowDidEnterFullScreen:|. 454 // Set to NO by |-windowDidEnterFullScreen:|.
496 enteringImmersiveFullscreen_ = YES; 455 enteringImmersiveFullscreen_ = YES;
497 456
498 // Fade to black. 457 // Fade to black.
499 const CGDisplayReservationInterval kFadeDurationSeconds = 0.6; 458 const CGDisplayReservationInterval kFadeDurationSeconds = 0.6;
500 Boolean didFadeOut = NO; 459 Boolean didFadeOut = NO;
501 CGDisplayFadeReservationToken token; 460 CGDisplayFadeReservationToken token;
502 if (CGAcquireDisplayFadeReservation(kFadeDurationSeconds, &token) 461 if (CGAcquireDisplayFadeReservation(kFadeDurationSeconds, &token)
503 == kCGErrorSuccess) { 462 == kCGErrorSuccess) {
504 didFadeOut = YES; 463 didFadeOut = YES;
505 CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendNormal, 464 CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendNormal,
506 kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, /*synchronous=*/true); 465 kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, /*synchronous=*/true);
507 } 466 }
508 467
509 // Create the fullscreen window. 468 // Create the fullscreen window.
510 fullscreenWindow_.reset([[self createFullscreenWindow] retain]); 469 fullscreenWindow_.reset([[self createFullscreenWindow] retain]);
511 savedRegularWindow_ = [[self window] retain]; 470 savedRegularWindow_ = [[self window] retain];
512 savedRegularWindowFrame_ = [savedRegularWindow_ frame]; 471 savedRegularWindowFrame_ = [savedRegularWindow_ frame];
513 472
514 [self moveViewsForImmersiveFullscreen:YES 473 [self moveViewsForImmersiveFullscreen:YES
515 regularWindow:[self window] 474 regularWindow:[self window]
516 fullscreenWindow:fullscreenWindow_.get()]; 475 fullscreenWindow:fullscreenWindow_.get()];
517 476 [self adjustUIForEnteringFullscreen];
518 FullscreenSlidingStyle style = FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN;
519 [self adjustUIForSlidingFullscreenStyle:style];
520 477
521 [fullscreenWindow_ display]; 478 [fullscreenWindow_ display];
522 479
523 // AppKit is helpful and prevents NSWindows from having the same height as 480 // AppKit is helpful and prevents NSWindows from having the same height as
524 // the screen while the menu bar is showing. This only applies to windows on 481 // the screen while the menu bar is showing. This only applies to windows on
525 // a secondary screen, in a separate space. Calling [NSWindow 482 // a secondary screen, in a separate space. Calling [NSWindow
526 // setFrame:display:] with the screen's height will always reduce the 483 // setFrame:display:] with the screen's height will always reduce the
527 // height by the height of the MenuBar. Calling the method with any other 484 // height by the height of the MenuBar. Calling the method with any other
528 // height works fine. The relevant method in the 10.10 AppKit SDK is called: 485 // height works fine. The relevant method in the 10.10 AppKit SDK is called:
529 // _canAdjustSizeForScreensHaveSeparateSpacesIfFillingSecondaryScreen 486 // _canAdjustSizeForScreensHaveSeparateSpacesIfFillingSecondaryScreen
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 [bubbleWindow orderFront:nil]; 737 [bubbleWindow orderFront:nil];
781 } 738 }
782 739
783 // Ensure that the window is layout properly. 740 // Ensure that the window is layout properly.
784 [self layoutSubviews]; 741 [self layoutSubviews];
785 } 742 }
786 743
787 - (void)windowDidFailToEnterFullScreen:(NSWindow*)window { 744 - (void)windowDidFailToEnterFullScreen:(NSWindow*)window {
788 [self deregisterForContentViewResizeNotifications]; 745 [self deregisterForContentViewResizeNotifications];
789 [self resetCustomAppKitFullscreenVariables]; 746 [self resetCustomAppKitFullscreenVariables];
790 [self adjustUIForExitingFullscreenAndStopOmniboxSliding]; 747 [self adjustUIForExitingFullscreen];
791 fullscreenLowPowerCoordinator_.reset(); 748 fullscreenLowPowerCoordinator_.reset();
792 } 749 }
793 750
794 - (void)windowDidFailToExitFullScreen:(NSWindow*)window { 751 - (void)windowDidFailToExitFullScreen:(NSWindow*)window {
795 [self deregisterForContentViewResizeNotifications]; 752 [self deregisterForContentViewResizeNotifications];
796 [self resetCustomAppKitFullscreenVariables]; 753 [self resetCustomAppKitFullscreenVariables];
797 754
798 // Force a relayout to try and get the window back into a reasonable state. 755 // Force a relayout to try and get the window back into a reasonable state.
799 [self layoutSubviews]; 756 [self layoutSubviews];
800 } 757 }
801 758
802 - (void)setSheetHiddenForFullscreenTransition:(BOOL)shoudHide { 759 - (void)setSheetHiddenForFullscreenTransition:(BOOL)shoudHide {
803 if (!isUsingCustomAnimation_) 760 if (!isUsingCustomAnimation_)
804 return; 761 return;
805 762
806 ConstrainedWindowSheetController* sheetController = 763 ConstrainedWindowSheetController* sheetController =
807 [ConstrainedWindowSheetController 764 [ConstrainedWindowSheetController
808 controllerForParentWindow:[self window]]; 765 controllerForParentWindow:[self window]];
809 if (shoudHide) 766 if (shoudHide)
810 [sheetController hideSheetForFullscreenTransition]; 767 [sheetController hideSheetForFullscreenTransition];
811 else 768 else
812 [sheetController unhideSheetForFullscreenTransition]; 769 [sheetController unhideSheetForFullscreenTransition];
813 } 770 }
814 771
815 - (void)adjustUIForExitingFullscreen { 772 - (void)adjustUIForExitingFullscreen {
816 exclusiveAccessController_->Destroy(); 773 exclusiveAccessController_->Destroy();
817 [self adjustUIForExitingFullscreenAndStopOmniboxSliding]; 774 [fullscreenToolbarController_ exitFullscreenMode];
775 fullscreenToolbarController_.reset();
776
777 // Force the bookmark bar z-order to update.
778 [[bookmarkBarController_ view] removeFromSuperview];
779 [self layoutSubviews];
818 } 780 }
819 781
820 - (void)adjustUIForEnteringFullscreen { 782 - (void)adjustUIForEnteringFullscreen {
821 FullscreenSlidingStyle style = FullscreenSlidingStyle::OMNIBOX_TABS_PRESENT; 783 DCHECK([self isInAnyFullscreenMode]);
822 if ([self isFullscreenForTabContentOrExtension]) 784 if (!fullscreenToolbarController_) {
823 style = FullscreenSlidingStyle::OMNIBOX_TABS_NONE; 785 fullscreenToolbarController_.reset(
824 else if (!shouldShowFullscreenToolbar_) 786 [[FullscreenToolbarController alloc] initWithBrowserController:self]);
825 style = FullscreenSlidingStyle::OMNIBOX_TABS_HIDDEN; 787 }
826 788
827 [self adjustUIForSlidingFullscreenStyle:style]; 789 [fullscreenToolbarController_ enterFullscreenMode];
790
791 if (!floatingBarBackingView_.get() &&
792 ([self hasTabStrip] || [self hasToolbar] || [self hasLocationBar])) {
793 floatingBarBackingView_.reset(
794 [[FloatingBarBackingView alloc] initWithFrame:NSZeroRect]);
795 [floatingBarBackingView_
796 setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)];
797 }
798
799 // Force the bookmark bar z-order to update.
800 [[bookmarkBarController_ view] removeFromSuperview];
801 [self layoutSubviews];
828 } 802 }
829 803
830 - (CGFloat)toolbarDividerOpacity { 804 - (CGFloat)toolbarDividerOpacity {
831 return [bookmarkBarController_ toolbarDividerOpacity]; 805 return [bookmarkBarController_ toolbarDividerOpacity];
832 } 806 }
833 807
834 - (void)updateInfoBarTipVisibility { 808 - (void)updateInfoBarTipVisibility {
835 // If there's no toolbar then hide the infobar tip. 809 // If there's no toolbar then hide the infobar tip.
836 [infoBarContainerController_ 810 [infoBarContainerController_
837 setShouldSuppressTopInfoBarTip:![self hasToolbar]]; 811 setShouldSuppressTopInfoBarTip:![self hasToolbar]];
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 - (void)updateLayoutParameters:(BrowserWindowLayout*)layout { 861 - (void)updateLayoutParameters:(BrowserWindowLayout*)layout {
888 [layout setContentViewSize:[[[self window] contentView] bounds].size]; 862 [layout setContentViewSize:[[[self window] contentView] bounds].size];
889 863
890 NSSize windowSize = (fullscreenTransition_.get()) 864 NSSize windowSize = (fullscreenTransition_.get())
891 ? [fullscreenTransition_ desiredWindowLayoutSize] 865 ? [fullscreenTransition_ desiredWindowLayoutSize]
892 : [[self window] frame].size; 866 : [[self window] frame].size;
893 867
894 [layout setWindowSize:windowSize]; 868 [layout setWindowSize:windowSize];
895 869
896 [layout setInAnyFullscreen:[self isInAnyFullscreenMode]]; 870 [layout setInAnyFullscreen:[self isInAnyFullscreenMode]];
897 [layout setSlidingStyle:fullscreenToolbarController_.get().slidingStyle]; 871 [layout setFullscreenToolbarStyle:fullscreenToolbarController_.get()
872 .toolbarStyle];
898 [layout 873 [layout
899 setFullscreenMenubarOffset:[fullscreenToolbarController_ menubarOffset]]; 874 setFullscreenMenubarOffset:[fullscreenToolbarController_ menubarOffset]];
900 [layout setFullscreenToolbarFraction:[fullscreenToolbarController_ 875 [layout setFullscreenToolbarFraction:[fullscreenToolbarController_
901 toolbarFraction]]; 876 toolbarFraction]];
902 877
903 [layout setHasTabStrip:[self hasTabStrip]]; 878 [layout setHasTabStrip:[self hasTabStrip]];
904 [layout setFullscreenButtonFrame:[self fullscreenButtonFrame]]; 879 [layout setFullscreenButtonFrame:[self fullscreenButtonFrame]];
905 880
906 if ([self shouldShowAvatar]) { 881 if ([self shouldShowAvatar]) {
907 NSView* avatar = [avatarButtonController_ view]; 882 NSView* avatar = [avatarButtonController_ view];
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 - (WebContents*)webContents { 1163 - (WebContents*)webContents {
1189 return browser_->tab_strip_model()->GetActiveWebContents(); 1164 return browser_->tab_strip_model()->GetActiveWebContents();
1190 } 1165 }
1191 1166
1192 - (PermissionRequestManager*)permissionRequestManager { 1167 - (PermissionRequestManager*)permissionRequestManager {
1193 if (WebContents* contents = [self webContents]) 1168 if (WebContents* contents = [self webContents])
1194 return PermissionRequestManager::FromWebContents(contents); 1169 return PermissionRequestManager::FromWebContents(contents);
1195 return nil; 1170 return nil;
1196 } 1171 }
1197 1172
1198 - (BOOL)isFullscreenForTabContentOrExtension {
1199 FullscreenController* controller =
1200 browser_->exclusive_access_manager()->fullscreen_controller();
1201 return controller->IsWindowFullscreenForTabOrPending() ||
1202 controller->IsExtensionFullscreenOrPending();
1203 }
1204
1205 - (FullscreenToolbarVisibilityLockController*) 1173 - (FullscreenToolbarVisibilityLockController*)
1206 fullscreenToolbarVisibilityLockController { 1174 fullscreenToolbarVisibilityLockController {
1207 return [fullscreenToolbarController_ visibilityLockController]; 1175 return [fullscreenToolbarController_ visibilityLockController];
1208 } 1176 }
1209 1177
1210 - (void)windowWillBeginSheet:(NSNotification*)notification { 1178 - (void)windowWillBeginSheet:(NSNotification*)notification {
1211 if (fullscreenLowPowerCoordinator_) 1179 if (fullscreenLowPowerCoordinator_)
1212 fullscreenLowPowerCoordinator_->SetHasActiveSheet(true); 1180 fullscreenLowPowerCoordinator_->SetHasActiveSheet(true);
1213 } 1181 }
1214 1182
1215 - (void)windowDidEndSheet:(NSNotification*)notification { 1183 - (void)windowDidEndSheet:(NSNotification*)notification {
1216 if (fullscreenLowPowerCoordinator_) 1184 if (fullscreenLowPowerCoordinator_)
1217 fullscreenLowPowerCoordinator_->SetHasActiveSheet(false); 1185 fullscreenLowPowerCoordinator_->SetHasActiveSheet(false);
1218 } 1186 }
1219 1187
1220 - (void)childWindowsDidChange { 1188 - (void)childWindowsDidChange {
1221 if (fullscreenLowPowerCoordinator_) 1189 if (fullscreenLowPowerCoordinator_)
1222 fullscreenLowPowerCoordinator_->ChildWindowsChanged(); 1190 fullscreenLowPowerCoordinator_->ChildWindowsChanged();
1223 } 1191 }
1224 1192
1225 @end // @implementation BrowserWindowController(Private) 1193 @end // @implementation BrowserWindowController(Private)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller_private.h ('k') | chrome/browser/ui/cocoa/browser_window_layout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698