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

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: Fixed minor style nits. Created 6 years, 5 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: 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..c9082506320b663b4ed882d6275d952bbd3ec1e6 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;
}
@@ -31,7 +38,9 @@ class MaximizeModeWindowManagerTest;
// 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,
flackr 2014/07/29 16:41:45 nit: Move the : public AccelerometerObserver down
bruthig 2014/07/31 16:10:49 Done.
- public base::PowerObserver,
+#if defined(OS_CHROMEOS)
+ public chromeos::PowerManagerClient::Observer,
+#endif // OS_CHROMEOS
public ShellObserver,
public DisplayController::Observer {
public:
@@ -98,17 +107,26 @@ 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. Ownership of
+ // |tick_clock| is assumed by this.
+ void SetTickClockForTest(base::TickClock* tick_clock);
flackr 2014/07/29 16:41:45 nit: Pass in a scoped_ptr to ensure correct pointe
bruthig 2014/07/31 16:10:49 Done.
+
// 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 acceleromter readings as the lid is opened but the acceleromater
flackr 2014/07/29 16:41:45 nit: s/acceleromter/accelerometer nit: s/accelerom
bruthig 2014/07/31 16:10:49 Done.
+ // 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') | ash/wm/maximize_mode/maximize_mode_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698