Chromium Code Reviews| Index: chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.mm |
| diff --git a/chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.mm b/chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.mm |
| index 28e52a5b33e2f3cbad1bf99276b6123c754117a2..44a60c84896cff8ac1e2b4e42d7040833a4c1a73 100644 |
| --- a/chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.mm |
| +++ b/chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.mm |
| @@ -4,6 +4,9 @@ |
| #include "chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.h" |
| +#include "base/command_line.h" |
| +#include "chrome/common/chrome_switches.h" |
| + |
| @interface FullscreenLowPowerWindow : NSWindow { |
| base::scoped_nsobject<NSWindow> eventTargetWindow_; |
| } |
| @@ -68,14 +71,27 @@ - (void)sendEvent:(NSEvent*)event { |
| return low_power_window_.get(); |
| } |
| -void FullscreenLowPowerCoordinatorCocoa::AddLowPowerModeSuppression() { |
| - suppression_count_ += 1; |
| - EnterOrExitLowPowerModeIfNeeded(); |
| -} |
| +void FullscreenLowPowerCoordinatorCocoa::SetLayoutParameters( |
| + const NSRect& toolbar_frame, |
|
spqchan
2016/05/20 00:22:24
Is it alright if "Hide Toolbar in Full Screen" tri
ccameron
2016/05/20 00:33:23
Yes. This actually allows triggering fullscreen lo
|
| + const NSRect& infobar_frame, |
| + const NSRect& content_frame, |
| + const NSRect& download_shelf_frame) { |
| + NSRect screen_frame = [[content_window_ screen] frame]; |
| + allowed_by_nsview_layout_ = true; |
| + |
| + // The toolbar and infobar must be above the top of the screen. |
| + allowed_by_nsview_layout_ &= |
| + toolbar_frame.origin.y >= screen_frame.size.height; |
| + allowed_by_nsview_layout_ &= |
| + infobar_frame.origin.y >= screen_frame.size.height; |
| + |
| + // The content rect must equal the screen's rect. |
| + allowed_by_nsview_layout_ &= NSEqualRects(content_frame, screen_frame); |
| + |
| + // The download shelf must not extend on to the screen. |
| + allowed_by_nsview_layout_ &= |
| + download_shelf_frame.origin.y + download_shelf_frame.size.height <= 0; |
| -void FullscreenLowPowerCoordinatorCocoa::RemoveLowPowerModeSuppression() { |
| - DCHECK(suppression_count_ > 0); |
| - suppression_count_ -= 1; |
| EnterOrExitLowPowerModeIfNeeded(); |
| } |
| @@ -92,8 +108,14 @@ - (void)sendEvent:(NSEvent*)event { |
| } |
| void FullscreenLowPowerCoordinatorCocoa::EnterOrExitLowPowerModeIfNeeded() { |
| - bool new_in_low_power_mode = widget_ && low_power_window_ && |
| - !suppression_count_ && low_power_layer_valid_; |
| + static bool enabled_at_command_line = |
| + base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableFullscreenLowPowerMode); |
| + |
| + bool new_in_low_power_mode = |
| + widget_ && low_power_window_ && allowed_by_nsview_layout_ && |
| + low_power_layer_valid_ && enabled_at_command_line; |
| + |
| if (new_in_low_power_mode) { |
| if (!in_low_power_mode_) { |
| [low_power_window_ setFrame:[content_window_ frame] display:YES]; |