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

Side by Side Diff: ash/display/screen_orientation_controller_chromeos.h

Issue 2802403002: Resolve current orientation after applying the previous orientation request. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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 <unordered_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/common/wm_activation_observer.h" 12 #include "ash/common/wm_activation_observer.h"
13 #include "ash/common/wm_display_observer.h" 13 #include "ash/common/wm_display_observer.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "chromeos/accelerometer/accelerometer_reader.h" 16 #include "chromeos/accelerometer/accelerometer_reader.h"
17 #include "chromeos/accelerometer/accelerometer_types.h" 17 #include "chromeos/accelerometer/accelerometer_types.h"
18 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h" 18 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h"
(...skipping 17 matching lines...) Expand all
36 // rotation lock. 36 // rotation lock.
37 class Observer { 37 class Observer {
38 public: 38 public:
39 // Invoked when rotation is locked or unlocked by a user. 39 // Invoked when rotation is locked or unlocked by a user.
40 virtual void OnUserRotationLockChanged() {} 40 virtual void OnUserRotationLockChanged() {}
41 41
42 protected: 42 protected:
43 virtual ~Observer() {} 43 virtual ~Observer() {}
44 }; 44 };
45 45
46 // Controls the behavior after lock is applied to the window (when
47 // the window becomes active window). |DisableSensor| disables
48 // the sensor based rotation and locks to the specific orientation.
49 // For example, PORTRAIT may rotate to PORTRAIT_PRIMARY or
50 // PORTRAIT_SECONDARY, and will allow rotate between these two.
51 // |DisableSensor| will lock the orientation to the one of them
52 // after locked to disalow the sensor basd rotation.
53 enum class LockCompletionBehavior {
54 None,
55 DisableSensor,
56 };
57
46 ScreenOrientationController(); 58 ScreenOrientationController();
47 ~ScreenOrientationController() override; 59 ~ScreenOrientationController() override;
48 60
49 // Add/Remove observers. 61 // Add/Remove observers.
50 void AddObserver(Observer* observer); 62 void AddObserver(Observer* observer);
51 void RemoveObserver(Observer* observer); 63 void RemoveObserver(Observer* observer);
52 64
53 // Allows/unallows a window to lock the screen orientation. 65 // Allows/unallows a window to lock the screen orientation.
54 void LockOrientationForWindow( 66 void LockOrientationForWindow(
55 WmWindow* requesting_window, 67 WmWindow* requesting_window,
56 blink::WebScreenOrientationLockType lock_orientation); 68 blink::WebScreenOrientationLockType lock_orientation,
69 LockCompletionBehavior lock_completion_behavior);
57 void UnlockOrientationForWindow(WmWindow* window); 70 void UnlockOrientationForWindow(WmWindow* window);
58 71
59 // Unlock all and set the rotation back to the user specified rotation. 72 // Unlock all and set the rotation back to the user specified rotation.
60 void UnlockAll(); 73 void UnlockAll();
61 74
62 bool ScreenOrientationProviderSupported() const; 75 bool ScreenOrientationProviderSupported() const;
63 76
64 bool ignore_display_configuration_updates() const { 77 bool ignore_display_configuration_updates() const {
65 return ignore_display_configuration_updates_; 78 return ignore_display_configuration_updates_;
66 } 79 }
(...skipping 30 matching lines...) Expand all
97 // WmDisplayObserver: 110 // WmDisplayObserver:
98 void OnDisplayConfigurationChanged() override; 111 void OnDisplayConfigurationChanged() override;
99 112
100 // ShellObserver: 113 // ShellObserver:
101 void OnMaximizeModeStarted() override; 114 void OnMaximizeModeStarted() override;
102 void OnMaximizeModeEnded() override; 115 void OnMaximizeModeEnded() override;
103 116
104 private: 117 private:
105 friend class test::ScreenOrientationControllerTestApi; 118 friend class test::ScreenOrientationControllerTestApi;
106 119
120 struct LockInfo {
121 LockInfo() {}
122 LockInfo(blink::WebScreenOrientationLockType orientation,
123 LockCompletionBehavior lock_completion_behavior)
124 : orientation(orientation),
125 lock_completion_behavior(lock_completion_behavior) {}
126
127 blink::WebScreenOrientationLockType orientation =
128 blink::WebScreenOrientationLockAny;
129 LockCompletionBehavior lock_completion_behavior =
130 LockCompletionBehavior::None;
131 };
132
107 // Sets the display rotation for the given |source|. The new |rotation| will 133 // Sets the display rotation for the given |source|. The new |rotation| will
108 // also become active. Display changed notifications are surpressed for this 134 // also become active. Display changed notifications are surpressed for this
109 // change. 135 // change.
110 void SetDisplayRotation(display::Display::Rotation rotation, 136 void SetDisplayRotation(display::Display::Rotation rotation,
111 display::Display::RotationSource source); 137 display::Display::RotationSource source);
112 138
113 void SetRotationLockedInternal(bool rotation_locked); 139 void SetRotationLockedInternal(bool rotation_locked);
114 140
115 // A helper method that set locked to the given |orientation| and save it. 141 // A helper method that set locked to the given |orientation| and save it.
116 void SetLockToOrientation(blink::WebScreenOrientationLockType orientation); 142 void SetLockToOrientation(blink::WebScreenOrientationLockType orientation);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // window, and applies it. If there is none, rotation lock will be removed. 181 // window, and applies it. If there is none, rotation lock will be removed.
156 void ApplyLockForActiveWindow(); 182 void ApplyLockForActiveWindow();
157 183
158 // Both |blink::WebScreenOrientationLockLandscape| and 184 // Both |blink::WebScreenOrientationLockLandscape| and
159 // |blink::WebScreenOrientationLockPortrait| allow for rotation between the 185 // |blink::WebScreenOrientationLockPortrait| allow for rotation between the
160 // two angles of the same screen orientation 186 // two angles of the same screen orientation
161 // (http://www.w3.org/TR/screen-orientation/). Returns true if |rotation| is 187 // (http://www.w3.org/TR/screen-orientation/). Returns true if |rotation| is
162 // supported for the current |rotation_locked_orientation_|. 188 // supported for the current |rotation_locked_orientation_|.
163 bool IsRotationAllowedInLockedState(display::Display::Rotation rotation); 189 bool IsRotationAllowedInLockedState(display::Display::Rotation rotation);
164 190
191 blink::WebScreenOrientationLockType GetCurrentOrientationForTest() const;
192
165 // Certain orientation locks allow for rotation between the two angles of the 193 // Certain orientation locks allow for rotation between the two angles of the
166 // same screen orientation. Returns true if |rotation_locked_orientation_| 194 // same screen orientation. Returns true if |rotation_locked_orientation_|
167 // allows rotation. 195 // allows rotation.
168 bool CanRotateInLockedState(); 196 bool CanRotateInLockedState();
169 197
170 // The orientation of the display when at a rotation of 0. 198 // The orientation of the display when at a rotation of 0.
171 blink::WebScreenOrientationLockType natural_orientation_; 199 blink::WebScreenOrientationLockType natural_orientation_;
172 200
173 // True when changes being applied cause OnDisplayConfigurationChanged() to be 201 // True when changes being applied cause OnDisplayConfigurationChanged() to be
174 // called, and for which these changes should be ignored. 202 // called, and for which these changes should be ignored.
(...skipping 15 matching lines...) Expand all
190 218
191 // The current rotation set by ScreenOrientationController for the internal 219 // The current rotation set by ScreenOrientationController for the internal
192 // display. 220 // display.
193 display::Display::Rotation current_rotation_; 221 display::Display::Rotation current_rotation_;
194 222
195 // Rotation Lock observers. 223 // Rotation Lock observers.
196 base::ObserverList<Observer> observers_; 224 base::ObserverList<Observer> observers_;
197 225
198 // Tracks all windows that have requested a lock, as well as the requested 226 // Tracks all windows that have requested a lock, as well as the requested
199 // orientation. 227 // orientation.
200 std::map<WmWindow*, blink::WebScreenOrientationLockType> locking_windows_; 228 std::unordered_map<WmWindow*, LockInfo> lock_info_map_;
201 229
202 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationController); 230 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationController);
203 }; 231 };
204 232
205 } // namespace ash 233 } // namespace ash
206 234
207 #endif // ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ 235 #endif // ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_
OLDNEW
« no previous file with comments | « ash/display/display_manager_unittest.cc ('k') | ash/display/screen_orientation_controller_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698