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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ash/display/screen_orientation_controller_chromeos.h
diff --git a/ash/display/screen_orientation_controller_chromeos.h b/ash/display/screen_orientation_controller_chromeos.h
index 04121172638eec72d7219df3124d94b97dc4494f..3803c89fa084852e6dad5b6310b400711903b2f1 100644
--- a/ash/display/screen_orientation_controller_chromeos.h
+++ b/ash/display/screen_orientation_controller_chromeos.h
@@ -5,7 +5,7 @@
#ifndef ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_
#define ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_
-#include <map>
+#include <unordered_map>
#include "ash/ash_export.h"
#include "ash/common/shell_observer.h"
@@ -50,10 +50,17 @@ class ASH_EXPORT ScreenOrientationController
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
- // Allows/unallows a window to lock the screen orientation.
+ // Allows/unallows a window to lock the screen orientation. When
+ // |lock_to_current| is true, it will take another stop to lock to
+ // the exact orientation locked by |lock_orientation|. For example,
+ // specifying PORTRAIT may still rotate to PORTRAIT_PRIMARY or
+ // PORTRAIT_SEONDARY. Setting true with PORTRAIT will lock to these
+ // specific orientation so that it will not rotate after it is
+ // locked to one of them.
void LockOrientationForWindow(
WmWindow* requesting_window,
- blink::WebScreenOrientationLockType lock_orientation);
+ blink::WebScreenOrientationLockType lock_orientation,
+ 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.
void UnlockOrientationForWindow(WmWindow* window);
// Unlock all and set the rotation back to the user specified rotation.
@@ -105,6 +112,17 @@ class ASH_EXPORT ScreenOrientationController
private:
friend class test::ScreenOrientationControllerTestApi;
+ struct LockInfo {
+ LockInfo() {}
+ LockInfo(blink::WebScreenOrientationLockType orientation,
+ bool lock_to_current)
+ : orientation(orientation), lock_to_current(lock_to_current) {}
+
+ blink::WebScreenOrientationLockType orientation =
+ blink::WebScreenOrientationLockAny;
+ bool lock_to_current = false;
+ };
+
// Sets the display rotation for the given |source|. The new |rotation| will
// also become active. Display changed notifications are surpressed for this
// change.
@@ -163,6 +181,8 @@ class ASH_EXPORT ScreenOrientationController
// supported for the current |rotation_locked_orientation_|.
bool IsRotationAllowedInLockedState(display::Display::Rotation rotation);
+ blink::WebScreenOrientationLockType GetCurrentOrientationForTest() const;
+
// Certain orientation locks allow for rotation between the two angles of the
// same screen orientation. Returns true if |rotation_locked_orientation_|
// allows rotation.
@@ -198,7 +218,7 @@ class ASH_EXPORT ScreenOrientationController
// Tracks all windows that have requested a lock, as well as the requested
// orientation.
- std::map<WmWindow*, blink::WebScreenOrientationLockType> locking_windows_;
+ std::unordered_map<WmWindow*, LockInfo> lock_info_map_;
DISALLOW_COPY_AND_ASSIGN(ScreenOrientationController);
};

Powered by Google App Engine
This is Rietveld 408576698