| 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 "components/mus/ws/window_tree.h" | 5 #include "components/mus/ws/window_tree.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "components/mus/ws/connection_manager.h" | 13 #include "components/mus/ws/connection_manager.h" |
| 14 #include "components/mus/ws/default_access_policy.h" | 14 #include "components/mus/ws/default_access_policy.h" |
| 15 #include "components/mus/ws/display.h" | 15 #include "components/mus/ws/display.h" |
| 16 #include "components/mus/ws/display_manager.h" | 16 #include "components/mus/ws/display_manager.h" |
| 17 #include "components/mus/ws/focus_controller.h" | 17 #include "components/mus/ws/focus_controller.h" |
| 18 #include "components/mus/ws/operation.h" | 18 #include "components/mus/ws/operation.h" |
| 19 #include "components/mus/ws/platform_display.h" | 19 #include "components/mus/ws/platform_display.h" |
| 20 #include "components/mus/ws/server_window.h" | 20 #include "components/mus/ws/server_window.h" |
| 21 #include "components/mus/ws/server_window_observer.h" | 21 #include "components/mus/ws/server_window_observer.h" |
| 22 #include "components/mus/ws/window_manager_access_policy.h" | |
| 23 #include "components/mus/ws/window_manager_state.h" | 22 #include "components/mus/ws/window_manager_state.h" |
| 24 #include "components/mus/ws/window_tree_binding.h" | 23 #include "components/mus/ws/window_tree_binding.h" |
| 25 #include "mojo/converters/geometry/geometry_type_converters.h" | 24 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 26 #include "mojo/converters/ime/ime_type_converters.h" | 25 #include "mojo/converters/ime/ime_type_converters.h" |
| 27 #include "mojo/converters/input_events/input_events_type_converters.h" | 26 #include "mojo/converters/input_events/input_events_type_converters.h" |
| 28 #include "mojo/converters/surfaces/surfaces_type_converters.h" | 27 #include "mojo/converters/surfaces/surfaces_type_converters.h" |
| 29 #include "ui/platform_window/text_input_state.h" | 28 #include "ui/platform_window/text_input_state.h" |
| 30 | 29 |
| 31 using mojo::Array; | 30 using mojo::Array; |
| 32 using mojo::Callback; | 31 using mojo::Callback; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 60 } | 59 } |
| 61 | 60 |
| 62 ServerWindow* target_; | 61 ServerWindow* target_; |
| 63 mojom::EventPtr event_; | 62 mojom::EventPtr event_; |
| 64 | 63 |
| 65 DISALLOW_COPY_AND_ASSIGN(TargetedEvent); | 64 DISALLOW_COPY_AND_ASSIGN(TargetedEvent); |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 WindowTree::WindowTree(ConnectionManager* connection_manager, | 67 WindowTree::WindowTree(ConnectionManager* connection_manager, |
| 69 const UserId& user_id, | 68 const UserId& user_id, |
| 70 ServerWindow* root) | 69 ServerWindow* root, |
| 70 scoped_ptr<AccessPolicy> access_policy) |
| 71 : connection_manager_(connection_manager), | 71 : connection_manager_(connection_manager), |
| 72 user_id_(user_id), | 72 user_id_(user_id), |
| 73 id_(connection_manager_->GetAndAdvanceNextConnectionId()), | 73 id_(connection_manager_->GetAndAdvanceNextConnectionId()), |
| 74 next_window_id_(1), | 74 next_window_id_(1), |
| 75 access_policy_(std::move(access_policy)), |
| 75 event_ack_id_(0), | 76 event_ack_id_(0), |
| 76 window_manager_internal_(nullptr) { | 77 window_manager_internal_(nullptr) { |
| 77 if (root) | 78 if (root) |
| 78 roots_.insert(root); | 79 roots_.insert(root); |
| 79 // TODO(sky): pass in type rather than inferring it. | 80 access_policy_->Init(id_, this); |
| 80 if (root && root->id().connection_id == kInvalidConnectionId) | |
| 81 access_policy_.reset(new WindowManagerAccessPolicy(id_, this)); | |
| 82 else | |
| 83 access_policy_.reset(new DefaultAccessPolicy(id_, this)); | |
| 84 } | 81 } |
| 85 | 82 |
| 86 WindowTree::~WindowTree() { | 83 WindowTree::~WindowTree() { |
| 87 DestroyWindows(); | 84 DestroyWindows(); |
| 88 } | 85 } |
| 89 | 86 |
| 90 void WindowTree::Init(scoped_ptr<WindowTreeBinding> binding, | 87 void WindowTree::Init(scoped_ptr<WindowTreeBinding> binding, |
| 91 mojom::WindowTreePtr tree) { | 88 mojom::WindowTreePtr tree) { |
| 92 DCHECK(!binding_); | 89 DCHECK(!binding_); |
| 93 binding_ = std::move(binding); | 90 binding_ = std::move(binding); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 } | 269 } |
| 273 | 270 |
| 274 bool WindowTree::Embed(const ClientWindowId& window_id, | 271 bool WindowTree::Embed(const ClientWindowId& window_id, |
| 275 mojom::WindowTreeClientPtr client) { | 272 mojom::WindowTreeClientPtr client) { |
| 276 if (!client || !CanEmbed(window_id)) | 273 if (!client || !CanEmbed(window_id)) |
| 277 return false; | 274 return false; |
| 278 ServerWindow* window = GetWindowByClientId(window_id); | 275 ServerWindow* window = GetWindowByClientId(window_id); |
| 279 PrepareForEmbed(window); | 276 PrepareForEmbed(window); |
| 280 // When embedding we don't know the user id of where the TreeClient came | 277 // When embedding we don't know the user id of where the TreeClient came |
| 281 // from. Use an invalid id, which limits what the client is able to do. | 278 // from. Use an invalid id, which limits what the client is able to do. |
| 282 connection_manager_->EmbedAtWindow(window, InvalidUserId(), | 279 connection_manager_->EmbedAtWindow(window, InvalidUserId(), std::move(client), |
| 283 std::move(client)); | 280 make_scoped_ptr(new DefaultAccessPolicy)); |
| 284 return true; | 281 return true; |
| 285 } | 282 } |
| 286 | 283 |
| 287 void WindowTree::DispatchInputEvent(ServerWindow* target, | 284 void WindowTree::DispatchInputEvent(ServerWindow* target, |
| 288 mojom::EventPtr event) { | 285 mojom::EventPtr event) { |
| 289 if (event_ack_id_) { | 286 if (event_ack_id_) { |
| 290 // This is currently waiting for an event ack. Add it to the queue. | 287 // This is currently waiting for an event ack. Add it to the queue. |
| 291 event_queue_.push( | 288 event_queue_.push( |
| 292 make_scoped_ptr(new TargetedEvent(target, std::move(event)))); | 289 make_scoped_ptr(new TargetedEvent(target, std::move(event)))); |
| 293 // TODO(sad): If the |event_queue_| grows too large, then this should notify | 290 // TODO(sad): If the |event_queue_| grows too large, then this should notify |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 } | 1363 } |
| 1367 | 1364 |
| 1368 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( | 1365 bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( |
| 1369 const ServerWindow* window) const { | 1366 const ServerWindow* window) const { |
| 1370 WindowTree* tree = connection_manager_->GetTreeWithRoot(window); | 1367 WindowTree* tree = connection_manager_->GetTreeWithRoot(window); |
| 1371 return tree && tree != this; | 1368 return tree && tree != this; |
| 1372 } | 1369 } |
| 1373 | 1370 |
| 1374 } // namespace ws | 1371 } // namespace ws |
| 1375 } // namespace mus | 1372 } // namespace mus |
| OLD | NEW |