Chromium Code Reviews| 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..684dddd7dba21099b98cc30c99e268113136a9e4 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,46 @@ const float kMinimumAccelerationScreenRotation = 0.3f; |
| const float kRadiansToDegrees = 180.0f / 3.14159265f; |
| +// A message centre notification blocker used to suppress screen rotation |
|
flackr
2014/05/05 20:26:54
nit: s/centre/center
bruthig
2014/05/05 20:57:22
Done.
|
| +// events caused by accelerometer events |
| +class ScopedNotificationBlocker |
| + : public message_center::NotificationBlocker { |
| + public: |
| + ScopedNotificationBlocker(); |
| + |
|
flackr
2014/05/05 20:26:54
nit: no newline needed between constructor and des
bruthig
2014/05/05 20:57:22
Done.
|
| + 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()) { |
|
flackr
2014/05/05 20:26:54
nit: indent 4 more to show it's part of the previo
bruthig
2014/05/05 20:57:22
Done.
|
| + NotifyBlockingStateChanged(); |
| +} |
| + |
| +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) { |
| @@ -169,8 +211,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,9 +271,21 @@ 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); |
| } |
| } |
| +void MaximizeModeController::SetDisplayRotation( |
| + DisplayManager* display_manager, |
| + int64 display_id, |
| + gfx::Display::Rotation rotation) const { |
| + // 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 ash |