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

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

Issue 303723003: Lock Rotation on user settings changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 fd2efe5acb13e105eb3e53964619082c9c17cac3..4bd818cb6ae28cb2ac551fbf7e8fbe9f00d3a312 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller.h
+++ b/ash/wm/maximize_mode/maximize_mode_controller.h
@@ -7,9 +7,11 @@
#include "ash/accelerometer/accelerometer_observer.h"
#include "ash/ash_export.h"
+#include "ash/display/display_controller.h"
#include "ash/display/display_manager.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
+#include "base/observer_list.h"
#include "ui/gfx/display.h"
namespace ui {
@@ -24,8 +26,20 @@ class MaximizeModeEventBlocker;
// 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 {
+class ASH_EXPORT MaximizeModeController : public AccelerometerObserver,
+ public DisplayController::Observer {
public:
+ // Observer that reports changes to the state of MaximizeModeController's
+ // rotation lock.
+ class Observer {
+ public:
+ // Invoked whenever |rotation_locked_| is changed.
+ virtual void OnRotationLockChanged(bool rotation_locked) {}
+
+ protected:
+ virtual ~Observer() {}
+ };
+
MaximizeModeController();
virtual ~MaximizeModeController();
@@ -41,9 +55,11 @@ class ASH_EXPORT MaximizeModeController : public AccelerometerObserver {
// If |rotation_locked| future calls to OnAccelerometerUpdated will not
// change the display rotation.
- void set_rotation_locked(bool rotation_locked) {
- rotation_locked_ = rotation_locked;
- }
+ void SetRotationLocked(bool rotation_locked);
+
+ // Add/Remove observers.
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
// True if it is possible to enter maximize mode in the current
// configuration. If this returns false, it should never be the case that
@@ -54,6 +70,9 @@ class ASH_EXPORT MaximizeModeController : public AccelerometerObserver {
virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base,
const gfx::Vector3dF& lid) OVERRIDE;
+ // DisplayController::Observer:
+ virtual void OnDisplayConfigurationChanged() OVERRIDE;
+
private:
friend class MaximizeModeControllerTest;
@@ -98,6 +117,14 @@ class ASH_EXPORT MaximizeModeController : public AccelerometerObserver {
// restored upon exiting maximize mode.
gfx::Display::Rotation user_rotation_;
+ // The current rotation set by MaximizeModeController for the internal
+ // display. Compared in OnDisplayConfigurationChanged to determine user
+ // display setting changes.
+ gfx::Display::Rotation current_rotation_;
+
+ // Rotation Lock observers.
+ ObserverList<Observer> observers_;
+
DISALLOW_COPY_AND_ASSIGN(MaximizeModeController);
};

Powered by Google App Engine
This is Rietveld 408576698