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/system_modal_container_layout_manager.h" | 5 #include "ash/wm/system_modal_container_layout_manager.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "ash/public/cpp/config.h" | 9 #include "ash/public/cpp/config.h" |
10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 void SystemModalContainerLayoutManager::OnWindowResized() { | 74 void SystemModalContainerLayoutManager::OnWindowResized() { |
75 PositionDialogsAfterWorkAreaResize(); | 75 PositionDialogsAfterWorkAreaResize(); |
76 } | 76 } |
77 | 77 |
78 void SystemModalContainerLayoutManager::OnWindowAddedToLayout(WmWindow* child) { | 78 void SystemModalContainerLayoutManager::OnWindowAddedToLayout(WmWindow* child) { |
79 DCHECK(child->GetType() == ui::wm::WINDOW_TYPE_NORMAL || | 79 DCHECK(child->GetType() == ui::wm::WINDOW_TYPE_NORMAL || |
80 child->GetType() == ui::wm::WINDOW_TYPE_POPUP); | 80 child->GetType() == ui::wm::WINDOW_TYPE_POPUP); |
81 // TODO(mash): IsUserSessionBlocked() depends on knowing the login state. We | 81 // TODO(mash): IsUserSessionBlocked() depends on knowing the login state. We |
82 // need a non-stub version of SessionStateDelegate. crbug.com/648964 | 82 // need a non-stub version of SessionStateDelegate. crbug.com/648964 |
83 if (Shell::GetAshConfig() != Config::MASH) { | 83 if (Shell::GetAshConfig() != Config::MASH) { |
84 DCHECK(container_->GetShellWindowId() != | 84 DCHECK(container_->aura_window()->id() != |
85 kShellWindowId_LockSystemModalContainer || | 85 kShellWindowId_LockSystemModalContainer || |
86 Shell::Get()->session_controller()->IsUserSessionBlocked()); | 86 Shell::Get()->session_controller()->IsUserSessionBlocked()); |
87 } | 87 } |
88 // Since this is for SystemModal, there is no good reason to add windows | 88 // Since this is for SystemModal, there is no good reason to add windows |
89 // other than MODAL_TYPE_NONE or MODAL_TYPE_SYSTEM. DCHECK to avoid simple | 89 // other than MODAL_TYPE_NONE or MODAL_TYPE_SYSTEM. DCHECK to avoid simple |
90 // mistake. | 90 // mistake. |
91 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_CHILD); | 91 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_CHILD); |
92 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_WINDOW); | 92 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_WINDOW); |
93 | 93 |
94 child->aura_window()->AddObserver(this); | 94 child->aura_window()->AddObserver(this); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 if (!window_dimmer_) | 177 if (!window_dimmer_) |
178 return; | 178 return; |
179 | 179 |
180 if (keyboard::KeyboardController::GetInstance()) | 180 if (keyboard::KeyboardController::GetInstance()) |
181 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); | 181 keyboard::KeyboardController::GetInstance()->RemoveObserver(this); |
182 window_dimmer_.reset(); | 182 window_dimmer_.reset(); |
183 } | 183 } |
184 | 184 |
185 // static | 185 // static |
186 bool SystemModalContainerLayoutManager::IsModalBackground(WmWindow* window) { | 186 bool SystemModalContainerLayoutManager::IsModalBackground(WmWindow* window) { |
187 int id = window->GetParent()->GetShellWindowId(); | 187 int id = window->GetParent()->aura_window()->id(); |
188 if (id != kShellWindowId_SystemModalContainer && | 188 if (id != kShellWindowId_SystemModalContainer && |
189 id != kShellWindowId_LockSystemModalContainer) | 189 id != kShellWindowId_LockSystemModalContainer) |
190 return false; | 190 return false; |
191 SystemModalContainerLayoutManager* layout_manager = | 191 SystemModalContainerLayoutManager* layout_manager = |
192 static_cast<SystemModalContainerLayoutManager*>( | 192 static_cast<SystemModalContainerLayoutManager*>( |
193 window->GetParent()->GetLayoutManager()); | 193 window->GetParent()->GetLayoutManager()); |
194 return layout_manager->window_dimmer_ && | 194 return layout_manager->window_dimmer_ && |
195 WmWindow::Get(layout_manager->window_dimmer_->window()) == window; | 195 WmWindow::Get(layout_manager->window_dimmer_->window()) == window; |
196 } | 196 } |
197 | 197 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 bool SystemModalContainerLayoutManager::IsBoundsCentered( | 274 bool SystemModalContainerLayoutManager::IsBoundsCentered( |
275 const gfx::Rect& bounds) const { | 275 const gfx::Rect& bounds) const { |
276 gfx::Point window_center = bounds.CenterPoint(); | 276 gfx::Point window_center = bounds.CenterPoint(); |
277 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); | 277 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); |
278 return std::abs(window_center.x() - container_center.x()) < | 278 return std::abs(window_center.x() - container_center.x()) < |
279 kCenterPixelDelta && | 279 kCenterPixelDelta && |
280 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; | 280 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; |
281 } | 281 } |
282 | 282 |
283 } // namespace ash | 283 } // namespace ash |
OLD | NEW |