| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/wm/stacking_controller.h" | 5 #include "ash/wm/stacking_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/session_state_delegate.h" | 8 #include "ash/session_state_delegate.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 //////////////////////////////////////////////////////////////////////////////// | 112 //////////////////////////////////////////////////////////////////////////////// |
| 113 // StackingController, private: | 113 // StackingController, private: |
| 114 | 114 |
| 115 aura::Window* StackingController::GetSystemModalContainer( | 115 aura::Window* StackingController::GetSystemModalContainer( |
| 116 aura::RootWindow* root, | 116 aura::RootWindow* root, |
| 117 aura::Window* window) const { | 117 aura::Window* window) const { |
| 118 DCHECK(IsSystemModal(window)); | 118 DCHECK(IsSystemModal(window)); |
| 119 | 119 |
| 120 // If screen lock is not active and user session is active, | 120 // If screen lock is not active and user session is active, |
| 121 // all modal windows are placed into the normal modal container. | 121 // all modal windows are placed into the normal modal container. |
| 122 if (!Shell::GetInstance()->session_state_delegate()->IsScreenLocked() && | 122 // In case of missing transient parent (it could happen for alerts from |
| 123 Shell::GetInstance()->session_state_delegate()-> | 123 // background pages) assume that the window belongs to user session. |
| 124 IsActiveUserSessionStarted()) { | 124 SessionStateDelegate* session_state_delegate = |
| 125 Shell::GetInstance()->session_state_delegate(); |
| 126 if ((!session_state_delegate->IsScreenLocked() && |
| 127 session_state_delegate->IsActiveUserSessionStarted()) || |
| 128 !window->transient_parent()) { |
| 125 return GetContainerById(root, | 129 return GetContainerById(root, |
| 126 internal::kShellWindowId_SystemModalContainer); | 130 internal::kShellWindowId_SystemModalContainer); |
| 127 } | 131 } |
| 128 | 132 |
| 129 // Otherwise those that originate from LockScreen container and above are | 133 // Otherwise those that originate from LockScreen container and above are |
| 130 // placed in the screen lock modal container. | 134 // placed in the screen lock modal container. |
| 131 aura::Window* lock_container = | |
| 132 GetContainerById(root, internal::kShellWindowId_LockScreenContainer); | |
| 133 int lock_container_id = lock_container->id(); | |
| 134 int window_container_id = window->transient_parent()->parent()->id(); | 135 int window_container_id = window->transient_parent()->parent()->id(); |
| 135 | |
| 136 aura::Window* container = NULL; | 136 aura::Window* container = NULL; |
| 137 if (window_container_id < lock_container_id) { | 137 if (window_container_id < internal::kShellWindowId_LockScreenContainer) { |
| 138 container = GetContainerById( | 138 container = GetContainerById( |
| 139 root, internal::kShellWindowId_SystemModalContainer); | 139 root, internal::kShellWindowId_SystemModalContainer); |
| 140 } else { | 140 } else { |
| 141 container = GetContainerById( | 141 container = GetContainerById( |
| 142 root, internal::kShellWindowId_LockSystemModalContainer); | 142 root, internal::kShellWindowId_LockSystemModalContainer); |
| 143 } | 143 } |
| 144 | 144 |
| 145 return container; | 145 return container; |
| 146 } | 146 } |
| 147 | 147 |
| 148 // TODO(oshima): Remove this once extended desktop is on by default. | 148 // TODO(oshima): Remove this once extended desktop is on by default. |
| 149 internal::AlwaysOnTopController* | 149 internal::AlwaysOnTopController* |
| 150 StackingController::GetAlwaysOnTopController(aura::RootWindow* root_window) { | 150 StackingController::GetAlwaysOnTopController(aura::RootWindow* root_window) { |
| 151 internal::AlwaysOnTopController* controller = | 151 internal::AlwaysOnTopController* controller = |
| 152 root_window->GetProperty(internal::kAlwaysOnTopControllerKey); | 152 root_window->GetProperty(internal::kAlwaysOnTopControllerKey); |
| 153 if (!controller) { | 153 if (!controller) { |
| 154 controller = new internal::AlwaysOnTopController; | 154 controller = new internal::AlwaysOnTopController; |
| 155 controller->SetAlwaysOnTopContainer( | 155 controller->SetAlwaysOnTopContainer( |
| 156 root_window->GetChildById( | 156 root_window->GetChildById( |
| 157 internal::kShellWindowId_AlwaysOnTopContainer)); | 157 internal::kShellWindowId_AlwaysOnTopContainer)); |
| 158 // RootWindow owns the AlwaysOnTopController object. | 158 // RootWindow owns the AlwaysOnTopController object. |
| 159 root_window->SetProperty(internal::kAlwaysOnTopControllerKey, controller); | 159 root_window->SetProperty(internal::kAlwaysOnTopControllerKey, controller); |
| 160 } | 160 } |
| 161 return controller; | 161 return controller; |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace ash | 164 } // namespace ash |
| OLD | NEW |