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

Unified Diff: ash/wm/maximize_mode/maximize_mode_controller.h

Issue 412013002: Prevent entering maximize mode when the lid is closed or has recently opened. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor sp nit fix. Created 6 years, 4 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 | « no previous file | ash/wm/maximize_mode/maximize_mode_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/maximize_mode/maximize_mode_controller.h
diff --git a/ash/wm/maximize_mode/maximize_mode_controller.h b/ash/wm/maximize_mode/maximize_mode_controller.h
index 54db3f3a48539de4f53fb4781960be6b52876918..4614bef141959fcdce7c6347f79e8abad6a67841 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller.h
+++ b/ash/wm/maximize_mode/maximize_mode_controller.h
@@ -13,9 +13,16 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
-#include "base/power_monitor/power_observer.h"
#include "ui/gfx/display.h"
+#if defined(OS_CHROMEOS)
+#include "chromeos/dbus/power_manager_client.h"
+#endif // OS_CHROMEOS
+
+namespace base {
+class TickClock;
+}
+
namespace ui {
class EventHandler;
}
@@ -30,10 +37,13 @@ class MaximizeModeWindowManagerTest;
// MaximizeModeController listens to accelerometer events and automatically
// enters and exits maximize mode when the lid is opened beyond the triggering
// angle and rotates the display to match the device when in maximize mode.
-class ASH_EXPORT MaximizeModeController : public AccelerometerObserver,
- public base::PowerObserver,
- public ShellObserver,
- public DisplayController::Observer {
+class ASH_EXPORT MaximizeModeController
+ : public AccelerometerObserver,
+#if defined(OS_CHROMEOS)
+ public chromeos::PowerManagerClient::Observer,
+#endif // OS_CHROMEOS
+ public ShellObserver,
+ public DisplayController::Observer {
public:
// Observer that reports changes to the state of MaximizeModeController's
// rotation lock.
@@ -98,17 +108,25 @@ class ASH_EXPORT MaximizeModeController : public AccelerometerObserver,
virtual void OnMaximizeModeStarted() OVERRIDE;
virtual void OnMaximizeModeEnded() OVERRIDE;
- // base::PowerObserver:
- virtual void OnSuspend() OVERRIDE;
- virtual void OnResume() OVERRIDE;
-
// DisplayController::Observer:
virtual void OnDisplayConfigurationChanged() OVERRIDE;
+#if defined(OS_CHROMEOS)
+ // PowerManagerClient::Observer:
+ virtual void LidEventReceived(bool open,
+ const base::TimeTicks& time) OVERRIDE;
+ virtual void SuspendImminent() OVERRIDE;
+ virtual void SuspendDone(const base::TimeDelta& sleep_duration) OVERRIDE;
+#endif // OS_CHROMEOS
+
private:
friend class MaximizeModeControllerTest;
friend class MaximizeModeWindowManagerTest;
+ // Set the TickClock. This is only to be used by tests that need to
+ // artificially and deterministically control the current time.
+ void SetTickClockForTest(scoped_ptr<base::TickClock> tick_clock);
+
// Detect hinge rotation from |base| and |lid| accelerometers and
// automatically start / stop maximize mode.
void HandleHingeRotation(const gfx::Vector3dF& base,
@@ -122,6 +140,9 @@ class ASH_EXPORT MaximizeModeController : public AccelerometerObserver,
void SetDisplayRotation(DisplayManager* display_manager,
gfx::Display::Rotation rotation);
+ // Returns true if the lid was recently opened.
+ bool WasLidOpenedRecently() const;
+
// Enables MaximizeModeWindowManager, and determines the current state of
// rotation lock.
void EnterMaximizeMode();
@@ -169,6 +190,17 @@ class ASH_EXPORT MaximizeModeController : public AccelerometerObserver,
base::TimeDelta total_touchview_time_;
base::TimeDelta total_non_touchview_time_;
+ // Tracks the last time we received a lid open event. This is used to suppress
+ // erroneous accelerometer readings as the lid is opened but the accelerometer
+ // reports readings that make the lid to appear near fully open.
+ base::TimeTicks last_lid_open_time_;
+
+ // Source for the current time in base::TimeTicks.
+ scoped_ptr<base::TickClock> tick_clock_;
+
+ // Tracks when the lid is closed. Used to prevent entering maximize mode.
+ bool lid_is_closed_;
+
DISALLOW_COPY_AND_ASSIGN(MaximizeModeController);
};
« no previous file with comments | « no previous file | ash/wm/maximize_mode/maximize_mode_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698