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/window_manager_access_policy.h" | |
6 | |
7 #include "components/mus/access_policy_delegate.h" | |
8 #include "components/mus/server_view.h" | |
9 | |
10 namespace mus { | |
11 | |
12 // TODO(sky): document why this differs from default for each case. Maybe want | |
13 // to subclass DefaultAccessPolicy. | |
14 | |
15 WindowManagerAccessPolicy::WindowManagerAccessPolicy( | |
16 ConnectionSpecificId connection_id, | |
17 AccessPolicyDelegate* delegate) | |
18 : connection_id_(connection_id), delegate_(delegate) {} | |
19 | |
20 WindowManagerAccessPolicy::~WindowManagerAccessPolicy() {} | |
21 | |
22 bool WindowManagerAccessPolicy::CanRemoveViewFromParent( | |
23 const ServerView* view) const { | |
24 return true; | |
25 } | |
26 | |
27 bool WindowManagerAccessPolicy::CanAddView(const ServerView* parent, | |
28 const ServerView* child) const { | |
29 return true; | |
30 } | |
31 | |
32 bool WindowManagerAccessPolicy::CanReorderView( | |
33 const ServerView* view, | |
34 const ServerView* relative_view, | |
35 mojo::OrderDirection direction) const { | |
36 return true; | |
37 } | |
38 | |
39 bool WindowManagerAccessPolicy::CanDeleteView(const ServerView* view) const { | |
40 return view->id().connection_id == connection_id_; | |
41 } | |
42 | |
43 bool WindowManagerAccessPolicy::CanGetViewTree(const ServerView* view) const { | |
44 return true; | |
45 } | |
46 | |
47 bool WindowManagerAccessPolicy::CanDescendIntoViewForViewTree( | |
48 const ServerView* view) const { | |
49 return true; | |
50 } | |
51 | |
52 bool WindowManagerAccessPolicy::CanEmbed(const ServerView* view, | |
53 uint32_t policy_bitmask) const { | |
54 return !delegate_->IsRootForAccessPolicy(view->id()); | |
55 } | |
56 | |
57 bool WindowManagerAccessPolicy::CanChangeViewVisibility( | |
58 const ServerView* view) const { | |
59 // The WindowManager can change the visibility of the root too. | |
60 return view->id().connection_id == connection_id_ || | |
61 (view->GetRoot() == view); | |
62 } | |
63 | |
64 bool WindowManagerAccessPolicy::CanSetViewSurfaceId( | |
65 const ServerView* view) const { | |
66 if (delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view)) | |
67 return false; | |
68 return view->id().connection_id == connection_id_ || | |
69 (delegate_->IsRootForAccessPolicy(view->id())); | |
70 } | |
71 | |
72 bool WindowManagerAccessPolicy::CanSetViewBounds(const ServerView* view) const { | |
73 return view->id().connection_id == connection_id_; | |
74 } | |
75 | |
76 bool WindowManagerAccessPolicy::CanSetViewProperties( | |
77 const ServerView* view) const { | |
78 return view->id().connection_id == connection_id_; | |
79 } | |
80 | |
81 bool WindowManagerAccessPolicy::CanSetViewTextInputState( | |
82 const ServerView* view) const { | |
83 return view->id().connection_id == connection_id_; | |
84 } | |
85 | |
86 bool WindowManagerAccessPolicy::CanSetFocus(const ServerView* view) const { | |
87 return true; | |
88 } | |
89 | |
90 bool WindowManagerAccessPolicy::ShouldNotifyOnHierarchyChange( | |
91 const ServerView* view, | |
92 const ServerView** new_parent, | |
93 const ServerView** old_parent) const { | |
94 // Notify if we've already told the window manager about the view, or if we've | |
95 // already told the window manager about the parent. The later handles the | |
96 // case of a view that wasn't parented to the root getting added to the root. | |
97 return IsViewKnown(view) || (*new_parent && IsViewKnown(*new_parent)); | |
98 } | |
99 | |
100 const ServerView* WindowManagerAccessPolicy::GetViewForFocusChange( | |
101 const ServerView* focused) { | |
102 return focused; | |
103 } | |
104 | |
105 bool WindowManagerAccessPolicy::IsViewKnown(const ServerView* view) const { | |
106 return delegate_->IsViewKnownForAccessPolicy(view); | |
107 } | |
108 | |
109 } // namespace mus | |
OLD | NEW |