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

Unified Diff: ash/content/display/screen_orientation_controller_chromeos.cc

Issue 1071353003: Prevent DisplayPreferences from saving incorrect rotations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/content/display/screen_orientation_controller_chromeos.cc
diff --git a/ash/content/display/screen_orientation_controller_chromeos.cc b/ash/content/display/screen_orientation_controller_chromeos.cc
index 07659d7c131d282c85a13f8f4a985b153b72b28b..69f5c7410bc481890ded1aa4cd3aab24005afd2a 100644
--- a/ash/content/display/screen_orientation_controller_chromeos.cc
+++ b/ash/content/display/screen_orientation_controller_chromeos.cc
@@ -45,7 +45,7 @@ blink::WebScreenOrientationLockType GetDisplayNaturalOrientation() {
ash::DisplayInfo info =
display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId());
gfx::Size size = info.size_in_pixel();
- switch (info.rotation()) {
+ switch (info.Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE)) {
case gfx::Display::ROTATE_0:
case gfx::Display::ROTATE_180:
return size.height() >= size.width()
@@ -112,7 +112,8 @@ void ScreenOrientationController::SetRotationLocked(bool rotation_locked) {
}
void ScreenOrientationController::SetDisplayRotation(
- gfx::Display::Rotation rotation) {
+ gfx::Display::Rotation rotation,
+ gfx::Display::RotationSource source) {
DisplayManager* display_manager = Shell::GetInstance()->display_manager();
if (!display_manager->HasInternalDisplay())
return;
@@ -120,7 +121,7 @@ void ScreenOrientationController::SetDisplayRotation(
base::AutoReset<bool> auto_ignore_display_configuration_updates(
&ignore_display_configuration_updates_, true);
ash::ScreenRotationAnimator(gfx::Display::InternalDisplayId())
- .Rotate(rotation);
+ .Rotate(rotation, source);
}
void ScreenOrientationController::OnWindowActivated(aura::Window* gained_active,
@@ -200,7 +201,7 @@ void ScreenOrientationController::OnDisplayConfigurationChanged() {
Shell::GetInstance()
->display_manager()
->GetDisplayInfo(gfx::Display::InternalDisplayId())
- .rotation();
+ .Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE);
if (user_rotation != current_rotation_) {
// A user may change other display configuration settings. When the user
// does change the rotation setting, then lock rotation to prevent the
@@ -216,7 +217,7 @@ void ScreenOrientationController::OnMaximizeModeStarted() {
return;
current_rotation_ = user_rotation_ =
display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId())
- .rotation();
+ .Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE);
if (!rotation_locked_)
LoadDisplayRotationProperties();
chromeos::AccelerometerReader::GetInstance()->AddObserver(this);
@@ -229,13 +230,14 @@ void ScreenOrientationController::OnMaximizeModeEnded() {
chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this);
Shell::GetInstance()->display_controller()->RemoveObserver(this);
if (current_rotation_ != user_rotation_)
- SetDisplayRotation(user_rotation_);
+ SetDisplayRotation(user_rotation_, gfx::Display::ROTATION_SOURCE_USER);
}
void ScreenOrientationController::LockRotation(
- gfx::Display::Rotation rotation) {
+ gfx::Display::Rotation rotation,
+ gfx::Display::RotationSource source) {
SetRotationLocked(true);
- SetDisplayRotation(rotation);
+ SetDisplayRotation(rotation, source);
}
void ScreenOrientationController::LockRotationToOrientation(
@@ -268,7 +270,8 @@ void ScreenOrientationController::LockRotationToOrientation(
blink::WebScreenOrientationLockLandscape);
break;
case blink::WebScreenOrientationLockNatural:
- LockRotation(gfx::Display::ROTATE_0);
+ LockRotation(gfx::Display::ROTATE_0,
+ gfx::Display::ROTATION_SOURCE_ACTIVE);
break;
default:
NOTREACHED();
@@ -280,14 +283,16 @@ void ScreenOrientationController::LockRotationToPrimaryOrientation(
blink::WebScreenOrientationLockType lock_orientation) {
LockRotation(natural_orientation_ == lock_orientation
? gfx::Display::ROTATE_0
- : gfx::Display::ROTATE_90);
+ : gfx::Display::ROTATE_90,
+ gfx::Display::ROTATION_SOURCE_ACTIVE);
}
void ScreenOrientationController::LockRotationToSecondaryOrientation(
blink::WebScreenOrientationLockType lock_orientation) {
LockRotation(natural_orientation_ == lock_orientation
? gfx::Display::ROTATE_180
- : gfx::Display::ROTATE_270);
+ : gfx::Display::ROTATE_270,
+ gfx::Display::ROTATION_SOURCE_ACTIVE);
}
void ScreenOrientationController::LockToRotationMatchingOrientation(
@@ -298,20 +303,22 @@ void ScreenOrientationController::LockToRotationMatchingOrientation(
gfx::Display::Rotation rotation =
display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId())
- .rotation();
+ .Rotation(gfx::Display::ROTATION_SOURCE_ACTIVE);
if (natural_orientation_ == lock_orientation) {
if (rotation == gfx::Display::ROTATE_0 ||
rotation == gfx::Display::ROTATE_180) {
SetRotationLocked(true);
} else {
- LockRotation(gfx::Display::ROTATE_0);
+ LockRotation(gfx::Display::ROTATE_0,
+ gfx::Display::ROTATION_SOURCE_ACTIVE);
}
} else {
if (rotation == gfx::Display::ROTATE_90 ||
rotation == gfx::Display::ROTATE_270) {
SetRotationLocked(true);
} else {
- LockRotation(gfx::Display::ROTATE_90);
+ LockRotation(gfx::Display::ROTATE_90,
+ gfx::Display::ROTATION_SOURCE_ACTIVE);
}
}
}
@@ -363,14 +370,16 @@ void ScreenOrientationController::HandleScreenRotation(
if (new_rotation != current_rotation_ &&
IsRotationAllowedInLockedState(new_rotation))
- SetDisplayRotation(new_rotation);
+ SetDisplayRotation(new_rotation,
+ gfx::Display::ROTATION_SOURCE_ACCELEROMETER);
}
void ScreenOrientationController::LoadDisplayRotationProperties() {
DisplayManager* display_manager = Shell::GetInstance()->display_manager();
if (!display_manager->registered_internal_display_rotation_lock())
return;
- SetDisplayRotation(display_manager->registered_internal_display_rotation());
+ SetDisplayRotation(display_manager->registered_internal_display_rotation(),
+ gfx::Display::ROTATION_SOURCE_ACCELEROMETER);
SetRotationLocked(true);
}

Powered by Google App Engine
This is Rietveld 408576698