Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: components/mus/ws/default_access_policy.cc

Issue 1406153004: components/mus/public/interfaces View => Window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yet another rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/ws/default_access_policy.h ('k') | components/mus/ws/display_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/default_access_policy.h" 5 #include "components/mus/ws/default_access_policy.h"
6 6
7 #include "components/mus/ws/access_policy_delegate.h" 7 #include "components/mus/ws/access_policy_delegate.h"
8 #include "components/mus/ws/server_view.h" 8 #include "components/mus/ws/server_view.h"
9 9
10 namespace mus { 10 namespace mus {
11 11
12 DefaultAccessPolicy::DefaultAccessPolicy(ConnectionSpecificId connection_id, 12 DefaultAccessPolicy::DefaultAccessPolicy(ConnectionSpecificId connection_id,
13 AccessPolicyDelegate* delegate) 13 AccessPolicyDelegate* delegate)
14 : connection_id_(connection_id), delegate_(delegate) {} 14 : connection_id_(connection_id), delegate_(delegate) {}
15 15
16 DefaultAccessPolicy::~DefaultAccessPolicy() {} 16 DefaultAccessPolicy::~DefaultAccessPolicy() {}
17 17
18 bool DefaultAccessPolicy::CanRemoveViewFromParent( 18 bool DefaultAccessPolicy::CanRemoveWindowFromParent(
19 const ServerView* view) const { 19 const ServerView* view) const {
20 if (!WasCreatedByThisConnection(view)) 20 if (!WasCreatedByThisConnection(view))
21 return false; // Can only unparent views we created. 21 return false; // Can only unparent views we created.
22 22
23 return delegate_->IsRootForAccessPolicy(view->parent()->id()) || 23 return delegate_->IsRootForAccessPolicy(view->parent()->id()) ||
24 WasCreatedByThisConnection(view->parent()); 24 WasCreatedByThisConnection(view->parent());
25 } 25 }
26 26
27 bool DefaultAccessPolicy::CanAddView(const ServerView* parent, 27 bool DefaultAccessPolicy::CanAddWindow(const ServerView* parent,
28 const ServerView* child) const { 28 const ServerView* child) const {
29 return WasCreatedByThisConnection(child) && 29 return WasCreatedByThisConnection(child) &&
30 (delegate_->IsRootForAccessPolicy(parent->id()) || 30 (delegate_->IsRootForAccessPolicy(parent->id()) ||
31 (WasCreatedByThisConnection(parent) && 31 (WasCreatedByThisConnection(parent) &&
32 !delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(parent))); 32 !delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(parent)));
33 } 33 }
34 34
35 bool DefaultAccessPolicy::CanReorderView(const ServerView* view, 35 bool DefaultAccessPolicy::CanReorderWindow(
36 const ServerView* relative_view, 36 const ServerView* view,
37 mojo::OrderDirection direction) const { 37 const ServerView* relative_view,
38 mojom::OrderDirection direction) const {
38 return WasCreatedByThisConnection(view) && 39 return WasCreatedByThisConnection(view) &&
39 WasCreatedByThisConnection(relative_view); 40 WasCreatedByThisConnection(relative_view);
40 } 41 }
41 42
42 bool DefaultAccessPolicy::CanDeleteView(const ServerView* view) const { 43 bool DefaultAccessPolicy::CanDeleteWindow(const ServerView* view) const {
43 return WasCreatedByThisConnection(view); 44 return WasCreatedByThisConnection(view);
44 } 45 }
45 46
46 bool DefaultAccessPolicy::CanGetViewTree(const ServerView* view) const { 47 bool DefaultAccessPolicy::CanGetWindowTree(const ServerView* view) const {
47 return WasCreatedByThisConnection(view) || 48 return WasCreatedByThisConnection(view) ||
48 delegate_->IsRootForAccessPolicy(view->id()) || 49 delegate_->IsRootForAccessPolicy(view->id()) ||
49 IsDescendantOfEmbedRoot(view); 50 IsDescendantOfEmbedRoot(view);
50 } 51 }
51 52
52 bool DefaultAccessPolicy::CanDescendIntoViewForViewTree( 53 bool DefaultAccessPolicy::CanDescendIntoViewForViewTree(
53 const ServerView* view) const { 54 const ServerView* view) const {
54 return (WasCreatedByThisConnection(view) && 55 return (WasCreatedByThisConnection(view) &&
55 !delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view)) || 56 !delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view)) ||
56 delegate_->IsRootForAccessPolicy(view->id()) || 57 delegate_->IsRootForAccessPolicy(view->id()) ||
57 delegate_->IsDescendantOfEmbedRoot(view); 58 delegate_->IsDescendantOfEmbedRoot(view);
58 } 59 }
59 60
60 bool DefaultAccessPolicy::CanEmbed(const ServerView* view, 61 bool DefaultAccessPolicy::CanEmbed(const ServerView* view,
61 uint32_t policy_bitmask) const { 62 uint32_t policy_bitmask) const {
62 if (policy_bitmask != mojo::ViewTree::ACCESS_POLICY_DEFAULT) 63 if (policy_bitmask != mojom::WindowTree::ACCESS_POLICY_DEFAULT)
63 return false; 64 return false;
64 return WasCreatedByThisConnection(view) || 65 return WasCreatedByThisConnection(view) ||
65 (delegate_->IsViewKnownForAccessPolicy(view) && 66 (delegate_->IsViewKnownForAccessPolicy(view) &&
66 IsDescendantOfEmbedRoot(view) && 67 IsDescendantOfEmbedRoot(view) &&
67 !delegate_->IsRootForAccessPolicy(view->id())); 68 !delegate_->IsRootForAccessPolicy(view->id()));
68 } 69 }
69 70
70 bool DefaultAccessPolicy::CanChangeViewVisibility( 71 bool DefaultAccessPolicy::CanChangeViewVisibility(
71 const ServerView* view) const { 72 const ServerView* view) const {
72 return WasCreatedByThisConnection(view) || 73 return WasCreatedByThisConnection(view) ||
73 delegate_->IsRootForAccessPolicy(view->id()); 74 delegate_->IsRootForAccessPolicy(view->id());
74 } 75 }
75 76
76 bool DefaultAccessPolicy::CanSetWindowSurfaceId(const ServerView* view) const { 77 bool DefaultAccessPolicy::CanSetWindowSurfaceId(const ServerView* view) const {
77 // Once a view embeds another app, the embedder app is no longer able to 78 // Once a view embeds another app, the embedder app is no longer able to
78 // call SetWindowSurfaceId() - this ability is transferred to the embedded 79 // call SetWindowSurfaceId() - this ability is transferred to the embedded
79 // app. 80 // app.
80 if (delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view)) 81 if (delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view))
81 return false; 82 return false;
82 return WasCreatedByThisConnection(view) || 83 return WasCreatedByThisConnection(view) ||
83 delegate_->IsRootForAccessPolicy(view->id()); 84 delegate_->IsRootForAccessPolicy(view->id());
84 } 85 }
85 86
86 bool DefaultAccessPolicy::CanSetViewBounds(const ServerView* view) const { 87 bool DefaultAccessPolicy::CanSetWindowBounds(const ServerView* view) const {
87 return WasCreatedByThisConnection(view); 88 return WasCreatedByThisConnection(view);
88 } 89 }
89 90
90 bool DefaultAccessPolicy::CanSetViewProperties(const ServerView* view) const { 91 bool DefaultAccessPolicy::CanSetWindowProperties(const ServerView* view) const {
91 return WasCreatedByThisConnection(view); 92 return WasCreatedByThisConnection(view);
92 } 93 }
93 94
94 bool DefaultAccessPolicy::CanSetViewTextInputState( 95 bool DefaultAccessPolicy::CanSetWindowTextInputState(
95 const ServerView* view) const { 96 const ServerView* view) const {
96 return WasCreatedByThisConnection(view) || 97 return WasCreatedByThisConnection(view) ||
97 delegate_->IsRootForAccessPolicy(view->id()); 98 delegate_->IsRootForAccessPolicy(view->id());
98 } 99 }
99 100
100 bool DefaultAccessPolicy::CanSetFocus(const ServerView* view) const { 101 bool DefaultAccessPolicy::CanSetFocus(const ServerView* view) const {
101 return WasCreatedByThisConnection(view) || 102 return WasCreatedByThisConnection(view) ||
102 delegate_->IsRootForAccessPolicy(view->id()); 103 delegate_->IsRootForAccessPolicy(view->id());
103 } 104 }
104 105
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const ServerView* view) const { 144 const ServerView* view) const {
144 return view->id().connection_id == connection_id_; 145 return view->id().connection_id == connection_id_;
145 } 146 }
146 147
147 bool DefaultAccessPolicy::IsDescendantOfEmbedRoot( 148 bool DefaultAccessPolicy::IsDescendantOfEmbedRoot(
148 const ServerView* view) const { 149 const ServerView* view) const {
149 return delegate_->IsDescendantOfEmbedRoot(view); 150 return delegate_->IsDescendantOfEmbedRoot(view);
150 } 151 }
151 152
152 } // namespace mus 153 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/default_access_policy.h ('k') | components/mus/ws/display_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698