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

Side by Side Diff: ash/common/wm/container_finder.cc

Issue 2035543004: Shuffles and renames ash/common/wm classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: random changes for chrome tests Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/container_finder.h" 5 #include "ash/common/wm/container_finder.h"
6 6
7 #include "ash/common/shell_window_ids.h" 7 #include "ash/common/shell_window_ids.h"
8 #include "ash/common/wm/always_on_top_controller.h" 8 #include "ash/common/wm/always_on_top_controller.h"
9 #include "ash/common/wm/root_window_finder.h" 9 #include "ash/common/wm/root_window_finder.h"
10 #include "ash/common/wm/window_state.h" 10 #include "ash/common/wm/window_state.h"
11 #include "ash/common/wm/wm_globals.h" 11 #include "ash/common/wm_root_window_controller.h"
12 #include "ash/common/wm/wm_root_window_controller.h" 12 #include "ash/common/wm_shell.h"
13 #include "ash/common/wm/wm_window.h" 13 #include "ash/common/wm_window.h"
14 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
15 15
16 namespace ash { 16 namespace ash {
17 namespace wm { 17 namespace wm {
18 namespace { 18 namespace {
19 19
20 WmWindow* FindContainerRoot(WmGlobals* globals, const gfx::Rect& bounds) { 20 WmWindow* FindContainerRoot(WmShell* shell, const gfx::Rect& bounds) {
21 if (bounds == gfx::Rect()) 21 if (bounds == gfx::Rect())
22 return globals->GetRootWindowForNewWindows(); 22 return shell->GetRootWindowForNewWindows();
23 return GetRootWindowMatching(bounds); 23 return GetRootWindowMatching(bounds);
24 } 24 }
25 25
26 bool HasTransientParentWindow(const WmWindow* window) { 26 bool HasTransientParentWindow(const WmWindow* window) {
27 return window->GetTransientParent() && 27 return window->GetTransientParent() &&
28 window->GetTransientParent()->GetType() != ui::wm::WINDOW_TYPE_UNKNOWN; 28 window->GetTransientParent()->GetType() != ui::wm::WINDOW_TYPE_UNKNOWN;
29 } 29 }
30 30
31 WmWindow* GetSystemModalContainer(WmWindow* root, WmWindow* window) { 31 WmWindow* GetSystemModalContainer(WmWindow* root, WmWindow* window) {
32 DCHECK(window->IsSystemModal()); 32 DCHECK(window->IsSystemModal());
33 33
34 // If screen lock is not active and user session is active, 34 // If screen lock is not active and user session is active,
35 // all modal windows are placed into the normal modal container. 35 // all modal windows are placed into the normal modal container.
36 // In case of missing transient parent (it could happen for alerts from 36 // In case of missing transient parent (it could happen for alerts from
37 // background pages) assume that the window belongs to user session. 37 // background pages) assume that the window belongs to user session.
38 if (!window->GetGlobals()->IsUserSessionBlocked() || 38 if (!window->GetShell()->IsUserSessionBlocked() ||
39 !window->GetTransientParent()) { 39 !window->GetTransientParent()) {
40 return root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer); 40 return root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer);
41 } 41 }
42 42
43 // Otherwise those that originate from LockScreen container and above are 43 // Otherwise those that originate from LockScreen container and above are
44 // placed in the screen lock modal container. 44 // placed in the screen lock modal container.
45 int window_container_id = 45 int window_container_id =
46 window->GetTransientParent()->GetParent()->GetShellWindowId(); 46 window->GetTransientParent()->GetParent()->GetShellWindowId();
47 if (window_container_id < kShellWindowId_LockScreenContainer) 47 if (window_container_id < kShellWindowId_LockScreenContainer)
48 return root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer); 48 return root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer);
(...skipping 18 matching lines...) Expand all
67 67
68 WmWindow* GetDefaultParent(WmWindow* context, 68 WmWindow* GetDefaultParent(WmWindow* context,
69 WmWindow* window, 69 WmWindow* window,
70 const gfx::Rect& bounds) { 70 const gfx::Rect& bounds) {
71 WmWindow* target_root = nullptr; 71 WmWindow* target_root = nullptr;
72 WmWindow* transient_parent = window->GetTransientParent(); 72 WmWindow* transient_parent = window->GetTransientParent();
73 if (transient_parent) { 73 if (transient_parent) {
74 // Transient window should use the same root as its transient parent. 74 // Transient window should use the same root as its transient parent.
75 target_root = transient_parent->GetRootWindow(); 75 target_root = transient_parent->GetRootWindow();
76 } else { 76 } else {
77 target_root = FindContainerRoot(context->GetGlobals(), bounds); 77 target_root = FindContainerRoot(context->GetShell(), bounds);
78 } 78 }
79 79
80 switch (window->GetType()) { 80 switch (window->GetType()) {
81 case ui::wm::WINDOW_TYPE_NORMAL: 81 case ui::wm::WINDOW_TYPE_NORMAL:
82 case ui::wm::WINDOW_TYPE_POPUP: 82 case ui::wm::WINDOW_TYPE_POPUP:
83 if (window->IsSystemModal()) 83 if (window->IsSystemModal())
84 return GetSystemModalContainer(target_root, window); 84 return GetSystemModalContainer(target_root, window);
85 if (HasTransientParentWindow(window)) 85 if (HasTransientParentWindow(window))
86 return GetContainerForWindow(window->GetTransientParent()); 86 return GetContainerForWindow(window->GetTransientParent());
87 return GetContainerFromAlwaysOnTopController(target_root, window); 87 return GetContainerFromAlwaysOnTopController(target_root, window);
(...skipping 13 matching lines...) Expand all
101 default: 101 default:
102 NOTREACHED() << "Window " << window->GetShellWindowId() 102 NOTREACHED() << "Window " << window->GetShellWindowId()
103 << " has unhandled type " << window->GetType(); 103 << " has unhandled type " << window->GetType();
104 break; 104 break;
105 } 105 }
106 return nullptr; 106 return nullptr;
107 } 107 }
108 108
109 } // namespace wm 109 } // namespace wm
110 } // namespace ash 110 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698