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/shell.h" | 10 #include "ash/shell.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 rotation_locked_(false), | 67 rotation_locked_(false), |
68 user_rotation_(gfx::Display::ROTATE_0), | 68 user_rotation_(gfx::Display::ROTATE_0), |
69 current_rotation_(gfx::Display::ROTATE_0) { | 69 current_rotation_(gfx::Display::ROTATE_0) { |
70 content::ScreenOrientationProvider::SetDelegate(this); | 70 content::ScreenOrientationProvider::SetDelegate(this); |
71 Shell::GetInstance()->AddShellObserver(this); | 71 Shell::GetInstance()->AddShellObserver(this); |
72 } | 72 } |
73 | 73 |
74 ScreenOrientationController::~ScreenOrientationController() { | 74 ScreenOrientationController::~ScreenOrientationController() { |
75 content::ScreenOrientationProvider::SetDelegate(NULL); | 75 content::ScreenOrientationProvider::SetDelegate(NULL); |
76 Shell::GetInstance()->RemoveShellObserver(this); | 76 Shell::GetInstance()->RemoveShellObserver(this); |
77 Shell::GetInstance()->accelerometer_reader()->RemoveObserver(this); | 77 chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this); |
78 Shell::GetInstance()->display_controller()->RemoveObserver(this); | 78 Shell::GetInstance()->display_controller()->RemoveObserver(this); |
79 } | 79 } |
80 | 80 |
81 void ScreenOrientationController::AddObserver(Observer* observer) { | 81 void ScreenOrientationController::AddObserver(Observer* observer) { |
82 observers_.AddObserver(observer); | 82 observers_.AddObserver(observer); |
83 } | 83 } |
84 | 84 |
85 void ScreenOrientationController::RemoveObserver(Observer* observer) { | 85 void ScreenOrientationController::RemoveObserver(Observer* observer) { |
86 observers_.RemoveObserver(observer); | 86 observers_.RemoveObserver(observer); |
87 } | 87 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 213 } |
214 | 214 |
215 void ScreenOrientationController::OnMaximizeModeStarted() { | 215 void ScreenOrientationController::OnMaximizeModeStarted() { |
216 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 216 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
217 if (!display_manager->HasInternalDisplay()) | 217 if (!display_manager->HasInternalDisplay()) |
218 return; | 218 return; |
219 current_rotation_ = user_rotation_ = | 219 current_rotation_ = user_rotation_ = |
220 display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId()) | 220 display_manager->GetDisplayInfo(gfx::Display::InternalDisplayId()) |
221 .rotation(); | 221 .rotation(); |
222 LoadDisplayRotationProperties(); | 222 LoadDisplayRotationProperties(); |
223 Shell::GetInstance()->accelerometer_reader()->AddObserver(this); | 223 chromeos::AccelerometerReader::GetInstance()->AddObserver(this); |
224 Shell::GetInstance()->display_controller()->AddObserver(this); | 224 Shell::GetInstance()->display_controller()->AddObserver(this); |
225 } | 225 } |
226 | 226 |
227 void ScreenOrientationController::OnMaximizeModeEnded() { | 227 void ScreenOrientationController::OnMaximizeModeEnded() { |
228 if (!Shell::GetInstance()->display_manager()->HasInternalDisplay()) | 228 if (!Shell::GetInstance()->display_manager()->HasInternalDisplay()) |
229 return; | 229 return; |
230 Shell::GetInstance()->accelerometer_reader()->RemoveObserver(this); | 230 chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this); |
231 Shell::GetInstance()->display_controller()->RemoveObserver(this); | 231 Shell::GetInstance()->display_controller()->RemoveObserver(this); |
232 if (current_rotation_ != user_rotation_) | 232 if (current_rotation_ != user_rotation_) |
233 SetDisplayRotation(user_rotation_); | 233 SetDisplayRotation(user_rotation_); |
234 } | 234 } |
235 | 235 |
236 void ScreenOrientationController::LockRotation( | 236 void ScreenOrientationController::LockRotation( |
237 gfx::Display::Rotation rotation) { | 237 gfx::Display::Rotation rotation) { |
238 SetRotationLocked(true); | 238 SetRotationLocked(true); |
239 SetDisplayRotation(rotation); | 239 SetDisplayRotation(rotation); |
240 } | 240 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 333 |
334 void ScreenOrientationController::LoadDisplayRotationProperties() { | 334 void ScreenOrientationController::LoadDisplayRotationProperties() { |
335 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 335 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
336 if (!display_manager->registered_internal_display_rotation_lock()) | 336 if (!display_manager->registered_internal_display_rotation_lock()) |
337 return; | 337 return; |
338 SetDisplayRotation(display_manager->registered_internal_display_rotation()); | 338 SetDisplayRotation(display_manager->registered_internal_display_rotation()); |
339 SetRotationLocked(true); | 339 SetRotationLocked(true); |
340 } | 340 } |
341 | 341 |
342 } // namespace ash | 342 } // namespace ash |
OLD | NEW |