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

Unified Diff: ash/display/screen_orientation_controller_chromeos.cc

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 side-by-side diff with in-line comments
Download patch
Index: ash/display/screen_orientation_controller_chromeos.cc
diff --git a/ash/display/screen_orientation_controller_chromeos.cc b/ash/display/screen_orientation_controller_chromeos.cc
index b10a9b846dbdae3add000df5f93b46977b7ab8fb..a3edd7f5127850037843fc7af8521a79be5ed955 100644
--- a/ash/display/screen_orientation_controller_chromeos.cc
+++ b/ash/display/screen_orientation_controller_chromeos.cc
@@ -167,7 +167,7 @@ ScreenOrientationController::~ScreenOrientationController() {
chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this);
WmShell::Get()->RemoveDisplayObserver(this);
WmShell::Get()->RemoveActivationObserver(this);
- for (auto& windows : locking_windows_)
+ for (auto& windows : lock_info_map_)
windows.first->aura_window()->RemoveObserver(this);
}
@@ -181,29 +181,31 @@ void ScreenOrientationController::RemoveObserver(Observer* observer) {
void ScreenOrientationController::LockOrientationForWindow(
WmWindow* requesting_window,
- blink::WebScreenOrientationLockType lock_orientation) {
- if (locking_windows_.empty())
+ blink::WebScreenOrientationLockType lock_orientation,
+ LockCompletionBehavior lock_completion_behavior) {
+ if (lock_info_map_.empty())
WmShell::Get()->AddActivationObserver(this);
if (!requesting_window->aura_window()->HasObserver(this))
requesting_window->aura_window()->AddObserver(this);
- locking_windows_[requesting_window] = lock_orientation;
+ lock_info_map_[requesting_window] =
+ LockInfo(lock_orientation, lock_completion_behavior);
ApplyLockForActiveWindow();
}
void ScreenOrientationController::UnlockOrientationForWindow(WmWindow* window) {
- locking_windows_.erase(window);
- if (locking_windows_.empty())
+ lock_info_map_.erase(window);
+ if (lock_info_map_.empty())
WmShell::Get()->RemoveActivationObserver(this);
window->aura_window()->RemoveObserver(this);
ApplyLockForActiveWindow();
}
void ScreenOrientationController::UnlockAll() {
- for (auto pair : locking_windows_)
+ for (auto pair : lock_info_map_)
pair.first->aura_window()->RemoveObserver(this);
- locking_windows_.clear();
+ lock_info_map_.clear();
WmShell::Get()->RemoveActivationObserver(this);
SetRotationLockedInternal(false);
if (user_rotation_ != current_rotation_)
@@ -260,7 +262,7 @@ void ScreenOrientationController::OnWindowDestroying(aura::Window* window) {
void ScreenOrientationController::OnWindowVisibilityChanged(
aura::Window* window,
bool visible) {
- if (locking_windows_.find(WmWindow::Get(window)) == locking_windows_.end())
+ if (lock_info_map_.find(WmWindow::Get(window)) == lock_info_map_.end())
return;
ApplyLockForActiveWindow();
}
@@ -526,10 +528,16 @@ void ScreenOrientationController::ApplyLockForActiveWindow() {
for (WmWindow* window : mru_windows) {
if (!window->GetTargetVisibility())
continue;
- for (auto const& pair : locking_windows_) {
+ for (auto& pair : lock_info_map_) {
if (pair.first->GetTargetVisibility() && window->Contains(pair.first)) {
- LockRotationToOrientation(
- ResolveOrientationLock(pair.second, user_locked_orientation_));
+ LockRotationToOrientation(ResolveOrientationLock(
+ pair.second.orientation, user_locked_orientation_));
+ if (pair.second.lock_completion_behavior ==
+ LockCompletionBehavior::DisableSensor) {
+ pair.second.orientation = RotationToOrientation(current_rotation_);
+ pair.second.lock_completion_behavior = LockCompletionBehavior::None;
+ LockRotationToOrientation(pair.second.orientation);
+ }
return;
}
}
@@ -562,6 +570,11 @@ bool ScreenOrientationController::IsRotationAllowedInLockedState(
return false;
}
+blink::WebScreenOrientationLockType
+ScreenOrientationController::GetCurrentOrientationForTest() const {
+ return RotationToOrientation(current_rotation_);
+}
+
bool ScreenOrientationController::CanRotateInLockedState() {
return rotation_locked_orientation_ ==
blink::WebScreenOrientationLockLandscape ||
« no previous file with comments | « ash/display/screen_orientation_controller_chromeos.h ('k') | ash/test/screen_orientation_controller_test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698