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

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

Issue 2784043002: cros: Treat set rotation for chrome.system.display API in touchview mode as if user rotation lock (Closed)
Patch Set: based on ps3's comments Created 3 years, 8 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
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/display/screen_orientation_controller_chromeos.h" 5 #include "ash/display/screen_orientation_controller_chromeos.h"
6 6
7 #include "ash/common/ash_switches.h" 7 #include "ash/common/ash_switches.h"
8 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 8 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
9 #include "ash/common/wm/mru_window_tracker.h" 9 #include "ash/common/wm/mru_window_tracker.h"
10 #include "ash/common/wm/window_state.h" 10 #include "ash/common/wm/window_state.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 ->IsMaximizeModeWindowManagerEnabled() && 217 ->IsMaximizeModeWindowManagerEnabled() &&
218 !base::CommandLine::ForCurrentProcess()->HasSwitch( 218 !base::CommandLine::ForCurrentProcess()->HasSwitch(
219 switches::kAshDisableScreenOrientationLock); 219 switches::kAshDisableScreenOrientationLock);
220 } 220 }
221 221
222 void ScreenOrientationController::ToggleUserRotationLock() { 222 void ScreenOrientationController::ToggleUserRotationLock() {
223 if (!display::Display::HasInternalDisplay()) 223 if (!display::Display::HasInternalDisplay())
224 return; 224 return;
225 225
226 if (user_rotation_locked()) { 226 if (user_rotation_locked()) {
227 user_locked_orientation_ = blink::WebScreenOrientationLockAny; 227 SetLockToOrientation(blink::WebScreenOrientationLockAny);
228 } else { 228 } else {
229 display::Display::Rotation current_rotation = 229 display::Display::Rotation current_rotation =
230 WmShell::Get() 230 WmShell::Get()
231 ->GetDisplayInfo(display::Display::InternalDisplayId()) 231 ->GetDisplayInfo(display::Display::InternalDisplayId())
232 .GetActiveRotation(); 232 .GetActiveRotation();
233 user_locked_orientation_ = RotationToOrientation(current_rotation); 233 SetLockToRotation(current_rotation);
234 } 234 }
235 base::AutoReset<bool> auto_ignore_display_configuration_updates( 235 }
236 &ignore_display_configuration_updates_, true);
237 Shell::GetInstance()->display_manager()->RegisterDisplayRotationProperties(
238 user_rotation_locked(), OrientationToRotation(user_locked_orientation_));
239 236
240 ApplyLockForActiveWindow(); 237 void ScreenOrientationController::SetLockToRotation(
241 for (auto& observer : observers_) 238 display::Display::Rotation rotation) {
242 observer.OnUserRotationLockChanged(); 239 if (!display::Display::HasInternalDisplay())
240 return;
241
242 SetLockToOrientation(RotationToOrientation(rotation));
243 } 243 }
244 244
245 void ScreenOrientationController::OnWindowActivated(ActivationReason reason, 245 void ScreenOrientationController::OnWindowActivated(ActivationReason reason,
246 aura::Window* gained_active, 246 aura::Window* gained_active,
247 aura::Window* lost_active) { 247 aura::Window* lost_active) {
248 ApplyLockForActiveWindow(); 248 ApplyLockForActiveWindow();
249 } 249 }
250 250
251 void ScreenOrientationController::OnWindowDestroying(aura::Window* window) { 251 void ScreenOrientationController::OnWindowDestroying(aura::Window* window) {
252 UnlockOrientationForWindow(WmWindow::Get(window)); 252 UnlockOrientationForWindow(WmWindow::Get(window));
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 void ScreenOrientationController::SetRotationLockedInternal( 351 void ScreenOrientationController::SetRotationLockedInternal(
352 bool rotation_locked) { 352 bool rotation_locked) {
353 if (rotation_locked_ == rotation_locked) 353 if (rotation_locked_ == rotation_locked)
354 return; 354 return;
355 rotation_locked_ = rotation_locked; 355 rotation_locked_ = rotation_locked;
356 if (!rotation_locked_) 356 if (!rotation_locked_)
357 rotation_locked_orientation_ = blink::WebScreenOrientationLockAny; 357 rotation_locked_orientation_ = blink::WebScreenOrientationLockAny;
358 } 358 }
359 359
360 void ScreenOrientationController::SetLockToOrientation(
361 blink::WebScreenOrientationLockType orientation) {
362 user_locked_orientation_ = orientation;
363 base::AutoReset<bool> auto_ignore_display_configuration_updates(
364 &ignore_display_configuration_updates_, true);
365 Shell::GetInstance()->display_manager()->RegisterDisplayRotationProperties(
366 user_rotation_locked(), OrientationToRotation(user_locked_orientation_));
367
368 ApplyLockForActiveWindow();
369 for (auto& observer : observers_)
370 observer.OnUserRotationLockChanged();
371 }
372
360 void ScreenOrientationController::LockRotation( 373 void ScreenOrientationController::LockRotation(
361 display::Display::Rotation rotation, 374 display::Display::Rotation rotation,
362 display::Display::RotationSource source) { 375 display::Display::RotationSource source) {
363 SetRotationLockedInternal(true); 376 SetRotationLockedInternal(true);
364 SetDisplayRotation(rotation, source); 377 SetDisplayRotation(rotation, source);
365 } 378 }
366 379
367 void ScreenOrientationController::LockRotationToOrientation( 380 void ScreenOrientationController::LockRotationToOrientation(
368 blink::WebScreenOrientationLockType lock_orientation) { 381 blink::WebScreenOrientationLockType lock_orientation) {
369 rotation_locked_orientation_ = lock_orientation; 382 rotation_locked_orientation_ = lock_orientation;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 } 565 }
553 566
554 bool ScreenOrientationController::CanRotateInLockedState() { 567 bool ScreenOrientationController::CanRotateInLockedState() {
555 return rotation_locked_orientation_ == 568 return rotation_locked_orientation_ ==
556 blink::WebScreenOrientationLockLandscape || 569 blink::WebScreenOrientationLockLandscape ||
557 rotation_locked_orientation_ == 570 rotation_locked_orientation_ ==
558 blink::WebScreenOrientationLockPortrait; 571 blink::WebScreenOrientationLockPortrait;
559 } 572 }
560 573
561 } // namespace ash 574 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698