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

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

Issue 1276383004: Implemented fullscreen exit animation with AppKit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed extra include Created 5 years, 4 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 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 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/mac/bind_objc_block.h" 10 #include "base/mac/bind_objc_block.h"
11 #include "base/mac/foundation_util.h" 11 #include "base/mac/foundation_util.h"
12 #include "base/mac/mac_util.h" 12 #include "base/mac/mac_util.h"
13 #import "base/mac/scoped_nsobject.h" 13 #import "base/mac/scoped_nsobject.h"
14 #import "base/mac/sdk_forward_declarations.h" 14 #import "base/mac/sdk_forward_declarations.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
17 #include "base/prefs/scoped_user_pref_update.h" 17 #include "base/prefs/scoped_user_pref_update.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/fullscreen.h" 19 #include "chrome/browser/fullscreen.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 21 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
22 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 22 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
23 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_window_state.h" 24 #include "chrome/browser/ui/browser_window_state.h"
25 #import "chrome/browser/ui/cocoa/browser_window_enter_fullscreen_transition.h" 25 #import "chrome/browser/ui/cocoa/browser_window_fullscreen_transition.h"
26 #import "chrome/browser/ui/cocoa/browser_window_layout.h" 26 #import "chrome/browser/ui/cocoa/browser_window_layout.h"
27 #import "chrome/browser/ui/cocoa/custom_frame_view.h" 27 #import "chrome/browser/ui/cocoa/custom_frame_view.h"
28 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" 28 #import "chrome/browser/ui/cocoa/dev_tools_controller.h"
29 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 29 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
30 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" 30 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
31 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h" 31 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h"
32 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 32 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
33 #import "chrome/browser/ui/cocoa/fullscreen_window.h" 33 #import "chrome/browser/ui/cocoa/fullscreen_window.h"
34 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 34 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
35 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" 35 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h"
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 [[[self window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]]; 699 [[[self window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]];
700 700
701 fullscreen_mac::SlidingStyle style = 701 fullscreen_mac::SlidingStyle style =
702 mode ? fullscreen_mac::OMNIBOX_TABS_HIDDEN 702 mode ? fullscreen_mac::OMNIBOX_TABS_HIDDEN
703 : fullscreen_mac::OMNIBOX_TABS_PRESENT; 703 : fullscreen_mac::OMNIBOX_TABS_PRESENT;
704 704
705 [self adjustUIForSlidingFullscreenStyle:style]; 705 [self adjustUIForSlidingFullscreenStyle:style];
706 } 706 }
707 707
708 - (void)windowDidEnterFullScreen:(NSNotification*)notification { 708 - (void)windowDidEnterFullScreen:(NSNotification*)notification {
709 enterFullscreenTransition_.reset(); 709 fullscreenTransition_.reset();
710 710
711 // In Yosemite, some combination of the titlebar and toolbar always show in 711 // In Yosemite, some combination of the titlebar and toolbar always show in
712 // full-screen mode. We do not want either to show. Search for the window that 712 // full-screen mode. We do not want either to show. Search for the window that
713 // contains the views, and hide it. There is no need to ever unhide the view. 713 // contains the views, and hide it. There is no need to ever unhide the view.
714 // http://crbug.com/380235 714 // http://crbug.com/380235
715 if (base::mac::IsOSYosemiteOrLater()) { 715 if (base::mac::IsOSYosemiteOrLater()) {
716 for (NSWindow* window in [[NSApplication sharedApplication] windows]) { 716 for (NSWindow* window in [[NSApplication sharedApplication] windows]) {
717 if ([window 717 if ([window
718 isKindOfClass:NSClassFromString(@"NSToolbarFullScreenWindow")]) { 718 isKindOfClass:NSClassFromString(@"NSToolbarFullScreenWindow")]) {
719 [[window contentView] setHidden:YES]; 719 [[window contentView] setHidden:YES];
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 enteringPresentationMode_ = NO; 754 enteringPresentationMode_ = NO;
755 755
756 [self showFullscreenExitBubbleIfNecessary]; 756 [self showFullscreenExitBubbleIfNecessary];
757 browser_->WindowFullscreenStateChanged(); 757 browser_->WindowFullscreenStateChanged();
758 [[[self window] contentView] setWantsLayer:windowViewWantsLayer_]; 758 [[[self window] contentView] setWantsLayer:windowViewWantsLayer_];
759 } 759 }
760 760
761 - (void)windowWillExitFullScreen:(NSNotification*)notification { 761 - (void)windowWillExitFullScreen:(NSNotification*)notification {
762 if (notification) // For System Fullscreen when non-nil. 762 if (notification) // For System Fullscreen when non-nil.
763 [self registerForContentViewResizeNotifications]; 763 [self registerForContentViewResizeNotifications];
764 exitingAppKitFullscreen_ = YES;
765
764 [self destroyFullscreenExitBubbleIfNecessary]; 766 [self destroyFullscreenExitBubbleIfNecessary];
765 [self adjustUIForExitingFullscreenAndStopOmniboxSliding]; 767 [self adjustUIForExitingFullscreenAndStopOmniboxSliding];
766 } 768 }
767 769
768 - (void)windowDidExitFullScreen:(NSNotification*)notification { 770 - (void)windowDidExitFullScreen:(NSNotification*)notification {
771 DCHECK(exitingAppKitFullscreen_);
772
769 if (notification) // For System Fullscreen when non-nil. 773 if (notification) // For System Fullscreen when non-nil.
770 [self deregisterForContentViewResizeNotifications]; 774 [self deregisterForContentViewResizeNotifications];
775
776 // Since the content view was forcefully resized during the transition, we
777 // want to ensure that the subviews are layout correctly after it ended.
778 [self layoutSubviews];
771 browser_->WindowFullscreenStateChanged(); 779 browser_->WindowFullscreenStateChanged();
780
781 exitingAppKitFullscreen_ = NO;
782 fullscreenTransition_.reset();
772 } 783 }
773 784
774 - (void)windowDidFailToEnterFullScreen:(NSWindow*)window { 785 - (void)windowDidFailToEnterFullScreen:(NSWindow*)window {
775 [self deregisterForContentViewResizeNotifications]; 786 [self deregisterForContentViewResizeNotifications];
776 enteringAppKitFullscreen_ = NO; 787 enteringAppKitFullscreen_ = NO;
788 fullscreenTransition_.reset();
777 [self adjustUIForExitingFullscreenAndStopOmniboxSliding]; 789 [self adjustUIForExitingFullscreenAndStopOmniboxSliding];
778 } 790 }
779 791
780 - (void)windowDidFailToExitFullScreen:(NSWindow*)window { 792 - (void)windowDidFailToExitFullScreen:(NSWindow*)window {
781 [self deregisterForContentViewResizeNotifications]; 793 [self deregisterForContentViewResizeNotifications];
782 794 exitingAppKitFullscreen_ = NO;
795 fullscreenTransition_.reset();
783 // Force a relayout to try and get the window back into a reasonable state. 796 // Force a relayout to try and get the window back into a reasonable state.
784 [self layoutSubviews]; 797 [self layoutSubviews];
785 } 798 }
786 799
787 - (void)enableBarVisibilityUpdates { 800 - (void)enableBarVisibilityUpdates {
788 // Early escape if there's nothing to do. 801 // Early escape if there's nothing to do.
789 if (barVisibilityUpdatesEnabled_) 802 if (barVisibilityUpdatesEnabled_)
790 return; 803 return;
791 804
792 barVisibilityUpdatesEnabled_ = YES; 805 barVisibilityUpdatesEnabled_ = YES;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 // We need to return where the button should be positioned. 882 // We need to return where the button should be positioned.
870 NSView* rootView = [[[self window] contentView] superview]; 883 NSView* rootView = [[[self window] contentView] superview];
871 if ([rootView respondsToSelector:@selector(_fullScreenButtonOrigin)]) 884 if ([rootView respondsToSelector:@selector(_fullScreenButtonOrigin)])
872 buttonFrame.origin = [rootView _fullScreenButtonOrigin]; 885 buttonFrame.origin = [rootView _fullScreenButtonOrigin];
873 886
874 return buttonFrame; 887 return buttonFrame;
875 } 888 }
876 889
877 - (void)updateLayoutParameters:(BrowserWindowLayout*)layout { 890 - (void)updateLayoutParameters:(BrowserWindowLayout*)layout {
878 [layout setContentViewSize:[[[self window] contentView] bounds].size]; 891 [layout setContentViewSize:[[[self window] contentView] bounds].size];
879 [layout setWindowSize:[[self window] frame].size]; 892
893 NSSize windowSize = (fullscreenTransition_.get())
894 ? [fullscreenTransition_ desiredWindowLayoutSize]
895 : [[self window] frame].size;
896
897 [layout setWindowSize:windowSize];
880 898
881 [layout setInAnyFullscreen:[self isInAnyFullscreenMode]]; 899 [layout setInAnyFullscreen:[self isInAnyFullscreenMode]];
882 [layout setFullscreenSlidingStyle: 900 [layout setFullscreenSlidingStyle:
883 presentationModeController_.get().slidingStyle]; 901 presentationModeController_.get().slidingStyle];
884 [layout setFullscreenMenubarOffset: 902 [layout setFullscreenMenubarOffset:
885 [presentationModeController_ menubarOffset]]; 903 [presentationModeController_ menubarOffset]];
886 [layout setFullscreenToolbarFraction: 904 [layout setFullscreenToolbarFraction:
887 [presentationModeController_ toolbarFraction]]; 905 [presentationModeController_ toolbarFraction]];
888 906
889 [layout setHasTabStrip:[self hasTabStrip]]; 907 [layout setHasTabStrip:[self hasTabStrip]];
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 1105
1088 return YES; 1106 return YES;
1089 } 1107 }
1090 1108
1091 - (NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow*)window { 1109 - (NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow*)window {
1092 DCHECK([window isEqual:self.window]); 1110 DCHECK([window isEqual:self.window]);
1093 1111
1094 if (![self shouldUseCustomAppKitFullscreenTransition]) 1112 if (![self shouldUseCustomAppKitFullscreenTransition])
1095 return nil; 1113 return nil;
1096 1114
1097 enterFullscreenTransition_.reset( 1115 FramedBrowserWindow* framedBrowserWindow =
1098 [[BrowserWindowEnterFullscreenTransition alloc] 1116 base::mac::ObjCCast<FramedBrowserWindow>([self window]);
1099 initWithWindow:self.window]); 1117 fullscreenTransition_.reset([[BrowserWindowFullscreenTransition alloc]
1100 return [enterFullscreenTransition_ customWindowsToEnterFullScreen]; 1118 initEnterWithWindow:framedBrowserWindow]);
1119 return [fullscreenTransition_ customWindowsForFullScreenTransition];
1120 }
1121
1122 - (NSArray*)customWindowsToExitFullScreenForWindow:(NSWindow*)window {
1123 DCHECK([window isEqual:self.window]);
1124
1125 if (![self shouldUseCustomAppKitFullscreenTransition])
1126 return nil;
1127
1128 FramedBrowserWindow* framedBrowserWindow =
1129 base::mac::ObjCCast<FramedBrowserWindow>([self window]);
1130 fullscreenTransition_.reset([[BrowserWindowFullscreenTransition alloc]
1131 initExitWithWindow:framedBrowserWindow
1132 frame:savedRegularWindowFrame_]);
1133
1134 return [fullscreenTransition_ customWindowsForFullScreenTransition];
1101 } 1135 }
1102 1136
1103 - (void)window:(NSWindow*)window 1137 - (void)window:(NSWindow*)window
1104 startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration { 1138 startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration {
1105 DCHECK([window isEqual:self.window]); 1139 DCHECK([window isEqual:self.window]);
1106 [enterFullscreenTransition_ 1140 [fullscreenTransition_ startCustomFullScreenAnimationWithDuration:duration];
1107 startCustomAnimationToEnterFullScreenWithDuration:duration]; 1141 }
1142
1143 - (void)window:(NSWindow*)window
1144 startCustomAnimationToExitFullScreenWithDuration:(NSTimeInterval)duration {
1145 DCHECK([window isEqual:self.window]);
1146
1147 [fullscreenTransition_ startCustomFullScreenAnimationWithDuration:duration];
1108 } 1148 }
1109 1149
1110 - (BOOL)shouldConstrainFrameRect { 1150 - (BOOL)shouldConstrainFrameRect {
1111 if ([enterFullscreenTransition_ shouldWindowBeUnconstrained]) 1151 if ([fullscreenTransition_ shouldWindowBeUnconstrained])
1112 return NO; 1152 return NO;
1113 1153
1114 return [super shouldConstrainFrameRect]; 1154 return [super shouldConstrainFrameRect];
1115 } 1155 }
1116 1156
1117 - (WebContents*)webContents { 1157 - (WebContents*)webContents {
1118 return browser_->tab_strip_model()->GetActiveWebContents(); 1158 return browser_->tab_strip_model()->GetActiveWebContents();
1119 } 1159 }
1120 1160
1121 - (PermissionBubbleManager*)permissionBubbleManager { 1161 - (PermissionBubbleManager*)permissionBubbleManager {
1122 if (WebContents* contents = [self webContents]) 1162 if (WebContents* contents = [self webContents])
1123 return PermissionBubbleManager::FromWebContents(contents); 1163 return PermissionBubbleManager::FromWebContents(contents);
1124 return nil; 1164 return nil;
1125 } 1165 }
1126 1166
1127 @end // @implementation BrowserWindowController(Private) 1167 @end // @implementation BrowserWindowController(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698