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

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: Made some changes according to missed comments on Patch 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 [self layoutSubviews];
erikchen 2015/08/12 22:08:52 Why is this necessary? Shouldn't all the subviews
spqchan1 2015/08/13 20:38:48 We want to make sure that the subviews are layout
771 browser_->WindowFullscreenStateChanged(); 777 browser_->WindowFullscreenStateChanged();
778
779 exitingAppKitFullscreen_ = NO;
780 fullscreenTransition_.reset();
772 } 781 }
773 782
774 - (void)windowDidFailToEnterFullScreen:(NSWindow*)window { 783 - (void)windowDidFailToEnterFullScreen:(NSWindow*)window {
775 [self deregisterForContentViewResizeNotifications]; 784 [self deregisterForContentViewResizeNotifications];
776 enteringAppKitFullscreen_ = NO; 785 enteringAppKitFullscreen_ = NO;
786 fullscreenTransition_.reset();
777 [self adjustUIForExitingFullscreenAndStopOmniboxSliding]; 787 [self adjustUIForExitingFullscreenAndStopOmniboxSliding];
778 } 788 }
779 789
780 - (void)windowDidFailToExitFullScreen:(NSWindow*)window { 790 - (void)windowDidFailToExitFullScreen:(NSWindow*)window {
781 [self deregisterForContentViewResizeNotifications]; 791 [self deregisterForContentViewResizeNotifications];
782 792 exitingAppKitFullscreen_ = NO;
793 fullscreenTransition_.reset();
783 // Force a relayout to try and get the window back into a reasonable state. 794 // Force a relayout to try and get the window back into a reasonable state.
784 [self layoutSubviews]; 795 [self layoutSubviews];
785 } 796 }
786 797
787 - (void)enableBarVisibilityUpdates { 798 - (void)enableBarVisibilityUpdates {
788 // Early escape if there's nothing to do. 799 // Early escape if there's nothing to do.
789 if (barVisibilityUpdatesEnabled_) 800 if (barVisibilityUpdatesEnabled_)
790 return; 801 return;
791 802
792 barVisibilityUpdatesEnabled_ = YES; 803 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. 880 // We need to return where the button should be positioned.
870 NSView* rootView = [[[self window] contentView] superview]; 881 NSView* rootView = [[[self window] contentView] superview];
871 if ([rootView respondsToSelector:@selector(_fullScreenButtonOrigin)]) 882 if ([rootView respondsToSelector:@selector(_fullScreenButtonOrigin)])
872 buttonFrame.origin = [rootView _fullScreenButtonOrigin]; 883 buttonFrame.origin = [rootView _fullScreenButtonOrigin];
873 884
874 return buttonFrame; 885 return buttonFrame;
875 } 886 }
876 887
877 - (void)updateLayoutParameters:(BrowserWindowLayout*)layout { 888 - (void)updateLayoutParameters:(BrowserWindowLayout*)layout {
878 [layout setContentViewSize:[[[self window] contentView] bounds].size]; 889 [layout setContentViewSize:[[[self window] contentView] bounds].size];
879 [layout setWindowSize:[[self window] frame].size]; 890
891 NSSize windowSize = (fullscreenTransition_.get())
892 ? [fullscreenTransition_ getDesiredWindowLayoutSize]
893 : [[self window] frame].size;
894
895 [layout setWindowSize:windowSize];
880 896
881 [layout setInAnyFullscreen:[self isInAnyFullscreenMode]]; 897 [layout setInAnyFullscreen:[self isInAnyFullscreenMode]];
882 [layout setFullscreenSlidingStyle: 898 [layout setFullscreenSlidingStyle:
883 presentationModeController_.get().slidingStyle]; 899 presentationModeController_.get().slidingStyle];
884 [layout setFullscreenMenubarOffset: 900 [layout setFullscreenMenubarOffset:
885 [presentationModeController_ menubarOffset]]; 901 [presentationModeController_ menubarOffset]];
886 [layout setFullscreenToolbarFraction: 902 [layout setFullscreenToolbarFraction:
887 [presentationModeController_ toolbarFraction]]; 903 [presentationModeController_ toolbarFraction]];
888 904
889 [layout setHasTabStrip:[self hasTabStrip]]; 905 [layout setHasTabStrip:[self hasTabStrip]];
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 1103
1088 return YES; 1104 return YES;
1089 } 1105 }
1090 1106
1091 - (NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow*)window { 1107 - (NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow*)window {
1092 DCHECK([window isEqual:self.window]); 1108 DCHECK([window isEqual:self.window]);
1093 1109
1094 if (![self shouldUseCustomAppKitFullscreenTransition]) 1110 if (![self shouldUseCustomAppKitFullscreenTransition])
1095 return nil; 1111 return nil;
1096 1112
1097 enterFullscreenTransition_.reset( 1113 FramedBrowserWindow* framedBrowserWindow =
1098 [[BrowserWindowEnterFullscreenTransition alloc] 1114 base::mac::ObjCCast<FramedBrowserWindow>([self window]);
1099 initWithWindow:self.window]); 1115 fullscreenTransition_.reset([[BrowserWindowFullscreenTransition alloc]
1100 return [enterFullscreenTransition_ customWindowsToEnterFullScreen]; 1116 initEnterWithWindow:framedBrowserWindow]);
1117 return [fullscreenTransition_ customWindowsForFullScreenTransition];
1118 }
1119
1120 - (NSArray*)customWindowsToExitFullScreenForWindow:(NSWindow*)window {
1121 DCHECK([window isEqual:self.window]);
1122
1123 if (![self shouldUseCustomAppKitFullscreenTransition])
1124 return nil;
1125
1126 FramedBrowserWindow* framedBrowserWindow =
1127 base::mac::ObjCCast<FramedBrowserWindow>([self window]);
1128 fullscreenTransition_.reset([[BrowserWindowFullscreenTransition alloc]
1129 initExitWithWindow:framedBrowserWindow
1130 frame:savedRegularWindowFrame_]);
1131
1132 return [fullscreenTransition_ customWindowsForFullScreenTransition];
1101 } 1133 }
1102 1134
1103 - (void)window:(NSWindow*)window 1135 - (void)window:(NSWindow*)window
1104 startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration { 1136 startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration {
1105 DCHECK([window isEqual:self.window]); 1137 DCHECK([window isEqual:self.window]);
1106 [enterFullscreenTransition_ 1138 [fullscreenTransition_ startCustomFullScreenAnimationWithDuration:duration];
1107 startCustomAnimationToEnterFullScreenWithDuration:duration]; 1139 }
1140
1141 - (void)window:(NSWindow*)window
1142 startCustomAnimationToExitFullScreenWithDuration:(NSTimeInterval)duration {
1143 DCHECK([window isEqual:self.window]);
1144
1145 [fullscreenTransition_ startCustomFullScreenAnimationWithDuration:duration];
1108 } 1146 }
1109 1147
1110 - (BOOL)shouldConstrainFrameRect { 1148 - (BOOL)shouldConstrainFrameRect {
1111 if ([enterFullscreenTransition_ shouldWindowBeUnconstrained]) 1149 if ([fullscreenTransition_ shouldWindowBeUnconstrained])
1112 return NO; 1150 return NO;
1113 1151
1114 return [super shouldConstrainFrameRect]; 1152 return [super shouldConstrainFrameRect];
1115 } 1153 }
1116 1154
1117 - (WebContents*)webContents { 1155 - (WebContents*)webContents {
1118 return browser_->tab_strip_model()->GetActiveWebContents(); 1156 return browser_->tab_strip_model()->GetActiveWebContents();
1119 } 1157 }
1120 1158
1121 - (PermissionBubbleManager*)permissionBubbleManager { 1159 - (PermissionBubbleManager*)permissionBubbleManager {
1122 if (WebContents* contents = [self webContents]) 1160 if (WebContents* contents = [self webContents])
1123 return PermissionBubbleManager::FromWebContents(contents); 1161 return PermissionBubbleManager::FromWebContents(contents);
1124 return nil; 1162 return nil;
1125 } 1163 }
1126 1164
1127 @end // @implementation BrowserWindowController(Private) 1165 @end // @implementation BrowserWindowController(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698