Commit dc489084 authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Follow up CL for crrev.com/c/967684

TBR=afakhry@chromium.org
BUG=735078, 823634
TEST=None

Change-Id: I6351b02d21fd3d64ca0963204f22fdd97910dc4b
Reviewed-on: https://chromium-review.googlesource.com/974293Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544879}
parent 1966df16
...@@ -222,15 +222,19 @@ void ScreenOrientationController::LockOrientationForWindow( ...@@ -222,15 +222,19 @@ void ScreenOrientationController::LockOrientationForWindow(
OrientationLockType orientation_lock) { OrientationLockType orientation_lock) {
if (!requesting_window->HasObserver(this)) if (!requesting_window->HasObserver(this))
requesting_window->AddObserver(this); requesting_window->AddObserver(this);
auto iter = lock_info_map_.find(requesting_window);
if (orientation_lock == OrientationLockType::kCurrent && if (iter != lock_info_map_.end()) {
lock_info_map_.count(requesting_window)) { if (orientation_lock == OrientationLockType::kCurrent) {
// If the app previously requested an orientation, // If the app previously requested an orientation,
// disable the sensor when that orientation is locked. // disable the sensor when that orientation is locked.
lock_info_map_[requesting_window].lock_completion_behavior = iter->second.lock_completion_behavior =
LockCompletionBehavior::DisableSensor; LockCompletionBehavior::DisableSensor;
} else {
iter->second.orientation_lock = orientation_lock;
iter->second.lock_completion_behavior = LockCompletionBehavior::None;
}
} else { } else {
lock_info_map_[requesting_window] = LockInfo(orientation_lock); lock_info_map_.emplace(requesting_window, LockInfo(orientation_lock));
} }
ApplyLockForActiveWindow(); ApplyLockForActiveWindow();
...@@ -575,22 +579,21 @@ void ScreenOrientationController::ApplyLockForActiveWindow() { ...@@ -575,22 +579,21 @@ void ScreenOrientationController::ApplyLockForActiveWindow() {
continue; continue;
for (auto& pair : lock_info_map_) { for (auto& pair : lock_info_map_) {
if (pair.first->TargetVisibility() && window->Contains(pair.first)) { if (pair.first->TargetVisibility() && window->Contains(pair.first)) {
if (pair.second.orientation == OrientationLockType::kCurrent) { if (pair.second.orientation_lock == OrientationLockType::kCurrent) {
// If the app requested "current" without previously // If the app requested "current" without previously
// specifying a orientation, use the current rotation. // specifying an orientation, use the current rotation.
pair.second.orientation = pair.second.orientation_lock =
RotationToOrientation(natural_orientation_, current_rotation_); RotationToOrientation(natural_orientation_, current_rotation_);
LockRotationToOrientation(pair.second.orientation); LockRotationToOrientation(pair.second.orientation_lock);
} else if (pair.second.lock_completion_behavior ==
LockCompletionBehavior::DisableSensor) {
pair.second.lock_completion_behavior = LockCompletionBehavior::None;
pair.second.orientation = ResolveOrientationLock(
pair.second.orientation, user_locked_orientation_);
LockRotationToOrientation(pair.second.orientation);
} else { } else {
LockRotationToOrientation(ResolveOrientationLock( const auto orientation_lock = ResolveOrientationLock(
pair.second.orientation, user_locked_orientation_)); pair.second.orientation_lock, user_locked_orientation_);
LockRotationToOrientation(orientation_lock);
if (pair.second.lock_completion_behavior ==
LockCompletionBehavior::DisableSensor) {
pair.second.lock_completion_behavior = LockCompletionBehavior::None;
pair.second.orientation_lock = orientation_lock;
}
} }
return; return;
} }
......
...@@ -154,9 +154,8 @@ class ASH_EXPORT ScreenOrientationController ...@@ -154,9 +154,8 @@ class ASH_EXPORT ScreenOrientationController
struct LockInfo { struct LockInfo {
LockInfo() {} LockInfo() {}
LockInfo(OrientationLockType orientation_lock) LockInfo(OrientationLockType lock) : orientation_lock(lock) {}
: orientation(orientation_lock) {} OrientationLockType orientation_lock = OrientationLockType::kAny;
OrientationLockType orientation = OrientationLockType::kAny;
LockCompletionBehavior lock_completion_behavior = LockCompletionBehavior lock_completion_behavior =
LockCompletionBehavior::None; LockCompletionBehavior::None;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment