Index: ash/wm/maximize_mode/maximize_mode_controller.cc |
diff --git a/ash/wm/maximize_mode/maximize_mode_controller.cc b/ash/wm/maximize_mode/maximize_mode_controller.cc |
index 0b9ee53b06e85477423adfcb9065b2fec5f046e2..29965955c3b3589b82bc1d11b762d99492f17902 100644 |
--- a/ash/wm/maximize_mode/maximize_mode_controller.cc |
+++ b/ash/wm/maximize_mode/maximize_mode_controller.cc |
@@ -9,6 +9,8 @@ |
#include "ash/shell.h" |
#include "ash/wm/maximize_mode/maximize_mode_event_blocker.h" |
#include "ui/gfx/vector3d_f.h" |
+#include "ui/message_center/message_center.h" |
+#include "ui/message_center/notification_blocker.h" |
namespace ash { |
@@ -56,6 +58,36 @@ const float kMinimumAccelerationScreenRotation = 0.3f; |
const float kRadiansToDegrees = 180.0f / 3.14159265f; |
+// A message centre notification blocker used to suppress screen rotation |
+// events caused by accelerometer events |
+class ScreenRotationNotificationBlocker |
flackr
2014/05/05 19:06:00
nit: Just call this ScopedNotificationBlocker. It
bruthig
2014/05/05 19:35:35
Done.
|
+ : public message_center::NotificationBlocker { |
+ public: |
+ ScreenRotationNotificationBlocker() |
flackr
2014/05/05 19:06:00
nit: I don't think any of these methods should be
bruthig
2014/05/05 19:35:35
Done.
|
+ : message_center::NotificationBlocker( |
+ message_center::MessageCenter::Get()) { |
+ NotifyBlockingStateChanged(); |
+ } |
+ |
+ virtual ~ScreenRotationNotificationBlocker() { |
+ }; |
+ |
+ private: |
+ // Overriden from message_center::NotificationBlocker. |
+ virtual bool ShouldShowNotificationAsPopup( |
+ const message_center::NotifierId& notifier_id) const OVERRIDE { |
+ return false; |
+ } |
+ |
+// Overriden from message_center::NotificationBlocker. |
+ virtual bool ShouldShowNotification( |
+ const message_center::NotifierId& notifier_id) const OVERRIDE { |
+ return false; |
+ } |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ScreenRotationNotificationBlocker); |
+}; |
+ |
// Returns the angle between |base| and |other| in degrees. |
float AngleBetweenVectorsInDegrees(const gfx::Vector3dF& base, |
const gfx::Vector3dF& other) { |
@@ -107,7 +139,13 @@ void MaximizeModeController::OnAccelerometerUpdated( |
// Responding to the hinge rotation can change the maximize mode state which |
// affects screen rotation, so we handle hinge rotation first. |
HandleHingeRotation(base, lid); |
- HandleScreenRotation(lid); |
+ { |
+ // Suppress message centre notifications for screen rotations caused |
+ // by accelerometer events because it should be obvious why the orientation |
+ // changed. |
+ ScreenRotationNotificationBlocker notification_blocker; |
flackr
2014/05/05 19:06:00
This method (OnAccelerometerUpdated) is called fai
bruthig
2014/05/05 19:35:35
Done.
|
+ HandleScreenRotation(lid); |
+ } |
} |
void MaximizeModeController::HandleHingeRotation(const gfx::Vector3dF& base, |