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

Unified Diff: mojo/services/view_manager/default_access_policy.cc

Issue 699173003: Makes ViewManagerServiceImpl track a single root (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: comment Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: mojo/services/view_manager/default_access_policy.cc
diff --git a/mojo/services/view_manager/default_access_policy.cc b/mojo/services/view_manager/default_access_policy.cc
index bb945ddb6e6798953840d026e2476824debeffce..358ca7c2aba80de5bdd6297228799ae1ec6f76a1 100644
--- a/mojo/services/view_manager/default_access_policy.cc
+++ b/mojo/services/view_manager/default_access_policy.cc
@@ -24,14 +24,14 @@ bool DefaultAccessPolicy::CanRemoveViewFromParent(
if (!WasCreatedByThisConnection(view))
return false; // Can only unparent views we created.
- return IsViewInRoots(view->parent()) ||
+ return delegate_->IsRootForAccessPolicy(view->parent()->id()) ||
WasCreatedByThisConnection(view->parent());
}
bool DefaultAccessPolicy::CanAddView(const ServerView* parent,
const ServerView* child) const {
return WasCreatedByThisConnection(child) &&
- (IsViewInRoots(parent) ||
+ (delegate_->IsRootForAccessPolicy(parent->id()) ||
(WasCreatedByThisConnection(parent) &&
!delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(parent)));
}
@@ -48,7 +48,8 @@ bool DefaultAccessPolicy::CanDeleteView(const ServerView* view) const {
}
bool DefaultAccessPolicy::CanGetViewTree(const ServerView* view) const {
- return WasCreatedByThisConnection(view) || IsViewInRoots(view);
+ return WasCreatedByThisConnection(view) ||
+ delegate_->IsRootForAccessPolicy(view->id());
}
bool DefaultAccessPolicy::CanDescendIntoViewForViewTree(
@@ -63,7 +64,8 @@ bool DefaultAccessPolicy::CanEmbed(const ServerView* view) const {
bool DefaultAccessPolicy::CanChangeViewVisibility(
const ServerView* view) const {
- return WasCreatedByThisConnection(view) || IsViewInRoots(view);
+ return WasCreatedByThisConnection(view) ||
+ delegate_->IsRootForAccessPolicy(view->id());
}
bool DefaultAccessPolicy::CanSetViewSurfaceId(const ServerView* view) const {
@@ -71,7 +73,8 @@ bool DefaultAccessPolicy::CanSetViewSurfaceId(const ServerView* view) const {
// call SetViewSurfaceId() - this ability is transferred to the embedded app.
if (delegate_->IsViewRootOfAnotherConnectionForAccessPolicy(view))
return false;
- return WasCreatedByThisConnection(view) || IsViewInRoots(view);
+ return WasCreatedByThisConnection(view) ||
+ delegate_->IsRootForAccessPolicy(view->id());
}
bool DefaultAccessPolicy::CanSetViewBounds(const ServerView* view) const {
@@ -90,22 +93,17 @@ bool DefaultAccessPolicy::ShouldNotifyOnHierarchyChange(
return false;
if (*new_parent && !WasCreatedByThisConnection(*new_parent) &&
- !IsViewInRoots(*new_parent)) {
+ !delegate_->IsRootForAccessPolicy((*new_parent)->id())) {
*new_parent = NULL;
}
if (*old_parent && !WasCreatedByThisConnection(*old_parent) &&
- !IsViewInRoots(*old_parent)) {
+ !delegate_->IsRootForAccessPolicy((*old_parent)->id())) {
*old_parent = NULL;
}
return true;
}
-bool DefaultAccessPolicy::IsViewInRoots(const ServerView* view) const {
- return delegate_->GetRootsForAccessPolicy().count(
- ViewIdToTransportId(view->id())) > 0;
-}
-
bool DefaultAccessPolicy::WasCreatedByThisConnection(
const ServerView* view) const {
return view->id().connection_id == connection_id_;
« no previous file with comments | « mojo/services/view_manager/default_access_policy.h ('k') | mojo/services/view_manager/view_manager_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698