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