| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_ | 5 #ifndef ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_ |
| 6 #define ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_ | 6 #define ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "chromeos/accelerometer/accelerometer_reader.h" | 12 #include "chromeos/accelerometer/accelerometer_reader.h" |
| 13 #include "ui/gfx/display.h" | 13 #include "ui/gfx/display.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class TaskRunner; | 16 class TaskRunner; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace athena { | 19 namespace athena { |
| 20 | 20 |
| 21 // Monitors accelerometers, detecting orientation changes. When a change is | 21 // Monitors accelerometers, detecting orientation changes. When a change is |
| 22 // detected rotates the root window to match. | 22 // detected rotates the root window to match. |
| 23 class OrientationController | 23 class OrientationController : public chromeos::AccelerometerReader::Observer { |
| 24 : public chromeos::AccelerometerReader::Delegate { | |
| 25 public: | 24 public: |
| 26 OrientationController(); | 25 OrientationController(); |
| 27 ~OrientationController() override; | 26 ~OrientationController() override; |
| 28 | 27 |
| 29 void InitWith(scoped_refptr<base::TaskRunner> blocking_task_runner); | 28 void InitWith(scoped_refptr<base::TaskRunner> blocking_task_runner); |
| 30 void Shutdown(); | 29 void Shutdown(); |
| 31 | 30 |
| 32 // chromeos::AccelerometerReader::Delegate | 31 // chromeos::AccelerometerReader::Observer: |
| 33 virtual void HandleAccelerometerUpdate( | 32 void OnAccelerometerUpdated(const ui::AccelerometerUpdate& update) override; |
| 34 const ui::AccelerometerUpdate& update) override; | |
| 35 | 33 |
| 36 private: | 34 private: |
| 37 // The last configured rotation. | 35 // The last configured rotation. |
| 38 gfx::Display::Rotation current_rotation_; | 36 gfx::Display::Rotation current_rotation_; |
| 39 | 37 |
| 40 scoped_ptr<chromeos::AccelerometerReader> accelerometer_reader_; | 38 scoped_ptr<chromeos::AccelerometerReader> accelerometer_reader_; |
| 41 | 39 |
| 42 DISALLOW_COPY_AND_ASSIGN(OrientationController); | 40 DISALLOW_COPY_AND_ASSIGN(OrientationController); |
| 43 }; | 41 }; |
| 44 | 42 |
| 45 } // namespace athena | 43 } // namespace athena |
| 46 | 44 |
| 47 #endif // ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_ | 45 #endif // ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_ |
| OLD | NEW |