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

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

Issue 2112013002: Allow arc app to lock screen orientation in TouchView/Tablet mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow arc app to lock screen orientation in TouchView/Tablet mode Created 4 years, 5 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/display/display_info.h" 8 #include "ash/common/display/display_info.h"
9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 void ScreenOrientationController::UnlockOrientationForWindow( 106 void ScreenOrientationController::UnlockOrientationForWindow(
107 aura::Window* window) { 107 aura::Window* window) {
108 locking_windows_.erase(window); 108 locking_windows_.erase(window);
109 if (locking_windows_.empty()) 109 if (locking_windows_.empty())
110 Shell::GetInstance()->activation_client()->RemoveObserver(this); 110 Shell::GetInstance()->activation_client()->RemoveObserver(this);
111 window->RemoveObserver(this); 111 window->RemoveObserver(this);
112 ApplyLockForActiveWindow(); 112 ApplyLockForActiveWindow();
113 } 113 }
114 114
115 void ScreenOrientationController::UnlockAll() {
116 for (auto pair : locking_windows_)
117 pair.first->RemoveObserver(this);
118 locking_windows_.clear();
119 Shell::GetInstance()->activation_client()->RemoveObserver(this);
120 SetRotationLocked(false);
121 if (user_rotation_ != current_rotation_)
122 SetDisplayRotation(user_rotation_, display::Display::ROTATION_SOURCE_USER);
123 }
124
115 bool ScreenOrientationController::ScreenOrientationProviderSupported() const { 125 bool ScreenOrientationController::ScreenOrientationProviderSupported() const {
116 return WmShell::Get() 126 return WmShell::Get()
117 ->maximize_mode_controller() 127 ->maximize_mode_controller()
118 ->IsMaximizeModeWindowManagerEnabled() && 128 ->IsMaximizeModeWindowManagerEnabled() &&
119 !base::CommandLine::ForCurrentProcess()->HasSwitch( 129 !base::CommandLine::ForCurrentProcess()->HasSwitch(
120 switches::kAshDisableScreenOrientationLock); 130 switches::kAshDisableScreenOrientationLock);
121 } 131 }
122 132
123 void ScreenOrientationController::SetRotationLocked(bool rotation_locked) { 133 void ScreenOrientationController::SetRotationLocked(bool rotation_locked) {
124 if (rotation_locked_ == rotation_locked) 134 if (rotation_locked_ == rotation_locked)
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 if (!display_manager->registered_internal_display_rotation_lock()) 389 if (!display_manager->registered_internal_display_rotation_lock())
380 return; 390 return;
381 SetDisplayRotation(display_manager->registered_internal_display_rotation(), 391 SetDisplayRotation(display_manager->registered_internal_display_rotation(),
382 display::Display::ROTATION_SOURCE_ACCELEROMETER); 392 display::Display::ROTATION_SOURCE_ACCELEROMETER);
383 SetRotationLocked(true); 393 SetRotationLocked(true);
384 } 394 }
385 395
386 void ScreenOrientationController::ApplyLockForActiveWindow() { 396 void ScreenOrientationController::ApplyLockForActiveWindow() {
387 aura::Window* active_window = 397 aura::Window* active_window =
388 Shell::GetInstance()->activation_client()->GetActiveWindow(); 398 Shell::GetInstance()->activation_client()->GetActiveWindow();
389 for (auto const& windows : locking_windows_) { 399 if (active_window) {
390 if (windows.first->TargetVisibility() && 400 for (auto const& windows : locking_windows_) {
391 active_window->Contains(windows.first)) { 401 if (windows.first->TargetVisibility() &&
392 LockRotationToOrientation(windows.second); 402 active_window->Contains(windows.first)) {
393 return; 403 LockRotationToOrientation(windows.second);
404 return;
405 }
394 } 406 }
395 } 407 }
396 SetRotationLocked(false); 408 SetRotationLocked(false);
397 } 409 }
398 410
399 bool ScreenOrientationController::IsRotationAllowedInLockedState( 411 bool ScreenOrientationController::IsRotationAllowedInLockedState(
400 display::Display::Rotation rotation) { 412 display::Display::Rotation rotation) {
401 if (!rotation_locked_) 413 if (!rotation_locked_)
402 return true; 414 return true;
403 415
(...skipping 11 matching lines...) Expand all
415 } 427 }
416 428
417 bool ScreenOrientationController::CanRotateInLockedState() { 429 bool ScreenOrientationController::CanRotateInLockedState() {
418 return rotation_locked_orientation_ == 430 return rotation_locked_orientation_ ==
419 blink::WebScreenOrientationLockLandscape || 431 blink::WebScreenOrientationLockLandscape ||
420 rotation_locked_orientation_ == 432 rotation_locked_orientation_ ==
421 blink::WebScreenOrientationLockPortrait; 433 blink::WebScreenOrientationLockPortrait;
422 } 434 }
423 435
424 } // namespace ash 436 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/screen_orientation_controller_chromeos.h ('k') | chrome/browser/ui/app_list/arc/arc_app_list_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698