OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "components/mus/ws/window_manager_access_policy.h" | |
6 | |
7 #include "components/mus/ws/access_policy_delegate.h" | |
8 #include "components/mus/ws/server_window.h" | |
9 | |
10 namespace mus { | |
11 namespace ws { | |
12 | |
13 WindowManagerAccessPolicy::WindowManagerAccessPolicy() {} | |
14 | |
15 WindowManagerAccessPolicy::~WindowManagerAccessPolicy() {} | |
16 | |
17 void WindowManagerAccessPolicy::Init(ClientSpecificId client_id, | |
18 AccessPolicyDelegate* delegate) { | |
19 client_id_ = client_id; | |
20 delegate_ = delegate; | |
21 } | |
22 | |
23 bool WindowManagerAccessPolicy::CanRemoveWindowFromParent( | |
24 const ServerWindow* window) const { | |
25 return true; | |
26 } | |
27 | |
28 bool WindowManagerAccessPolicy::CanAddWindow(const ServerWindow* parent, | |
29 const ServerWindow* child) const { | |
30 return true; | |
31 } | |
32 | |
33 bool WindowManagerAccessPolicy::CanAddTransientWindow( | |
34 const ServerWindow* parent, | |
35 const ServerWindow* child) const { | |
36 return true; | |
37 } | |
38 | |
39 bool WindowManagerAccessPolicy::CanRemoveTransientWindowFromParent( | |
40 const ServerWindow* window) const { | |
41 return true; | |
42 } | |
43 | |
44 bool WindowManagerAccessPolicy::CanSetModal( | |
45 const ServerWindow* window) const { | |
46 return true; | |
47 } | |
48 | |
49 bool WindowManagerAccessPolicy::CanReorderWindow( | |
50 const ServerWindow* window, | |
51 const ServerWindow* relative_window, | |
52 mojom::OrderDirection direction) const { | |
53 return true; | |
54 } | |
55 | |
56 bool WindowManagerAccessPolicy::CanDeleteWindow( | |
57 const ServerWindow* window) const { | |
58 return WasCreatedByThisClient(window); | |
59 } | |
60 | |
61 bool WindowManagerAccessPolicy::CanGetWindowTree( | |
62 const ServerWindow* window) const { | |
63 return true; | |
64 } | |
65 | |
66 bool WindowManagerAccessPolicy::CanDescendIntoWindowForWindowTree( | |
67 const ServerWindow* window) const { | |
68 return true; | |
69 } | |
70 | |
71 bool WindowManagerAccessPolicy::CanEmbed(const ServerWindow* window) const { | |
72 return !delegate_->HasRootForAccessPolicy(window); | |
73 } | |
74 | |
75 bool WindowManagerAccessPolicy::CanChangeWindowVisibility( | |
76 const ServerWindow* window) const { | |
77 if (WasCreatedByThisClient(window)) | |
78 return true; | |
79 // The WindowManager can change the visibility of the WindowManager root. | |
80 const ServerWindow* root = window->GetRoot(); | |
81 return root && window->parent() == root; | |
82 } | |
83 | |
84 bool WindowManagerAccessPolicy::CanChangeWindowOpacity( | |
85 const ServerWindow* window) const { | |
86 return WasCreatedByThisClient(window); | |
87 } | |
88 | |
89 bool WindowManagerAccessPolicy::CanSetWindowSurface( | |
90 const ServerWindow* window, | |
91 mus::mojom::SurfaceType surface_type) const { | |
92 if (surface_type == mojom::SurfaceType::UNDERLAY) | |
93 return WasCreatedByThisClient(window); | |
94 | |
95 if (delegate_->IsWindowRootOfAnotherTreeForAccessPolicy(window)) | |
96 return false; | |
97 return WasCreatedByThisClient(window) || | |
98 (delegate_->HasRootForAccessPolicy(window)); | |
99 } | |
100 | |
101 bool WindowManagerAccessPolicy::CanSetWindowBounds( | |
102 const ServerWindow* window) const { | |
103 return WasCreatedByThisClient(window); | |
104 } | |
105 | |
106 bool WindowManagerAccessPolicy::CanSetWindowProperties( | |
107 const ServerWindow* window) const { | |
108 return WasCreatedByThisClient(window); | |
109 } | |
110 | |
111 bool WindowManagerAccessPolicy::CanSetWindowTextInputState( | |
112 const ServerWindow* window) const { | |
113 return WasCreatedByThisClient(window); | |
114 } | |
115 | |
116 bool WindowManagerAccessPolicy::CanSetCapture( | |
117 const ServerWindow* window) const { | |
118 return WasCreatedByThisClient(window); | |
119 } | |
120 | |
121 bool WindowManagerAccessPolicy::CanSetFocus(const ServerWindow* window) const { | |
122 return true; | |
123 } | |
124 | |
125 bool WindowManagerAccessPolicy::CanSetClientArea( | |
126 const ServerWindow* window) const { | |
127 return WasCreatedByThisClient(window) || | |
128 delegate_->HasRootForAccessPolicy(window); | |
129 } | |
130 | |
131 bool WindowManagerAccessPolicy::CanSetHitTestMask( | |
132 const ServerWindow* window) const { | |
133 return WasCreatedByThisClient(window) || | |
134 delegate_->HasRootForAccessPolicy(window); | |
135 } | |
136 | |
137 bool WindowManagerAccessPolicy::CanSetCursorProperties( | |
138 const ServerWindow* window) const { | |
139 return WasCreatedByThisClient(window) || | |
140 delegate_->HasRootForAccessPolicy(window); | |
141 } | |
142 | |
143 bool WindowManagerAccessPolicy::ShouldNotifyOnHierarchyChange( | |
144 const ServerWindow* window, | |
145 const ServerWindow** new_parent, | |
146 const ServerWindow** old_parent) const { | |
147 // Notify if we've already told the window manager about the window, or if | |
148 // we've | |
149 // already told the window manager about the parent. The later handles the | |
150 // case of a window that wasn't parented to the root getting added to the | |
151 // root. | |
152 return IsWindowKnown(window) || (*new_parent && IsWindowKnown(*new_parent)); | |
153 } | |
154 | |
155 bool WindowManagerAccessPolicy::CanSetWindowManager() const { | |
156 return true; | |
157 } | |
158 | |
159 const ServerWindow* WindowManagerAccessPolicy::GetWindowForFocusChange( | |
160 const ServerWindow* focused) { | |
161 return focused; | |
162 } | |
163 | |
164 bool WindowManagerAccessPolicy::IsWindowKnown( | |
165 const ServerWindow* window) const { | |
166 return delegate_->IsWindowKnownForAccessPolicy(window); | |
167 } | |
168 | |
169 bool WindowManagerAccessPolicy::IsValidIdForNewWindow( | |
170 const ClientWindowId& id) const { | |
171 // The WindowManager see windows created from other clients. If the WM doesn't | |
172 // use the client id when creating windows the WM could end up with two | |
173 // windows with the same id. Because of this the wm must use the same | |
174 // client id for all windows it creates. | |
175 return WindowIdFromTransportId(id.id).client_id == client_id_; | |
176 } | |
177 | |
178 bool WindowManagerAccessPolicy::WasCreatedByThisClient( | |
179 const ServerWindow* window) const { | |
180 return window->id().client_id == client_id_; | |
181 } | |
182 | |
183 } // namespace ws | |
184 } // namespace mus | |
OLD | NEW |