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

Unified Diff: chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.mm

Issue 2047103003: Mac fullscreen low power: Add unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698