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

Unified Diff: chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
+ 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];
« no previous file with comments | « chrome/browser/ui/cocoa/fullscreen_low_power_coordinator.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698