| 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_configuration_controller.h" |
| 9 #include "ash/shared/app_types.h" | 9 #include "ash/shared/app_types.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/shell_port.h" | 11 #include "ash/shell_port.h" |
| 12 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | |
| 13 #include "ash/wm/mru_window_tracker.h" | 12 #include "ash/wm/mru_window_tracker.h" |
| 13 #include "ash/wm/tablet_mode/tablet_mode_controller.h" |
| 14 #include "ash/wm/window_state.h" | 14 #include "ash/wm/window_state.h" |
| 15 #include "base/auto_reset.h" | 15 #include "base/auto_reset.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "chromeos/accelerometer/accelerometer_reader.h" | 17 #include "chromeos/accelerometer/accelerometer_reader.h" |
| 18 #include "chromeos/accelerometer/accelerometer_types.h" | 18 #include "chromeos/accelerometer/accelerometer_types.h" |
| 19 #include "ui/aura/client/aura_constants.h" | 19 #include "ui/aura/client/aura_constants.h" |
| 20 #include "ui/chromeos/accelerometer/accelerometer_util.h" | 20 #include "ui/chromeos/accelerometer/accelerometer_util.h" |
| 21 #include "ui/display/display.h" | 21 #include "ui/display/display.h" |
| 22 #include "ui/display/manager/display_manager.h" | 22 #include "ui/display/manager/display_manager.h" |
| 23 #include "ui/display/manager/managed_display_info.h" | 23 #include "ui/display/manager/managed_display_info.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 pair.first->RemoveObserver(this); | 209 pair.first->RemoveObserver(this); |
| 210 lock_info_map_.clear(); | 210 lock_info_map_.clear(); |
| 211 Shell::Get()->activation_client()->RemoveObserver(this); | 211 Shell::Get()->activation_client()->RemoveObserver(this); |
| 212 SetRotationLockedInternal(false); | 212 SetRotationLockedInternal(false); |
| 213 if (user_rotation_ != current_rotation_) | 213 if (user_rotation_ != current_rotation_) |
| 214 SetDisplayRotation(user_rotation_, display::Display::ROTATION_SOURCE_USER); | 214 SetDisplayRotation(user_rotation_, display::Display::ROTATION_SOURCE_USER); |
| 215 } | 215 } |
| 216 | 216 |
| 217 bool ScreenOrientationController::ScreenOrientationProviderSupported() const { | 217 bool ScreenOrientationController::ScreenOrientationProviderSupported() const { |
| 218 return Shell::Get() | 218 return Shell::Get() |
| 219 ->maximize_mode_controller() | 219 ->tablet_mode_controller() |
| 220 ->IsMaximizeModeWindowManagerEnabled(); | 220 ->IsTabletModeWindowManagerEnabled(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void ScreenOrientationController::ToggleUserRotationLock() { | 223 void ScreenOrientationController::ToggleUserRotationLock() { |
| 224 if (!display::Display::HasInternalDisplay()) | 224 if (!display::Display::HasInternalDisplay()) |
| 225 return; | 225 return; |
| 226 | 226 |
| 227 if (user_rotation_locked()) { | 227 if (user_rotation_locked()) { |
| 228 SetLockToOrientation(blink::kWebScreenOrientationLockAny); | 228 SetLockToOrientation(blink::kWebScreenOrientationLockAny); |
| 229 } else { | 229 } else { |
| 230 display::Display::Rotation current_rotation = | 230 display::Display::Rotation current_rotation = |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // because application may not work correctly. | 296 // because application may not work correctly. |
| 297 | 297 |
| 298 // A user may change other display configuration settings. When the user | 298 // A user may change other display configuration settings. When the user |
| 299 // does change the rotation setting, then lock rotation to prevent the | 299 // does change the rotation setting, then lock rotation to prevent the |
| 300 // accelerometer from erasing their change. | 300 // accelerometer from erasing their change. |
| 301 SetRotationLockedInternal(true); | 301 SetRotationLockedInternal(true); |
| 302 user_rotation_ = current_rotation_ = user_rotation; | 302 user_rotation_ = current_rotation_ = user_rotation; |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 | 305 |
| 306 void ScreenOrientationController::OnMaximizeModeStarted() { | 306 void ScreenOrientationController::OnTabletModeStarted() { |
| 307 // Do not exit early, as the internal display can be determined after Maximize | 307 // Do not exit early, as the internal display can be determined after Tablet |
| 308 // Mode has started. (chrome-os-partner:38796) | 308 // Mode has started. (chrome-os-partner:38796) |
| 309 // Always start observing. | 309 // Always start observing. |
| 310 if (display::Display::HasInternalDisplay()) { | 310 if (display::Display::HasInternalDisplay()) { |
| 311 current_rotation_ = user_rotation_ = | 311 current_rotation_ = user_rotation_ = |
| 312 ShellPort::Get() | 312 ShellPort::Get() |
| 313 ->GetDisplayInfo(display::Display::InternalDisplayId()) | 313 ->GetDisplayInfo(display::Display::InternalDisplayId()) |
| 314 .GetActiveRotation(); | 314 .GetActiveRotation(); |
| 315 } | 315 } |
| 316 if (!rotation_locked_) | 316 if (!rotation_locked_) |
| 317 LoadDisplayRotationProperties(); | 317 LoadDisplayRotationProperties(); |
| 318 chromeos::AccelerometerReader::GetInstance()->AddObserver(this); | 318 chromeos::AccelerometerReader::GetInstance()->AddObserver(this); |
| 319 ShellPort::Get()->AddDisplayObserver(this); | 319 ShellPort::Get()->AddDisplayObserver(this); |
| 320 | 320 |
| 321 if (!display::Display::HasInternalDisplay()) | 321 if (!display::Display::HasInternalDisplay()) |
| 322 return; | 322 return; |
| 323 ApplyLockForActiveWindow(); | 323 ApplyLockForActiveWindow(); |
| 324 for (auto& observer : observers_) | 324 for (auto& observer : observers_) |
| 325 observer.OnUserRotationLockChanged(); | 325 observer.OnUserRotationLockChanged(); |
| 326 } | 326 } |
| 327 | 327 |
| 328 void ScreenOrientationController::OnMaximizeModeEnding() { | 328 void ScreenOrientationController::OnTabletModeEnding() { |
| 329 chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this); | 329 chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this); |
| 330 ShellPort::Get()->RemoveDisplayObserver(this); | 330 ShellPort::Get()->RemoveDisplayObserver(this); |
| 331 if (!display::Display::HasInternalDisplay()) | 331 if (!display::Display::HasInternalDisplay()) |
| 332 return; | 332 return; |
| 333 if (current_rotation_ != user_rotation_) | 333 if (current_rotation_ != user_rotation_) |
| 334 SetDisplayRotation(user_rotation_, display::Display::ROTATION_SOURCE_USER); | 334 SetDisplayRotation(user_rotation_, display::Display::ROTATION_SOURCE_USER); |
| 335 for (auto& observer : observers_) | 335 for (auto& observer : observers_) |
| 336 observer.OnUserRotationLockChanged(); | 336 observer.OnUserRotationLockChanged(); |
| 337 } | 337 } |
| 338 | 338 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 } | 578 } |
| 579 | 579 |
| 580 bool ScreenOrientationController::CanRotateInLockedState() { | 580 bool ScreenOrientationController::CanRotateInLockedState() { |
| 581 return rotation_locked_orientation_ == | 581 return rotation_locked_orientation_ == |
| 582 blink::kWebScreenOrientationLockLandscape || | 582 blink::kWebScreenOrientationLockLandscape || |
| 583 rotation_locked_orientation_ == | 583 rotation_locked_orientation_ == |
| 584 blink::kWebScreenOrientationLockPortrait; | 584 blink::kWebScreenOrientationLockPortrait; |
| 585 } | 585 } |
| 586 | 586 |
| 587 } // namespace ash | 587 } // namespace ash |
| OLD | NEW |