OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_ |
| 6 #define ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_ |
| 7 |
| 8 #include "athena/system/device_socket_listener.h" |
| 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "ui/gfx/display.h" |
| 13 |
| 14 namespace base { |
| 15 class FilePath; |
| 16 class FilePathWatcher; |
| 17 } |
| 18 |
| 19 namespace athena { |
| 20 |
| 21 // Monitors accelerometers, detecting orientation changes. When a change is |
| 22 // detected rotates the root window to match. |
| 23 class OrientationController : public DeviceSocketListener { |
| 24 public: |
| 25 OrientationController(); |
| 26 virtual ~OrientationController(); |
| 27 |
| 28 private: |
| 29 // Overridden from device::DeviceSocketListener: |
| 30 virtual void OnDataAvailableOnIO(const void* data) OVERRIDE; |
| 31 |
| 32 // Rotates the display to |rotation|, called on the UI thread. |
| 33 void RotateOnUI(gfx::Display::Rotation rotation); |
| 34 |
| 35 // Dispatched when the socket path is created. This is used at startup when |
| 36 // the socket file has not yet been created. |
| 37 void OnFilePathChanged(const base::FilePath& path, bool error); |
| 38 |
| 39 // The last configured rotation. |
| 40 gfx::Display::Rotation current_rotation_; |
| 41 |
| 42 // The timestamp of the last applied orientation change. |
| 43 int64_t last_orientation_change_time_; |
| 44 |
| 45 // The file watcher which detects when the orientation socket file created. |
| 46 scoped_ptr<base::FilePathWatcher> watcher_; |
| 47 |
| 48 base::WeakPtrFactory<OrientationController> weak_factory_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(OrientationController); |
| 51 }; |
| 52 |
| 53 } // namespace athena |
| 54 |
| 55 #endif // ATHENA_SYSTEM_ORIENTATION_CONTROLLER_H_ |
OLD | NEW |