| 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 ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ | 5 #ifndef ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ |
| 6 #define ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ | 6 #define ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
| 11 #include "ash/common/shell_observer.h" | 11 #include "ash/common/shell_observer.h" |
| 12 #include "ash/display/window_tree_host_manager.h" | 12 #include "ash/common/wm_activation_observer.h" |
| 13 #include "ash/common/wm_display_observer.h" |
| 14 #include "ash/common/wm_window_observer.h" |
| 13 #include "base/macros.h" | 15 #include "base/macros.h" |
| 14 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 15 #include "chromeos/accelerometer/accelerometer_reader.h" | 17 #include "chromeos/accelerometer/accelerometer_reader.h" |
| 16 #include "chromeos/accelerometer/accelerometer_types.h" | 18 #include "chromeos/accelerometer/accelerometer_types.h" |
| 17 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree
nOrientationLockType.h" | 19 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree
nOrientationLockType.h" |
| 18 #include "ui/aura/window_observer.h" | |
| 19 #include "ui/display/display.h" | 20 #include "ui/display/display.h" |
| 20 #include "ui/wm/public/activation_change_observer.h" | |
| 21 | |
| 22 namespace aura { | |
| 23 class Window; | |
| 24 } | |
| 25 | 21 |
| 26 namespace ash { | 22 namespace ash { |
| 27 | 23 |
| 28 // Implements ChromeOS specific functionality for ScreenOrientationProvider. | 24 // Implements ChromeOS specific functionality for ScreenOrientationProvider. |
| 29 class ASH_EXPORT ScreenOrientationController | 25 class ASH_EXPORT ScreenOrientationController |
| 30 : public aura::client::ActivationChangeObserver, | 26 : public WmActivationObserver, |
| 31 public aura::WindowObserver, | 27 public WmWindowObserver, |
| 32 public chromeos::AccelerometerReader::Observer, | 28 public chromeos::AccelerometerReader::Observer, |
| 33 public WindowTreeHostManager::Observer, | 29 public WmDisplayObserver, |
| 34 public ShellObserver { | 30 public ShellObserver { |
| 35 public: | 31 public: |
| 36 // Observer that reports changes to the state of ScreenOrientationProvider's | 32 // Observer that reports changes to the state of ScreenOrientationProvider's |
| 37 // rotation lock. | 33 // rotation lock. |
| 38 class Observer { | 34 class Observer { |
| 39 public: | 35 public: |
| 40 // Invoked when rotation is locked or unlocked. | 36 // Invoked when rotation is locked or unlocked. |
| 41 virtual void OnRotationLockChanged(bool rotation_locked) {} | 37 virtual void OnRotationLockChanged(bool rotation_locked) {} |
| 42 | 38 |
| 43 protected: | 39 protected: |
| 44 virtual ~Observer() {} | 40 virtual ~Observer() {} |
| 45 }; | 41 }; |
| 46 | 42 |
| 47 ScreenOrientationController(); | 43 ScreenOrientationController(); |
| 48 ~ScreenOrientationController() override; | 44 ~ScreenOrientationController() override; |
| 49 | 45 |
| 50 // Add/Remove observers. | 46 // Add/Remove observers. |
| 51 void AddObserver(Observer* observer); | 47 void AddObserver(Observer* observer); |
| 52 void RemoveObserver(Observer* observer); | 48 void RemoveObserver(Observer* observer); |
| 53 | 49 |
| 54 // Allows/unallows a window to lock the screen orientation. | 50 // Allows/unallows a window to lock the screen orientation. |
| 55 void LockOrientationForWindow( | 51 void LockOrientationForWindow( |
| 56 aura::Window* requesting_windowwindow, | 52 WmWindow* requesting_window, |
| 57 blink::WebScreenOrientationLockType lock_orientation); | 53 blink::WebScreenOrientationLockType lock_orientation); |
| 58 void UnlockOrientationForWindow(aura::Window* window); | 54 void UnlockOrientationForWindow(WmWindow* window); |
| 59 | 55 |
| 60 // Unlock all and set the rotation back to the user specified rotation. | 56 // Unlock all and set the rotation back to the user specified rotation. |
| 61 void UnlockAll(); | 57 void UnlockAll(); |
| 62 | 58 |
| 63 bool ScreenOrientationProviderSupported() const; | 59 bool ScreenOrientationProviderSupported() const; |
| 64 | 60 |
| 65 bool ignore_display_configuration_updates() const { | 61 bool ignore_display_configuration_updates() const { |
| 66 return ignore_display_configuration_updates_; | 62 return ignore_display_configuration_updates_; |
| 67 } | 63 } |
| 68 | 64 |
| 69 // True if |rotation_lock_| has been set and accelerometer updates should not | 65 // True if |rotation_lock_| has been set and accelerometer updates should not |
| 70 // rotate the display. | 66 // rotate the display. |
| 71 bool rotation_locked() const { return rotation_locked_; } | 67 bool rotation_locked() const { return rotation_locked_; } |
| 72 | 68 |
| 73 // If |rotation_locked| future accelerometer updates should not change the | 69 // If |rotation_locked| future accelerometer updates should not change the |
| 74 // display rotation. | 70 // display rotation. |
| 75 void SetRotationLocked(bool rotation_locked); | 71 void SetRotationLocked(bool rotation_locked); |
| 76 | 72 |
| 77 // Sets the display rotation for the given |source|. The new |rotation| will | 73 // Sets the display rotation for the given |source|. The new |rotation| will |
| 78 // also become active. Display changed notifications are surpressed for this | 74 // also become active. Display changed notifications are surpressed for this |
| 79 // change. | 75 // change. |
| 80 void SetDisplayRotation(display::Display::Rotation rotation, | 76 void SetDisplayRotation(display::Display::Rotation rotation, |
| 81 display::Display::RotationSource source); | 77 display::Display::RotationSource source); |
| 82 | 78 |
| 83 // aura::client::ActivationChangeObserver: | 79 // WmActivationObserver: |
| 84 void OnWindowActivated( | 80 void OnWindowActivated(WmWindow* gained_active, |
| 85 aura::client::ActivationChangeObserver::ActivationReason reason, | 81 WmWindow* lost_active) override; |
| 86 aura::Window* gained_active, | |
| 87 aura::Window* lost_active) override; | |
| 88 | 82 |
| 89 // aura::WindowObserver: | 83 // WmWindowObserver: |
| 90 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; | 84 void OnWindowDestroying(WmWindow* window) override; |
| 91 void OnWindowDestroying(aura::Window* window) override; | 85 void OnWindowVisibilityChanged(WmWindow* window, bool visible) override; |
| 92 | 86 |
| 93 // chromeos::AccelerometerReader::Observer: | 87 // chromeos::AccelerometerReader::Observer: |
| 94 void OnAccelerometerUpdated( | 88 void OnAccelerometerUpdated( |
| 95 scoped_refptr<const chromeos::AccelerometerUpdate> update) override; | 89 scoped_refptr<const chromeos::AccelerometerUpdate> update) override; |
| 96 | 90 |
| 97 // WindowTreeHostManager::Observer: | 91 // WmDisplayObserver: |
| 98 void OnDisplayConfigurationChanged() override; | 92 void OnDisplayConfigurationChanged() override; |
| 99 | 93 |
| 100 // ShellObserver: | 94 // ShellObserver: |
| 101 void OnMaximizeModeStarted() override; | 95 void OnMaximizeModeStarted() override; |
| 102 void OnMaximizeModeEnded() override; | 96 void OnMaximizeModeEnded() override; |
| 103 | 97 |
| 104 private: | 98 private: |
| 105 // Sets the display rotation to |rotation|. Future accelerometer updates | 99 // Sets the display rotation to |rotation|. Future accelerometer updates |
| 106 // should not be used to change the rotation. SetRotationLocked(false) removes | 100 // should not be used to change the rotation. SetRotationLocked(false) removes |
| 107 // the rotation lock. | 101 // the rotation lock. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 167 |
| 174 // The current rotation set by ScreenOrientationController for the internal | 168 // The current rotation set by ScreenOrientationController for the internal |
| 175 // display. | 169 // display. |
| 176 display::Display::Rotation current_rotation_; | 170 display::Display::Rotation current_rotation_; |
| 177 | 171 |
| 178 // Rotation Lock observers. | 172 // Rotation Lock observers. |
| 179 base::ObserverList<Observer> observers_; | 173 base::ObserverList<Observer> observers_; |
| 180 | 174 |
| 181 // Tracks all windows that have requested a lock, as well as the requested | 175 // Tracks all windows that have requested a lock, as well as the requested |
| 182 // orientation. | 176 // orientation. |
| 183 std::map<aura::Window*, blink::WebScreenOrientationLockType> locking_windows_; | 177 std::map<WmWindow*, blink::WebScreenOrientationLockType> locking_windows_; |
| 184 | 178 |
| 185 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationController); | 179 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationController); |
| 186 }; | 180 }; |
| 187 | 181 |
| 188 } // namespace ash | 182 } // namespace ash |
| 189 | 183 |
| 190 #endif // ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ | 184 #endif // ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ |
| OLD | NEW |