Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: ash/content/display/screen_orientation_controller_chromeos.cc

Issue 822503003: Change AccelerometerReader to a Singleton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update new dependency Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ash/shell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698