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

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

Issue 1990163003: Mac fullscreen low power: Add layout interactions and flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add nil check for tests Created 4 years, 7 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 #import "base/auto_reset.h" 9 #import "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 13 matching lines...) Expand all
24 #import "chrome/browser/ui/cocoa/browser_window_fullscreen_transition.h" 24 #import "chrome/browser/ui/cocoa/browser_window_fullscreen_transition.h"
25 #import "chrome/browser/ui/cocoa/browser_window_layout.h" 25 #import "chrome/browser/ui/cocoa/browser_window_layout.h"
26 #import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h" 26 #import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h"
27 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h" 27 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con troller.h"
28 #import "chrome/browser/ui/cocoa/custom_frame_view.h" 28 #import "chrome/browser/ui/cocoa/custom_frame_view.h"
29 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" 29 #import "chrome/browser/ui/cocoa/dev_tools_controller.h"
30 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 30 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
31 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" 31 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
32 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h" 32 #import "chrome/browser/ui/cocoa/floating_bar_backing_view.h"
33 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 33 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
34 #include "chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.h"
34 #import "chrome/browser/ui/cocoa/fullscreen_window.h" 35 #import "chrome/browser/ui/cocoa/fullscreen_window.h"
35 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" 36 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
36 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" 37 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h"
37 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" 38 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h"
38 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h" 39 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h"
39 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h" 40 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h"
40 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" 41 #import "chrome/browser/ui/cocoa/status_bubble_mac.h"
41 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" 42 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h"
42 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" 43 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
43 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 44 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 787
787 // If the custom transition isn't complete, then just set the flag and 788 // If the custom transition isn't complete, then just set the flag and
788 // return. Once the transition is completed, windowDidExitFullscreen will 789 // return. Once the transition is completed, windowDidExitFullscreen will
789 // be called again. 790 // be called again.
790 if (isUsingCustomAnimation_ && 791 if (isUsingCustomAnimation_ &&
791 ![fullscreenTransition_ isTransitionCompleted]) { 792 ![fullscreenTransition_ isTransitionCompleted]) {
792 appKitDidExitFullscreen_ = YES; 793 appKitDidExitFullscreen_ = YES;
793 return; 794 return;
794 } 795 }
795 796
797 // Destroy the NSWindow used for fullscreen low power mode.
798 fullscreenLowPowerCoordinator_.reset();
799
796 if (notification) // For System Fullscreen when non-nil. 800 if (notification) // For System Fullscreen when non-nil.
797 [self deregisterForContentViewResizeNotifications]; 801 [self deregisterForContentViewResizeNotifications];
798 802
799 browser_->WindowFullscreenStateChanged(); 803 browser_->WindowFullscreenStateChanged();
800 [self.chromeContentView setAutoresizesSubviews:YES]; 804 [self.chromeContentView setAutoresizesSubviews:YES];
801 805
802 [self resetCustomAppKitFullscreenVariables]; 806 [self resetCustomAppKitFullscreenVariables];
803 807
804 // Ensures that the permission bubble shows up properly at the front. 808 // Ensures that the permission bubble shows up properly at the front.
805 PermissionBubbleManager* manager = [self permissionBubbleManager]; 809 PermissionBubbleManager* manager = [self permissionBubbleManager];
806 if (manager && manager->IsBubbleVisible()) { 810 if (manager && manager->IsBubbleVisible()) {
807 NSWindow* bubbleWindow = manager->GetBubbleWindow(); 811 NSWindow* bubbleWindow = manager->GetBubbleWindow();
808 DCHECK(bubbleWindow); 812 DCHECK(bubbleWindow);
809 [bubbleWindow orderFront:nil]; 813 [bubbleWindow orderFront:nil];
810 } 814 }
811 815
812 // Ensure that the window is layout properly. 816 // Ensure that the window is layout properly.
813 [self layoutSubviews]; 817 [self layoutSubviews];
814 } 818 }
815 819
816 - (void)windowDidFailToEnterFullScreen:(NSWindow*)window { 820 - (void)windowDidFailToEnterFullScreen:(NSWindow*)window {
817 [self deregisterForContentViewResizeNotifications]; 821 [self deregisterForContentViewResizeNotifications];
818 [self resetCustomAppKitFullscreenVariables]; 822 [self resetCustomAppKitFullscreenVariables];
819 [self adjustUIForExitingFullscreenAndStopOmniboxSliding]; 823 [self adjustUIForExitingFullscreenAndStopOmniboxSliding];
824 fullscreenLowPowerCoordinator_.reset();
820 } 825 }
821 826
822 - (void)windowDidFailToExitFullScreen:(NSWindow*)window { 827 - (void)windowDidFailToExitFullScreen:(NSWindow*)window {
823 [self deregisterForContentViewResizeNotifications]; 828 [self deregisterForContentViewResizeNotifications];
824 [self resetCustomAppKitFullscreenVariables]; 829 [self resetCustomAppKitFullscreenVariables];
825 830
826 // Force a relayout to try and get the window back into a reasonable state. 831 // Force a relayout to try and get the window back into a reasonable state.
827 [self layoutSubviews]; 832 [self layoutSubviews];
828 } 833 }
829 834
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 [floatingBarBackingView_ setFrame:output.fullscreenBackingBarFrame]; 1029 [floatingBarBackingView_ setFrame:output.fullscreenBackingBarFrame];
1025 [presentationModeController_ 1030 [presentationModeController_
1026 overlayFrameChanged:output.fullscreenBackingBarFrame]; 1031 overlayFrameChanged:output.fullscreenBackingBarFrame];
1027 } 1032 }
1028 1033
1029 [findBarCocoaController_ 1034 [findBarCocoaController_
1030 positionFindBarViewAtMaxY:output.findBarMaxY 1035 positionFindBarViewAtMaxY:output.findBarMaxY
1031 maxWidth:NSWidth(output.contentAreaFrame)]; 1036 maxWidth:NSWidth(output.contentAreaFrame)];
1032 1037
1033 exclusiveAccessController_->Layout(output.fullscreenExitButtonMaxY); 1038 exclusiveAccessController_->Layout(output.fullscreenExitButtonMaxY);
1039
1040 if (fullscreenLowPowerCoordinator_) {
1041 fullscreenLowPowerCoordinator_->SetLayoutParameters(
1042 output.toolbarFrame, output.infoBarFrame, output.contentAreaFrame,
1043 output.downloadShelfFrame);
1044 }
1034 } 1045 }
1035 1046
1036 - (void)updateSubviewZOrder { 1047 - (void)updateSubviewZOrder {
1037 if ([self isInAnyFullscreenMode]) 1048 if ([self isInAnyFullscreenMode])
1038 [self updateSubviewZOrderFullscreen]; 1049 [self updateSubviewZOrderFullscreen];
1039 else 1050 else
1040 [self updateSubviewZOrderNormal]; 1051 [self updateSubviewZOrderNormal];
1041 } 1052 }
1042 1053
1043 - (void)updateSubviewZOrderNormal { 1054 - (void)updateSubviewZOrderNormal {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 exitingAppKitFullscreen_ = NO; 1188 exitingAppKitFullscreen_ = NO;
1178 isUsingCustomAnimation_ = NO; 1189 isUsingCustomAnimation_ = NO;
1179 } 1190 }
1180 1191
1181 - (NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow*)window { 1192 - (NSArray*)customWindowsToEnterFullScreenForWindow:(NSWindow*)window {
1182 DCHECK([window isEqual:self.window]); 1193 DCHECK([window isEqual:self.window]);
1183 1194
1184 if (![self shouldUseCustomAppKitFullscreenTransition:YES]) 1195 if (![self shouldUseCustomAppKitFullscreenTransition:YES])
1185 return nil; 1196 return nil;
1186 1197
1198 WebContents* webContents = [self webContents];
1199 NSWindow* lowPowerWindow = nil;
1200 if (webContents) {
1201 fullscreenLowPowerCoordinator_.reset(new FullscreenLowPowerCoordinatorCocoa(
1202 [self window],
1203 webContents->GetRenderWidgetHostView()->GetAcceleratedWidgetMac()));
1204 lowPowerWindow =
1205 fullscreenLowPowerCoordinator_->GetFullscreenLowPowerWindow();
1206 }
1207
1187 fullscreenTransition_.reset( 1208 fullscreenTransition_.reset(
1188 [[BrowserWindowFullscreenTransition alloc] initEnterWithController:self]); 1209 [[BrowserWindowFullscreenTransition alloc] initEnterWithController:self]);
1189 1210
1190 NSArray* customWindows = 1211 NSArray* customWindows =
1191 [fullscreenTransition_ customWindowsForFullScreenTransition]; 1212 [fullscreenTransition_ customWindowsForFullScreenTransition];
1213 if (customWindows && lowPowerWindow)
1214 customWindows = [customWindows arrayByAddingObject:lowPowerWindow];
1215 else
1216 fullscreenLowPowerCoordinator_.reset();
1217
1192 isUsingCustomAnimation_ = customWindows != nil; 1218 isUsingCustomAnimation_ = customWindows != nil;
1193 return customWindows; 1219 return customWindows;
1194 } 1220 }
1195 1221
1196 - (NSArray*)customWindowsToExitFullScreenForWindow:(NSWindow*)window { 1222 - (NSArray*)customWindowsToExitFullScreenForWindow:(NSWindow*)window {
1197 DCHECK([window isEqual:self.window]); 1223 DCHECK([window isEqual:self.window]);
1198 1224
1199 if (![self shouldUseCustomAppKitFullscreenTransition:NO]) 1225 if (![self shouldUseCustomAppKitFullscreenTransition:NO])
1200 return nil; 1226 return nil;
1201 1227
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 } 1268 }
1243 1269
1244 - (BOOL)isFullscreenForTabContentOrExtension { 1270 - (BOOL)isFullscreenForTabContentOrExtension {
1245 FullscreenController* controller = 1271 FullscreenController* controller =
1246 browser_->exclusive_access_manager()->fullscreen_controller(); 1272 browser_->exclusive_access_manager()->fullscreen_controller();
1247 return controller->IsWindowFullscreenForTabOrPending() || 1273 return controller->IsWindowFullscreenForTabOrPending() ||
1248 controller->IsExtensionFullscreenOrPending(); 1274 controller->IsExtensionFullscreenOrPending();
1249 } 1275 }
1250 1276
1251 @end // @implementation BrowserWindowController(Private) 1277 @end // @implementation BrowserWindowController(Private)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.mm ('k') | chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698