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

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

Issue 2792973002: Resolve current orientation after applying the previous orientation request. (Closed)
Patch Set: LockToCurrent 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_display_observer.h" 12 #include "ash/common/wm_display_observer.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "chromeos/accelerometer/accelerometer_reader.h" 15 #include "chromeos/accelerometer/accelerometer_reader.h"
16 #include "chromeos/accelerometer/accelerometer_types.h" 16 #include "chromeos/accelerometer/accelerometer_types.h"
17 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h" 17 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree nOrientationLockType.h"
18 #include "ui/aura/window_observer.h" 18 #include "ui/aura/window_observer.h"
(...skipping 24 matching lines...) Expand all
43 virtual ~Observer() {} 43 virtual ~Observer() {}
44 }; 44 };
45 45
46 ScreenOrientationController(); 46 ScreenOrientationController();
47 ~ScreenOrientationController() override; 47 ~ScreenOrientationController() override;
48 48
49 // Add/Remove observers. 49 // Add/Remove observers.
50 void AddObserver(Observer* observer); 50 void AddObserver(Observer* observer);
51 void RemoveObserver(Observer* observer); 51 void RemoveObserver(Observer* observer);
52 52
53 // Allows/unallows a window to lock the screen orientation. 53 // Allows/unallows a window to lock the screen orientation. When
54 // |lock_to_current| is true, it will take another stop to lock to
55 // the exact orientation locked by |lock_orientation|. For example,
56 // specifying PORTRAIT may still rotate to PORTRAIT_PRIMARY or
57 // PORTRAIT_SEONDARY. Setting true with PORTRAIT will lock to these
58 // specific orientation so that it will not rotate after it is
59 // locked to one of them.
54 void LockOrientationForWindow( 60 void LockOrientationForWindow(
55 WmWindow* requesting_window, 61 WmWindow* requesting_window,
56 blink::WebScreenOrientationLockType lock_orientation); 62 blink::WebScreenOrientationLockType lock_orientation,
63 bool lock_to_current);
jonross 2017/04/04 21:51:32 So there is a split now in functionality between b
oshima 2017/04/04 23:00:25 Well, it's already different (for example, blink c
jonross 2017/04/04 23:49:25 Good point, I'm fine keeping this through the one
oshima 2017/04/05 18:19:30 Done.
57 void UnlockOrientationForWindow(WmWindow* window); 64 void UnlockOrientationForWindow(WmWindow* window);
58 65
59 // Unlock all and set the rotation back to the user specified rotation. 66 // Unlock all and set the rotation back to the user specified rotation.
60 void UnlockAll(); 67 void UnlockAll();
61 68
62 bool ScreenOrientationProviderSupported() const; 69 bool ScreenOrientationProviderSupported() const;
63 70
64 bool ignore_display_configuration_updates() const { 71 bool ignore_display_configuration_updates() const {
65 return ignore_display_configuration_updates_; 72 return ignore_display_configuration_updates_;
66 } 73 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // WmDisplayObserver: 105 // WmDisplayObserver:
99 void OnDisplayConfigurationChanged() override; 106 void OnDisplayConfigurationChanged() override;
100 107
101 // ShellObserver: 108 // ShellObserver:
102 void OnMaximizeModeStarted() override; 109 void OnMaximizeModeStarted() override;
103 void OnMaximizeModeEnded() override; 110 void OnMaximizeModeEnded() override;
104 111
105 private: 112 private:
106 friend class test::ScreenOrientationControllerTestApi; 113 friend class test::ScreenOrientationControllerTestApi;
107 114
115 struct LockInfo {
116 LockInfo() {}
117 LockInfo(blink::WebScreenOrientationLockType orientation,
118 bool lock_to_current)
119 : orientation(orientation), lock_to_current(lock_to_current) {}
120
121 blink::WebScreenOrientationLockType orientation =
122 blink::WebScreenOrientationLockAny;
123 bool lock_to_current = false;
124 };
125
108 // Sets the display rotation for the given |source|. The new |rotation| will 126 // Sets the display rotation for the given |source|. The new |rotation| will
109 // also become active. Display changed notifications are surpressed for this 127 // also become active. Display changed notifications are surpressed for this
110 // change. 128 // change.
111 void SetDisplayRotation(display::Display::Rotation rotation, 129 void SetDisplayRotation(display::Display::Rotation rotation,
112 display::Display::RotationSource source); 130 display::Display::RotationSource source);
113 131
114 void SetRotationLockedInternal(bool rotation_locked); 132 void SetRotationLockedInternal(bool rotation_locked);
115 133
116 // A helper method that set locked to the given |orientation| and save it. 134 // A helper method that set locked to the given |orientation| and save it.
117 void SetLockToOrientation(blink::WebScreenOrientationLockType orientation); 135 void SetLockToOrientation(blink::WebScreenOrientationLockType orientation);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // window, and applies it. If there is none, rotation lock will be removed. 174 // window, and applies it. If there is none, rotation lock will be removed.
157 void ApplyLockForActiveWindow(); 175 void ApplyLockForActiveWindow();
158 176
159 // Both |blink::WebScreenOrientationLockLandscape| and 177 // Both |blink::WebScreenOrientationLockLandscape| and
160 // |blink::WebScreenOrientationLockPortrait| allow for rotation between the 178 // |blink::WebScreenOrientationLockPortrait| allow for rotation between the
161 // two angles of the same screen orientation 179 // two angles of the same screen orientation
162 // (http://www.w3.org/TR/screen-orientation/). Returns true if |rotation| is 180 // (http://www.w3.org/TR/screen-orientation/). Returns true if |rotation| is
163 // supported for the current |rotation_locked_orientation_|. 181 // supported for the current |rotation_locked_orientation_|.
164 bool IsRotationAllowedInLockedState(display::Display::Rotation rotation); 182 bool IsRotationAllowedInLockedState(display::Display::Rotation rotation);
165 183
184 blink::WebScreenOrientationLockType GetCurrentOrientationForTest() const;
185
166 // Certain orientation locks allow for rotation between the two angles of the 186 // Certain orientation locks allow for rotation between the two angles of the
167 // same screen orientation. Returns true if |rotation_locked_orientation_| 187 // same screen orientation. Returns true if |rotation_locked_orientation_|
168 // allows rotation. 188 // allows rotation.
169 bool CanRotateInLockedState(); 189 bool CanRotateInLockedState();
170 190
171 // The orientation of the display when at a rotation of 0. 191 // The orientation of the display when at a rotation of 0.
172 blink::WebScreenOrientationLockType natural_orientation_; 192 blink::WebScreenOrientationLockType natural_orientation_;
173 193
174 // True when changes being applied cause OnDisplayConfigurationChanged() to be 194 // True when changes being applied cause OnDisplayConfigurationChanged() to be
175 // called, and for which these changes should be ignored. 195 // called, and for which these changes should be ignored.
(...skipping 15 matching lines...) Expand all
191 211
192 // The current rotation set by ScreenOrientationController for the internal 212 // The current rotation set by ScreenOrientationController for the internal
193 // display. 213 // display.
194 display::Display::Rotation current_rotation_; 214 display::Display::Rotation current_rotation_;
195 215
196 // Rotation Lock observers. 216 // Rotation Lock observers.
197 base::ObserverList<Observer> observers_; 217 base::ObserverList<Observer> observers_;
198 218
199 // Tracks all windows that have requested a lock, as well as the requested 219 // Tracks all windows that have requested a lock, as well as the requested
200 // orientation. 220 // orientation.
201 std::map<WmWindow*, blink::WebScreenOrientationLockType> locking_windows_; 221 std::unordered_map<WmWindow*, LockInfo> lock_info_map_;
202 222
203 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationController); 223 DISALLOW_COPY_AND_ASSIGN(ScreenOrientationController);
204 }; 224 };
205 225
206 } // namespace ash 226 } // namespace ash
207 227
208 #endif // ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ 228 #endif // ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698