| 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/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
| 8 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 8 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 9 #include "ash/common/wm/mru_window_tracker.h" | 9 #include "ash/common/wm/mru_window_tracker.h" |
| 10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 ->IsMaximizeModeWindowManagerEnabled() && | 216 ->IsMaximizeModeWindowManagerEnabled() && |
| 217 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 217 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 218 switches::kAshDisableScreenOrientationLock); | 218 switches::kAshDisableScreenOrientationLock); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void ScreenOrientationController::ToggleUserRotationLock() { | 221 void ScreenOrientationController::ToggleUserRotationLock() { |
| 222 if (!display::Display::HasInternalDisplay()) | 222 if (!display::Display::HasInternalDisplay()) |
| 223 return; | 223 return; |
| 224 | 224 |
| 225 if (user_rotation_locked()) { | 225 if (user_rotation_locked()) { |
| 226 user_locked_orientation_ = blink::WebScreenOrientationLockAny; | 226 SetLockToOrientation(blink::WebScreenOrientationLockAny); |
| 227 } else { | 227 } else { |
| 228 display::Display::Rotation current_rotation = | 228 display::Display::Rotation current_rotation = |
| 229 WmShell::Get() | 229 WmShell::Get() |
| 230 ->GetDisplayInfo(display::Display::InternalDisplayId()) | 230 ->GetDisplayInfo(display::Display::InternalDisplayId()) |
| 231 .GetActiveRotation(); | 231 .GetActiveRotation(); |
| 232 user_locked_orientation_ = RotationToOrientation(current_rotation); | 232 SetLockToRotation(current_rotation); |
| 233 } | 233 } |
| 234 base::AutoReset<bool> auto_ignore_display_configuration_updates( | 234 } |
| 235 &ignore_display_configuration_updates_, true); | |
| 236 Shell::GetInstance()->display_manager()->RegisterDisplayRotationProperties( | |
| 237 user_rotation_locked(), OrientationToRotation(user_locked_orientation_)); | |
| 238 | 235 |
| 239 ApplyLockForActiveWindow(); | 236 void ScreenOrientationController::SetLockToRotation( |
| 240 for (auto& observer : observers_) | 237 display::Display::Rotation rotation) { |
| 241 observer.OnUserRotationLockChanged(); | 238 if (!display::Display::HasInternalDisplay()) |
| 239 return; |
| 240 |
| 241 SetLockToOrientation(RotationToOrientation(rotation)); |
| 242 } | 242 } |
| 243 | 243 |
| 244 void ScreenOrientationController::OnWindowActivated(WmWindow* gained_active, | 244 void ScreenOrientationController::OnWindowActivated(WmWindow* gained_active, |
| 245 WmWindow* lost_active) { | 245 WmWindow* lost_active) { |
| 246 ApplyLockForActiveWindow(); | 246 ApplyLockForActiveWindow(); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void ScreenOrientationController::OnWindowDestroying(aura::Window* window) { | 249 void ScreenOrientationController::OnWindowDestroying(aura::Window* window) { |
| 250 UnlockOrientationForWindow(WmWindow::Get(window)); | 250 UnlockOrientationForWindow(WmWindow::Get(window)); |
| 251 } | 251 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 348 |
| 349 void ScreenOrientationController::SetRotationLockedInternal( | 349 void ScreenOrientationController::SetRotationLockedInternal( |
| 350 bool rotation_locked) { | 350 bool rotation_locked) { |
| 351 if (rotation_locked_ == rotation_locked) | 351 if (rotation_locked_ == rotation_locked) |
| 352 return; | 352 return; |
| 353 rotation_locked_ = rotation_locked; | 353 rotation_locked_ = rotation_locked; |
| 354 if (!rotation_locked_) | 354 if (!rotation_locked_) |
| 355 rotation_locked_orientation_ = blink::WebScreenOrientationLockAny; | 355 rotation_locked_orientation_ = blink::WebScreenOrientationLockAny; |
| 356 } | 356 } |
| 357 | 357 |
| 358 void ScreenOrientationController::SetLockToOrientation( |
| 359 blink::WebScreenOrientationLockType orientation) { |
| 360 user_locked_orientation_ = orientation; |
| 361 base::AutoReset<bool> auto_ignore_display_configuration_updates( |
| 362 &ignore_display_configuration_updates_, true); |
| 363 Shell::GetInstance()->display_manager()->RegisterDisplayRotationProperties( |
| 364 user_rotation_locked(), OrientationToRotation(user_locked_orientation_)); |
| 365 |
| 366 ApplyLockForActiveWindow(); |
| 367 for (auto& observer : observers_) |
| 368 observer.OnUserRotationLockChanged(); |
| 369 } |
| 370 |
| 358 void ScreenOrientationController::LockRotation( | 371 void ScreenOrientationController::LockRotation( |
| 359 display::Display::Rotation rotation, | 372 display::Display::Rotation rotation, |
| 360 display::Display::RotationSource source) { | 373 display::Display::RotationSource source) { |
| 361 SetRotationLockedInternal(true); | 374 SetRotationLockedInternal(true); |
| 362 SetDisplayRotation(rotation, source); | 375 SetDisplayRotation(rotation, source); |
| 363 } | 376 } |
| 364 | 377 |
| 365 void ScreenOrientationController::LockRotationToOrientation( | 378 void ScreenOrientationController::LockRotationToOrientation( |
| 366 blink::WebScreenOrientationLockType lock_orientation) { | 379 blink::WebScreenOrientationLockType lock_orientation) { |
| 367 rotation_locked_orientation_ = lock_orientation; | 380 rotation_locked_orientation_ = lock_orientation; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 563 } |
| 551 | 564 |
| 552 bool ScreenOrientationController::CanRotateInLockedState() { | 565 bool ScreenOrientationController::CanRotateInLockedState() { |
| 553 return rotation_locked_orientation_ == | 566 return rotation_locked_orientation_ == |
| 554 blink::WebScreenOrientationLockLandscape || | 567 blink::WebScreenOrientationLockLandscape || |
| 555 rotation_locked_orientation_ == | 568 rotation_locked_orientation_ == |
| 556 blink::WebScreenOrientationLockPortrait; | 569 blink::WebScreenOrientationLockPortrait; |
| 557 } | 570 } |
| 558 | 571 |
| 559 } // namespace ash | 572 } // namespace ash |
| OLD | NEW |