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/common/wm/system_modal_container_layout_manager.h" | 5 #include "ash/common/wm/system_modal_container_layout_manager.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
10 #include "ash/common/wm/window_dimmer.h" | 10 #include "ash/common/wm/window_dimmer.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 void SystemModalContainerLayoutManager::OnWindowResized() { | 70 void SystemModalContainerLayoutManager::OnWindowResized() { |
71 PositionDialogsAfterWorkAreaResize(); | 71 PositionDialogsAfterWorkAreaResize(); |
72 } | 72 } |
73 | 73 |
74 void SystemModalContainerLayoutManager::OnWindowAddedToLayout(WmWindow* child) { | 74 void SystemModalContainerLayoutManager::OnWindowAddedToLayout(WmWindow* child) { |
75 DCHECK(child->GetType() == ui::wm::WINDOW_TYPE_NORMAL || | 75 DCHECK(child->GetType() == ui::wm::WINDOW_TYPE_NORMAL || |
76 child->GetType() == ui::wm::WINDOW_TYPE_POPUP); | 76 child->GetType() == ui::wm::WINDOW_TYPE_POPUP); |
77 DCHECK(container_->GetShellWindowId() != | 77 // TODO(mash): IsUserSessionBlocked() depends on knowing the login state. We |
78 kShellWindowId_LockSystemModalContainer || | 78 // need a non-stub version of SessionStateDelegate. crbug.com/648964 |
79 WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()); | 79 if (!WmShell::Get()->IsRunningInMash()) { |
| 80 DCHECK(container_->GetShellWindowId() != |
| 81 kShellWindowId_LockSystemModalContainer || |
| 82 WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()); |
| 83 } |
80 // Since this is for SystemModal, there is no good reason to add windows | 84 // Since this is for SystemModal, there is no good reason to add windows |
81 // other than MODAL_TYPE_NONE or MODAL_TYPE_SYSTEM. DCHECK to avoid simple | 85 // other than MODAL_TYPE_NONE or MODAL_TYPE_SYSTEM. DCHECK to avoid simple |
82 // mistake. | 86 // mistake. |
83 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_CHILD); | 87 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_CHILD); |
84 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_WINDOW); | 88 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_WINDOW); |
85 | 89 |
86 child->AddObserver(this); | 90 child->AddObserver(this); |
87 if (GetModalType(child) == ui::MODAL_TYPE_SYSTEM && child->IsVisible()) | 91 if (GetModalType(child) == ui::MODAL_TYPE_SYSTEM && child->IsVisible()) |
88 AddModalWindow(child); | 92 AddModalWindow(child); |
89 } | 93 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 bool SystemModalContainerLayoutManager::IsBoundsCentered( | 268 bool SystemModalContainerLayoutManager::IsBoundsCentered( |
265 const gfx::Rect& bounds) const { | 269 const gfx::Rect& bounds) const { |
266 gfx::Point window_center = bounds.CenterPoint(); | 270 gfx::Point window_center = bounds.CenterPoint(); |
267 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); | 271 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); |
268 return std::abs(window_center.x() - container_center.x()) < | 272 return std::abs(window_center.x() - container_center.x()) < |
269 kCenterPixelDelta && | 273 kCenterPixelDelta && |
270 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; | 274 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; |
271 } | 275 } |
272 | 276 |
273 } // namespace ash | 277 } // namespace ash |
OLD | NEW |