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

Side by Side Diff: ash/wm/system_modal_container_layout_manager.cc

Issue 2808723004: Renames WmShell to ShellPort (Closed)
Patch Set: feedback Created 3 years, 8 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 (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/shell_window_ids.h" 9 #include "ash/public/cpp/shell_window_ids.h"
10 #include "ash/session/session_controller.h" 10 #include "ash/session/session_controller.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/shell_port.h"
12 #include "ash/wm/window_dimmer.h" 13 #include "ash/wm/window_dimmer.h"
13 #include "ash/wm/window_util.h" 14 #include "ash/wm/window_util.h"
14 #include "ash/wm_shell.h"
15 #include "ash/wm_window.h" 15 #include "ash/wm_window.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/stl_util.h" 17 #include "base/stl_util.h"
18 #include "ui/aura/client/aura_constants.h" 18 #include "ui/aura/client/aura_constants.h"
19 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
20 #include "ui/keyboard/keyboard_controller.h" 20 #include "ui/keyboard/keyboard_controller.h"
21 21
22 namespace ash { 22 namespace ash {
23 namespace { 23 namespace {
24 24
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 WmWindow* window, 59 WmWindow* window,
60 bool visible) { 60 bool visible) {
61 if (GetModalType(window) != ui::MODAL_TYPE_SYSTEM) 61 if (GetModalType(window) != ui::MODAL_TYPE_SYSTEM)
62 return; 62 return;
63 63
64 if (window->IsVisible()) { 64 if (window->IsVisible()) {
65 DCHECK(!base::ContainsValue(modal_windows_, window)); 65 DCHECK(!base::ContainsValue(modal_windows_, window));
66 AddModalWindow(window); 66 AddModalWindow(window);
67 } else { 67 } else {
68 if (RemoveModalWindow(window)) 68 if (RemoveModalWindow(window))
69 WmShell::Get()->OnModalWindowRemoved(window); 69 ShellPort::Get()->OnModalWindowRemoved(window);
70 } 70 }
71 } 71 }
72 72
73 void SystemModalContainerLayoutManager::OnWindowResized() { 73 void SystemModalContainerLayoutManager::OnWindowResized() {
74 PositionDialogsAfterWorkAreaResize(); 74 PositionDialogsAfterWorkAreaResize();
75 } 75 }
76 76
77 void SystemModalContainerLayoutManager::OnWindowAddedToLayout(WmWindow* child) { 77 void SystemModalContainerLayoutManager::OnWindowAddedToLayout(WmWindow* child) {
78 DCHECK(child->GetType() == ui::wm::WINDOW_TYPE_NORMAL || 78 DCHECK(child->GetType() == ui::wm::WINDOW_TYPE_NORMAL ||
79 child->GetType() == ui::wm::WINDOW_TYPE_POPUP); 79 child->GetType() == ui::wm::WINDOW_TYPE_POPUP);
80 // TODO(mash): IsUserSessionBlocked() depends on knowing the login state. We 80 // TODO(mash): IsUserSessionBlocked() depends on knowing the login state. We
81 // need a non-stub version of SessionStateDelegate. crbug.com/648964 81 // need a non-stub version of SessionStateDelegate. crbug.com/648964
82 if (!WmShell::Get()->IsRunningInMash()) { 82 if (!ShellPort::Get()->IsRunningInMash()) {
83 DCHECK(container_->GetShellWindowId() != 83 DCHECK(container_->GetShellWindowId() !=
84 kShellWindowId_LockSystemModalContainer || 84 kShellWindowId_LockSystemModalContainer ||
85 Shell::Get()->session_controller()->IsUserSessionBlocked()); 85 Shell::Get()->session_controller()->IsUserSessionBlocked());
86 } 86 }
87 // Since this is for SystemModal, there is no good reason to add windows 87 // Since this is for SystemModal, there is no good reason to add windows
88 // other than MODAL_TYPE_NONE or MODAL_TYPE_SYSTEM. DCHECK to avoid simple 88 // other than MODAL_TYPE_NONE or MODAL_TYPE_SYSTEM. DCHECK to avoid simple
89 // mistake. 89 // mistake.
90 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_CHILD); 90 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_CHILD);
91 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_WINDOW); 91 DCHECK_NE(GetModalType(child), ui::MODAL_TYPE_WINDOW);
92 92
(...skipping 30 matching lines...) Expand all
123 if (key != aura::client::kModalKey || !window->IsVisible()) 123 if (key != aura::client::kModalKey || !window->IsVisible())
124 return; 124 return;
125 125
126 WmWindow* wm_window = WmWindow::Get(window); 126 WmWindow* wm_window = WmWindow::Get(window);
127 if (window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM) { 127 if (window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM) {
128 if (base::ContainsValue(modal_windows_, wm_window)) 128 if (base::ContainsValue(modal_windows_, wm_window))
129 return; 129 return;
130 AddModalWindow(wm_window); 130 AddModalWindow(wm_window);
131 } else { 131 } else {
132 if (RemoveModalWindow(wm_window)) 132 if (RemoveModalWindow(wm_window))
133 WmShell::Get()->OnModalWindowRemoved(wm_window); 133 ShellPort::Get()->OnModalWindowRemoved(wm_window);
134 } 134 }
135 } 135 }
136 136
137 //////////////////////////////////////////////////////////////////////////////// 137 ////////////////////////////////////////////////////////////////////////////////
138 // SystemModalContainerLayoutManager, Keyboard::KeybaordControllerObserver 138 // SystemModalContainerLayoutManager, Keyboard::KeybaordControllerObserver
139 // implementation: 139 // implementation:
140 140
141 void SystemModalContainerLayoutManager::OnKeyboardBoundsChanging( 141 void SystemModalContainerLayoutManager::OnKeyboardBoundsChanging(
142 const gfx::Rect& new_bounds) { 142 const gfx::Rect& new_bounds) {
143 PositionDialogsAfterWorkAreaResize(); 143 PositionDialogsAfterWorkAreaResize();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void SystemModalContainerLayoutManager::AddModalWindow(WmWindow* window) { 200 void SystemModalContainerLayoutManager::AddModalWindow(WmWindow* window) {
201 if (modal_windows_.empty()) { 201 if (modal_windows_.empty()) {
202 WmWindow* capture_window = WmWindow::Get(wm::GetCaptureWindow()); 202 WmWindow* capture_window = WmWindow::Get(wm::GetCaptureWindow());
203 if (capture_window) 203 if (capture_window)
204 capture_window->ReleaseCapture(); 204 capture_window->ReleaseCapture();
205 } 205 }
206 DCHECK(window->IsVisible()); 206 DCHECK(window->IsVisible());
207 DCHECK(!base::ContainsValue(modal_windows_, window)); 207 DCHECK(!base::ContainsValue(modal_windows_, window));
208 208
209 modal_windows_.push_back(window); 209 modal_windows_.push_back(window);
210 WmShell::Get()->CreateModalBackground(window); 210 ShellPort::Get()->CreateModalBackground(window);
211 window->GetParent()->StackChildAtTop(window); 211 window->GetParent()->StackChildAtTop(window);
212 212
213 gfx::Rect target_bounds = window->GetBounds(); 213 gfx::Rect target_bounds = window->GetBounds();
214 target_bounds.AdjustToFit(GetUsableDialogArea()); 214 target_bounds.AdjustToFit(GetUsableDialogArea());
215 window->SetBounds(target_bounds); 215 window->SetBounds(target_bounds);
216 } 216 }
217 217
218 bool SystemModalContainerLayoutManager::RemoveModalWindow(WmWindow* window) { 218 bool SystemModalContainerLayoutManager::RemoveModalWindow(WmWindow* window) {
219 auto it = std::find(modal_windows_.begin(), modal_windows_.end(), window); 219 auto it = std::find(modal_windows_.begin(), modal_windows_.end(), window);
220 if (it == modal_windows_.end()) 220 if (it == modal_windows_.end())
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 bool SystemModalContainerLayoutManager::IsBoundsCentered( 273 bool SystemModalContainerLayoutManager::IsBoundsCentered(
274 const gfx::Rect& bounds) const { 274 const gfx::Rect& bounds) const {
275 gfx::Point window_center = bounds.CenterPoint(); 275 gfx::Point window_center = bounds.CenterPoint();
276 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); 276 gfx::Point container_center = GetUsableDialogArea().CenterPoint();
277 return std::abs(window_center.x() - container_center.x()) < 277 return std::abs(window_center.x() - container_center.x()) <
278 kCenterPixelDelta && 278 kCenterPixelDelta &&
279 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; 279 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta;
280 } 280 }
281 281
282 } // namespace ash 282 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698