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 17c64d1cf6841f2ad56eca335ba37444f700dd3c..a7e9e812bea62a7ff4faa8a960d5c4ae8b737610 100644 |
| --- a/chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.mm |
| +++ b/chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.mm |
| @@ -4,9 +4,6 @@ |
| #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_; |
| } |
| @@ -127,12 +124,17 @@ - (void)sendEvent:(NSEvent*)event { |
| // Don't make any assumptions about other child windows. |
| allowed_by_child_windows_ = false; |
| - return; |
| + break; |
| } |
| + |
| + EnterOrExitLowPowerModeIfNeeded(); |
|
ccameron
2016/06/08 03:47:18
Oops -- I didn't notice this bug until I wrote a t
|
| } |
| void FullscreenLowPowerCoordinatorCocoa::SetLowPowerLayerValid(bool valid) { |
| - low_power_layer_valid_ = valid; |
| + if (valid) |
| + low_power_layer_valid_frame_count_ += 1; |
| + else |
| + low_power_layer_valid_frame_count_ = 0; |
| EnterOrExitLowPowerModeIfNeeded(); |
| } |
| @@ -144,15 +146,13 @@ - (void)sendEvent:(NSEvent*)event { |
| } |
| void FullscreenLowPowerCoordinatorCocoa::EnterOrExitLowPowerModeIfNeeded() { |
| - static bool enabled_at_command_line = |
| - base::CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kEnableFullscreenLowPowerMode); |
| + const uint64_t kMinValidFrames = 15; |
|
spqchan
2016/06/08 21:43:58
Put this as a constant at the top of the file.
ccameron
2016/06/09 20:47:08
Done.
|
| bool new_in_low_power_mode = |
| - widget_ && low_power_window_ && low_power_layer_valid_ && |
| - allowed_by_fullscreen_transition_ && |
| - allowed_by_nsview_layout_ && allowed_by_child_windows_ && |
| - allowed_by_active_sheet_ && enabled_at_command_line; |
| + widget_ && low_power_window_ && |
| + low_power_layer_valid_frame_count_ > kMinValidFrames && |
| + allowed_by_fullscreen_transition_ && allowed_by_nsview_layout_ && |
| + allowed_by_child_windows_ && allowed_by_active_sheet_; |
| if (new_in_low_power_mode) { |
| // Update whether or not we are in low power mode based on whether or not |