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 "mojo/services/view_manager/window_manager_access_policy.h" |
| 6 |
| 7 #include "mojo/services/view_manager/access_policy_delegate.h" |
| 8 #include "mojo/services/view_manager/node.h" |
| 9 #include "mojo/services/view_manager/view.h" |
| 10 |
| 11 namespace mojo { |
| 12 namespace service { |
| 13 |
| 14 // TODO(sky): document why this differs from default for each case. Maybe want |
| 15 // to subclass DefaultAccessPolicy. |
| 16 |
| 17 WindowManagerAccessPolicy::WindowManagerAccessPolicy( |
| 18 ConnectionSpecificId connection_id, |
| 19 AccessPolicyDelegate* delegate) |
| 20 : connection_id_(connection_id), |
| 21 delegate_(delegate) { |
| 22 } |
| 23 |
| 24 WindowManagerAccessPolicy::~WindowManagerAccessPolicy() { |
| 25 } |
| 26 |
| 27 bool WindowManagerAccessPolicy::CanRemoveNodeFromParent( |
| 28 const Node* node) const { |
| 29 return true; |
| 30 } |
| 31 |
| 32 bool WindowManagerAccessPolicy::CanAddNode(const Node* parent, |
| 33 const Node* child) const { |
| 34 return true; |
| 35 } |
| 36 |
| 37 bool WindowManagerAccessPolicy::CanReorderNode(const Node* node, |
| 38 const Node* relative_node, |
| 39 OrderDirection direction) const { |
| 40 return true; |
| 41 } |
| 42 |
| 43 bool WindowManagerAccessPolicy::CanDeleteNode(const Node* node) const { |
| 44 return node->id().connection_id == connection_id_; |
| 45 } |
| 46 |
| 47 bool WindowManagerAccessPolicy::CanDeleteView(const View* view) const { |
| 48 return view->id().connection_id == connection_id_; |
| 49 } |
| 50 |
| 51 bool WindowManagerAccessPolicy::CanSetView(const Node* node, |
| 52 const View* view) const { |
| 53 return !view || view->id().connection_id == connection_id_; |
| 54 } |
| 55 |
| 56 bool WindowManagerAccessPolicy::CanSetFocus(const Node* node) const { |
| 57 // TODO(beng): security. |
| 58 return true; |
| 59 } |
| 60 |
| 61 bool WindowManagerAccessPolicy::CanGetNodeTree(const Node* node) const { |
| 62 return true; |
| 63 } |
| 64 |
| 65 bool WindowManagerAccessPolicy::CanDescendIntoNodeForNodeTree( |
| 66 const Node* node) const { |
| 67 return true; |
| 68 } |
| 69 |
| 70 bool WindowManagerAccessPolicy::CanEmbed(const Node* node) const { |
| 71 return node->id().connection_id == connection_id_; |
| 72 } |
| 73 |
| 74 bool WindowManagerAccessPolicy::CanChangeNodeVisibility( |
| 75 const Node* node) const { |
| 76 return node->id().connection_id == connection_id_; |
| 77 } |
| 78 |
| 79 bool WindowManagerAccessPolicy::CanSetViewContents(const View* view) const { |
| 80 return view->id().connection_id == connection_id_; |
| 81 } |
| 82 |
| 83 bool WindowManagerAccessPolicy::CanSetNodeBounds(const Node* node) const { |
| 84 return node->id().connection_id == connection_id_; |
| 85 } |
| 86 |
| 87 bool WindowManagerAccessPolicy::ShouldNotifyOnHierarchyChange( |
| 88 const Node* node, |
| 89 const Node** new_parent, |
| 90 const Node** old_parent) const { |
| 91 // Notify if we've already told the window manager about the node, or if we've |
| 92 // already told the window manager about the parent. The later handles the |
| 93 // case of a node that wasn't parented to the root getting added to the root. |
| 94 return IsNodeKnown(node) || (*new_parent && IsNodeKnown(*new_parent)); |
| 95 } |
| 96 |
| 97 bool WindowManagerAccessPolicy::ShouldSendViewDeleted( |
| 98 const ViewId& view_id) const { |
| 99 return true; |
| 100 } |
| 101 |
| 102 bool WindowManagerAccessPolicy::IsNodeKnown(const Node* node) const { |
| 103 return delegate_->IsNodeKnownForAccessPolicy(node); |
| 104 } |
| 105 |
| 106 Id WindowManagerAccessPolicy::GetViewIdToSend(const Node* node, |
| 107 const View* view) const { |
| 108 return ViewIdToTransportId(view->id()); |
| 109 } |
| 110 |
| 111 } // namespace service |
| 112 } // namespace mojo |
OLD | NEW |