| 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_controller.h" | 9 #include "ash/common/session/session_controller.h" |
| 10 #include "ash/common/wm/window_dimmer.h" | 10 #include "ash/common/wm/window_dimmer.h" |
| 11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "ash/common/wm_window.h" | 12 #include "ash/common/wm_window.h" |
| 13 #include "ash/public/cpp/shell_window_ids.h" | 13 #include "ash/public/cpp/shell_window_ids.h" |
| 14 #include "ash/shell.h" |
| 14 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 16 #include "ui/aura/client/aura_constants.h" | 17 #include "ui/aura/client/aura_constants.h" |
| 17 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 18 #include "ui/keyboard/keyboard_controller.h" | 19 #include "ui/keyboard/keyboard_controller.h" |
| 19 | 20 |
| 20 namespace ash { | 21 namespace ash { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // The center point of the window can diverge this much from the center point | 24 // The center point of the window can diverge this much from the center point |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 74 } |
| 74 | 75 |
| 75 void SystemModalContainerLayoutManager::OnWindowAddedToLayout(WmWindow* child) { | 76 void SystemModalContainerLayoutManager::OnWindowAddedToLayout(WmWindow* child) { |
| 76 DCHECK(child->GetType() == ui::wm::WINDOW_TYPE_NORMAL || | 77 DCHECK(child->GetType() == ui::wm::WINDOW_TYPE_NORMAL || |
| 77 child->GetType() == ui::wm::WINDOW_TYPE_POPUP); | 78 child->GetType() == ui::wm::WINDOW_TYPE_POPUP); |
| 78 // TODO(mash): IsUserSessionBlocked() depends on knowing the login state. We | 79 // TODO(mash): IsUserSessionBlocked() depends on knowing the login state. We |
| 79 // need a non-stub version of SessionStateDelegate. crbug.com/648964 | 80 // need a non-stub version of SessionStateDelegate. crbug.com/648964 |
| 80 if (!WmShell::Get()->IsRunningInMash()) { | 81 if (!WmShell::Get()->IsRunningInMash()) { |
| 81 DCHECK(container_->GetShellWindowId() != | 82 DCHECK(container_->GetShellWindowId() != |
| 82 kShellWindowId_LockSystemModalContainer || | 83 kShellWindowId_LockSystemModalContainer || |
| 83 WmShell::Get()->session_controller()->IsUserSessionBlocked()); | 84 Shell::Get()->session_controller()->IsUserSessionBlocked()); |
| 84 } | 85 } |
| 85 // Since this is for SystemModal, there is no good reason to add windows | 86 // Since this is for SystemModal, there is no good reason to add windows |
| 86 // other than MODAL_TYPE_NONE or MODAL_TYPE_SYSTEM. DCHECK to avoid simple | 87 // other than MODAL_TYPE_NONE or MODAL_TYPE_SYSTEM. DCHECK to avoid simple |
| 87 // mistake. | 88 // mistake. |
| 88 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_CHILD); | 89 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_CHILD); |
| 89 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_WINDOW); | 90 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_WINDOW); |
| 90 | 91 |
| 91 child->aura_window()->AddObserver(this); | 92 child->aura_window()->AddObserver(this); |
| 92 if (GetModalType(child) == ui::MODAL_TYPE_SYSTEM && child->IsVisible()) | 93 if (GetModalType(child) == ui::MODAL_TYPE_SYSTEM && child->IsVisible()) |
| 93 AddModalWindow(child); | 94 AddModalWindow(child); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 bool SystemModalContainerLayoutManager::IsBoundsCentered( | 272 bool SystemModalContainerLayoutManager::IsBoundsCentered( |
| 272 const gfx::Rect& bounds) const { | 273 const gfx::Rect& bounds) const { |
| 273 gfx::Point window_center = bounds.CenterPoint(); | 274 gfx::Point window_center = bounds.CenterPoint(); |
| 274 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); | 275 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); |
| 275 return std::abs(window_center.x() - container_center.x()) < | 276 return std::abs(window_center.x() - container_center.x()) < |
| 276 kCenterPixelDelta && | 277 kCenterPixelDelta && |
| 277 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; | 278 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; |
| 278 } | 279 } |
| 279 | 280 |
| 280 } // namespace ash | 281 } // namespace ash |
| OLD | NEW |