| 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/content/display/screen_orientation_controller_chromeos.h" | 5 #include "ash/content/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_info.h" | 8 #include "ash/display/display_info.h" |
| 9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/rotator/screen_rotation_animator.h" | 10 #include "ash/rotator/screen_rotation_animator.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 189 } |
| 190 | 190 |
| 191 void ScreenOrientationController::Unlock(content::WebContents* web_contents) { | 191 void ScreenOrientationController::Unlock(content::WebContents* web_contents) { |
| 192 aura::Window* requesting_window = web_contents->GetNativeView(); | 192 aura::Window* requesting_window = web_contents->GetNativeView(); |
| 193 RemoveLockingWindow(requesting_window); | 193 RemoveLockingWindow(requesting_window); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void ScreenOrientationController::OnDisplayConfigurationChanged() { | 196 void ScreenOrientationController::OnDisplayConfigurationChanged() { |
| 197 if (ignore_display_configuration_updates_) | 197 if (ignore_display_configuration_updates_) |
| 198 return; | 198 return; |
| 199 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | |
| 200 if (!display_manager->HasInternalDisplay()) | |
| 201 return; | |
| 202 gfx::Display::Rotation user_rotation = | 199 gfx::Display::Rotation user_rotation = |
| 203 display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId()) | 200 Shell::GetInstance() |
| 201 ->display_manager() |
| 202 ->GetDisplayInfo(gfx::Display::InternalDisplayId()) |
| 204 .rotation(); | 203 .rotation(); |
| 205 if (user_rotation != current_rotation_) { | 204 if (user_rotation != current_rotation_) { |
| 206 // A user may change other display configuration settings. When the user | 205 // A user may change other display configuration settings. When the user |
| 207 // does change the rotation setting, then lock rotation to prevent the | 206 // does change the rotation setting, then lock rotation to prevent the |
| 208 // accelerometer from erasing their change. | 207 // accelerometer from erasing their change. |
| 209 SetRotationLocked(true); | 208 SetRotationLocked(true); |
| 210 user_rotation_ = current_rotation_ = user_rotation; | 209 user_rotation_ = current_rotation_ = user_rotation; |
| 211 } | 210 } |
| 212 } | 211 } |
| 213 | 212 |
| 214 void ScreenOrientationController::OnMaximizeModeStarted() { | 213 void ScreenOrientationController::OnMaximizeModeStarted() { |
| 215 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 214 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 216 // Do not exit early, as the internal display can be determined after Maximize | 215 if (!display_manager->HasInternalDisplay()) |
| 217 // Mode has started. (chrome-os-partner:38796) | 216 return; |
| 218 // Always start observing. | 217 current_rotation_ = user_rotation_ = |
| 219 if (display_manager->HasInternalDisplay()) { | 218 display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId()) |
| 220 current_rotation_ = user_rotation_ = | 219 .rotation(); |
| 221 display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId()) | |
| 222 .rotation(); | |
| 223 } | |
| 224 if (!rotation_locked_) | 220 if (!rotation_locked_) |
| 225 LoadDisplayRotationProperties(); | 221 LoadDisplayRotationProperties(); |
| 226 chromeos::AccelerometerReader::GetInstance()->AddObserver(this); | 222 chromeos::AccelerometerReader::GetInstance()->AddObserver(this); |
| 227 Shell::GetInstance()->display_controller()->AddObserver(this); | 223 Shell::GetInstance()->display_controller()->AddObserver(this); |
| 228 } | 224 } |
| 229 | 225 |
| 230 void ScreenOrientationController::OnMaximizeModeEnded() { | 226 void ScreenOrientationController::OnMaximizeModeEnded() { |
| 227 if (!Shell::GetInstance()->display_manager()->HasInternalDisplay()) |
| 228 return; |
| 231 chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this); | 229 chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this); |
| 232 Shell::GetInstance()->display_controller()->RemoveObserver(this); | 230 Shell::GetInstance()->display_controller()->RemoveObserver(this); |
| 233 if (current_rotation_ != user_rotation_) | 231 if (current_rotation_ != user_rotation_) |
| 234 SetDisplayRotation(user_rotation_); | 232 SetDisplayRotation(user_rotation_); |
| 235 } | 233 } |
| 236 | 234 |
| 237 void ScreenOrientationController::LockRotation( | 235 void ScreenOrientationController::LockRotation( |
| 238 gfx::Display::Rotation rotation) { | 236 gfx::Display::Rotation rotation) { |
| 239 SetRotationLocked(true); | 237 SetRotationLocked(true); |
| 240 SetDisplayRotation(rotation); | 238 SetDisplayRotation(rotation); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 } | 414 } |
| 417 | 415 |
| 418 bool ScreenOrientationController::CanRotateInLockedState() { | 416 bool ScreenOrientationController::CanRotateInLockedState() { |
| 419 return rotation_locked_orientation_ == | 417 return rotation_locked_orientation_ == |
| 420 blink::WebScreenOrientationLockLandscape || | 418 blink::WebScreenOrientationLockLandscape || |
| 421 rotation_locked_orientation_ == | 419 rotation_locked_orientation_ == |
| 422 blink::WebScreenOrientationLockPortrait; | 420 blink::WebScreenOrientationLockPortrait; |
| 423 } | 421 } |
| 424 | 422 |
| 425 } // namespace ash | 423 } // namespace ash |
| OLD | NEW |