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..8d1cde006187f6132928bb56ad9232320b50d219 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,45 @@ const float kMinimumAccelerationScreenRotation = 0.3f; |
const float kRadiansToDegrees = 180.0f / 3.14159265f; |
+// A message center notification blocker used to suppress screen rotation |
+// events caused by accelerometer events |
flackr
2014/05/05 21:12:12
nit: Punctuation.
bruthig
2014/05/08 17:50:02
Done.
|
+class ScopedNotificationBlocker |
+ : public message_center::NotificationBlocker { |
+ public: |
+ ScopedNotificationBlocker(); |
+ virtual ~ScopedNotificationBlocker(); |
+ |
+ private: |
+ // Overriden from message_center::NotificationBlocker. |
+ virtual bool ShouldShowNotificationAsPopup( |
+ const message_center::NotifierId& notifier_id) const OVERRIDE; |
+ |
+// Overriden from message_center::NotificationBlocker. |
+ virtual bool ShouldShowNotification( |
+ const message_center::NotifierId& notifier_id) const OVERRIDE; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ScopedNotificationBlocker); |
+}; |
+ |
+ScopedNotificationBlocker::ScopedNotificationBlocker() |
+ : message_center::NotificationBlocker( |
+ message_center::MessageCenter::Get()) { |
+ NotifyBlockingStateChanged(); |
flackr
2014/05/05 21:12:12
Will this cause us to remove other currently activ
bruthig
2014/05/08 17:50:02
Nope
bruthig
2014/05/08 17:50:02
Done.
|
+} |
+ |
+ScopedNotificationBlocker::~ScopedNotificationBlocker() { |
+} |
+ |
+bool ScopedNotificationBlocker::ShouldShowNotificationAsPopup( |
+ const message_center::NotifierId& notifier_id) const { |
+ return false; |
+} |
+ |
+bool ScopedNotificationBlocker::ShouldShowNotification( |
+ const message_center::NotifierId& notifier_id) const { |
+ return false; |
+} |
+ |
// Returns the angle between |base| and |other| in degrees. |
float AngleBetweenVectorsInDegrees(const gfx::Vector3dF& base, |
const gfx::Vector3dF& other) { |
@@ -79,6 +120,17 @@ float ClockwiseAngleBetweenVectorsInDegrees(const gfx::Vector3dF& base, |
return angle; |
} |
+// Sets the display's rotation. |
+void SetDisplayRotation(DisplayManager* display_manager, |
+ int64 display_id, |
+ gfx::Display::Rotation rotation) { |
+ // Suppress message centre notifications for screen rotations caused |
+ // by accelerometer events because it should be obvious why the orientation |
+ // changed. |
+ ScopedNotificationBlocker notification_blocker; |
+ display_manager->SetDisplayRotation(display_id, rotation); |
+} |
+ |
} // namespace |
MaximizeModeController::MaximizeModeController() |
@@ -169,8 +221,9 @@ void MaximizeModeController::HandleScreenRotation(const gfx::Vector3dF& lid) { |
// Also, SetDisplayRotation will save the setting to the local store, |
// this should be stored in a way that we can distinguish what the |
// rotation was set by. |
- display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), |
- gfx::Display::ROTATE_0); |
+ SetDisplayRotation(display_manager, |
+ gfx::Display::InternalDisplayId(), |
+ gfx::Display::ROTATE_0); |
} |
rotation_locked_ = false; |
return; |
@@ -228,8 +281,9 @@ void MaximizeModeController::HandleScreenRotation(const gfx::Vector3dF& lid) { |
// match screen orientation. |
if (new_rotation == gfx::Display::ROTATE_0 || |
maximize_mode_engaged) { |
- display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), |
- new_rotation); |
+ SetDisplayRotation(display_manager, |
+ gfx::Display::InternalDisplayId(), |
+ new_rotation); |
} |
} |