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

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: 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..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,
« 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