| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "services/ui/ws/window_tree.h" | 5 #include "services/ui/ws/window_tree.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 created_window_map_[window_id] = window; | 276 created_window_map_[window_id] = window; |
| 277 client_id_to_window_id_map_[client_window_id] = window_id; | 277 client_id_to_window_id_map_[client_window_id] = window_id; |
| 278 window_id_to_client_id_map_[window_id] = client_window_id; | 278 window_id_to_client_id_map_[window_id] = client_window_id; |
| 279 return true; | 279 return true; |
| 280 } | 280 } |
| 281 | 281 |
| 282 bool WindowTree::AddWindow(const ClientWindowId& parent_id, | 282 bool WindowTree::AddWindow(const ClientWindowId& parent_id, |
| 283 const ClientWindowId& child_id) { | 283 const ClientWindowId& child_id) { |
| 284 ServerWindow* parent = GetWindowByClientId(parent_id); | 284 ServerWindow* parent = GetWindowByClientId(parent_id); |
| 285 ServerWindow* child = GetWindowByClientId(child_id); | 285 ServerWindow* child = GetWindowByClientId(child_id); |
| 286 DVLOG(3) << "add window client=" << id_ | 286 if (parent && child && child->parent() != parent && |
| 287 << " client parent window_id=" << parent_id.id | 287 !child->Contains(parent) && access_policy_->CanAddWindow(parent, child)) { |
| 288 << " global window_id=" | 288 Operation op(this, window_server_, OperationType::ADD_WINDOW); |
| 289 << (parent ? WindowIdToTransportId(parent->id()) : 0) | 289 parent->Add(child); |
| 290 << " client child window_id= " << child_id.id << " global window_id=" | 290 return true; |
| 291 << (child ? WindowIdToTransportId(child->id()) : 0); | |
| 292 if (!parent) { | |
| 293 DVLOG(1) << "add failed, no parent"; | |
| 294 return false; | |
| 295 } | 291 } |
| 296 if (!child) { | 292 return false; |
| 297 DVLOG(1) << "add failed, no child"; | |
| 298 return false; | |
| 299 } | |
| 300 if (child->parent() == parent) { | |
| 301 DVLOG(1) << "add failed, already has parent"; | |
| 302 return false; | |
| 303 } | |
| 304 if (child->Contains(parent)) { | |
| 305 DVLOG(1) << "add failed, child contains parent"; | |
| 306 return false; | |
| 307 } | |
| 308 if (!access_policy_->CanAddWindow(parent, child)) { | |
| 309 DVLOG(1) << "add failed, access policy denied add"; | |
| 310 return false; | |
| 311 } | |
| 312 Operation op(this, window_server_, OperationType::ADD_WINDOW); | |
| 313 parent->Add(child); | |
| 314 return true; | |
| 315 } | 293 } |
| 316 | 294 |
| 317 bool WindowTree::AddTransientWindow(const ClientWindowId& window_id, | 295 bool WindowTree::AddTransientWindow(const ClientWindowId& window_id, |
| 318 const ClientWindowId& transient_window_id) { | 296 const ClientWindowId& transient_window_id) { |
| 319 ServerWindow* window = GetWindowByClientId(window_id); | 297 ServerWindow* window = GetWindowByClientId(window_id); |
| 320 ServerWindow* transient_window = GetWindowByClientId(transient_window_id); | 298 ServerWindow* transient_window = GetWindowByClientId(transient_window_id); |
| 321 if (window && transient_window && !transient_window->Contains(window) && | 299 if (window && transient_window && !transient_window->Contains(window) && |
| 322 access_policy_->CanAddTransientWindow(window, transient_window)) { | 300 access_policy_->CanAddTransientWindow(window, transient_window)) { |
| 323 Operation op(this, window_server_, OperationType::ADD_TRANSIENT_WINDOW); | 301 Operation op(this, window_server_, OperationType::ADD_TRANSIENT_WINDOW); |
| 324 return window->AddTransientWindow(transient_window); | 302 return window->AddTransientWindow(transient_window); |
| (...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, | 1994 client()->OnCompleteDrop(client_window_id.id, event_flags, cursor_offset, |
| 2017 effect_bitmask, callback); | 1995 effect_bitmask, callback); |
| 2018 } | 1996 } |
| 2019 | 1997 |
| 2020 void WindowTree::PerformOnDragDropDone() { | 1998 void WindowTree::PerformOnDragDropDone() { |
| 2021 client()->OnDragDropDone(); | 1999 client()->OnDragDropDone(); |
| 2022 } | 2000 } |
| 2023 | 2001 |
| 2024 } // namespace ws | 2002 } // namespace ws |
| 2025 } // namespace ui | 2003 } // namespace ui |
| OLD | NEW |