| OLD | NEW |
| 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 #include "ash/display/screen_orientation_controller_chromeos.h" | 5 #include "ash/display/screen_orientation_controller_chromeos.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/display/display_configuration_controller.h" |
| 8 #include "ash/display/display_info.h" | 9 #include "ash/display/display_info.h" |
| 9 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| 10 #include "ash/rotator/screen_rotation_animator.h" | |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 12 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 13 #include "base/auto_reset.h" | 13 #include "base/auto_reset.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.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 "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 18 #include "ui/aura/window_observer.h" | 18 #include "ui/aura/window_observer.h" |
| 19 #include "ui/chromeos/accelerometer/accelerometer_util.h" | 19 #include "ui/chromeos/accelerometer/accelerometer_util.h" |
| 20 #include "ui/gfx/display.h" | 20 #include "ui/gfx/display.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 void ScreenOrientationController::SetDisplayRotation( | 138 void ScreenOrientationController::SetDisplayRotation( |
| 139 gfx::Display::Rotation rotation, | 139 gfx::Display::Rotation rotation, |
| 140 gfx::Display::RotationSource source) { | 140 gfx::Display::RotationSource source) { |
| 141 if (!gfx::Display::HasInternalDisplay()) | 141 if (!gfx::Display::HasInternalDisplay()) |
| 142 return; | 142 return; |
| 143 current_rotation_ = rotation; | 143 current_rotation_ = rotation; |
| 144 base::AutoReset<bool> auto_ignore_display_configuration_updates( | 144 base::AutoReset<bool> auto_ignore_display_configuration_updates( |
| 145 &ignore_display_configuration_updates_, true); | 145 &ignore_display_configuration_updates_, true); |
| 146 | 146 |
| 147 ash::ScreenRotationAnimator screen_rotation_animator( | 147 Shell::GetInstance()->display_configuration_controller()->SetDisplayRotation( |
| 148 gfx::Display::InternalDisplayId()); | 148 gfx::Display::InternalDisplayId(), rotation, source, |
| 149 if (screen_rotation_animator.CanAnimate()) { | 149 true /* user_action */); |
| 150 screen_rotation_animator.Rotate(rotation, source); | |
| 151 } else { | |
| 152 Shell::GetInstance()->display_manager()->SetDisplayRotation( | |
| 153 gfx::Display::InternalDisplayId(), rotation, source); | |
| 154 } | |
| 155 } | 150 } |
| 156 | 151 |
| 157 void ScreenOrientationController::OnWindowActivated( | 152 void ScreenOrientationController::OnWindowActivated( |
| 158 aura::client::ActivationChangeObserver::ActivationReason reason, | 153 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 159 aura::Window* gained_active, | 154 aura::Window* gained_active, |
| 160 aura::Window* lost_active) { | 155 aura::Window* lost_active) { |
| 161 ApplyLockForActiveWindow(); | 156 ApplyLockForActiveWindow(); |
| 162 } | 157 } |
| 163 | 158 |
| 164 // Currently contents::WebContents will only be able to lock rotation while | 159 // Currently contents::WebContents will only be able to lock rotation while |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 } | 414 } |
| 420 | 415 |
| 421 bool ScreenOrientationController::CanRotateInLockedState() { | 416 bool ScreenOrientationController::CanRotateInLockedState() { |
| 422 return rotation_locked_orientation_ == | 417 return rotation_locked_orientation_ == |
| 423 blink::WebScreenOrientationLockLandscape || | 418 blink::WebScreenOrientationLockLandscape || |
| 424 rotation_locked_orientation_ == | 419 rotation_locked_orientation_ == |
| 425 blink::WebScreenOrientationLockPortrait; | 420 blink::WebScreenOrientationLockPortrait; |
| 426 } | 421 } |
| 427 | 422 |
| 428 } // namespace ash | 423 } // namespace ash |
| OLD | NEW |