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

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

Issue 267743010: Suppressed screen rotation notifications triggeres by the accelerometer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Rob's comments from patch set 2 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
« no previous file with comments | « no previous file | ash/wm/maximize_mode/maximize_mode_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « no previous file | ash/wm/maximize_mode/maximize_mode_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698