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

Unified Diff: components/view_manager/view_tree_impl.cc

Issue 1317713006: Changes around how embed roots are set (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge to trunk Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/view_manager/view_tree_impl.h ('k') | components/view_manager/view_tree_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/view_manager/view_tree_impl.cc
diff --git a/components/view_manager/view_tree_impl.cc b/components/view_manager/view_tree_impl.cc
index 1439c7fdcfe99a84807f87ec0256f3146384645a..c53a8df138ee9e09da1a9054e2bc247abe9311db 100644
--- a/components/view_manager/view_tree_impl.cc
+++ b/components/view_manager/view_tree_impl.cc
@@ -43,10 +43,14 @@ ViewTreeImpl::ViewTreeImpl(
ServerView* view = GetView(root_id);
CHECK(view);
root_.reset(new ViewId(root_id));
- if (view->GetRoot() == view)
+ if (view->GetRoot() == view) {
access_policy_.reset(new WindowManagerAccessPolicy(id_, this));
- else
+ is_embed_root_ = true;
+ } else {
access_policy_.reset(new DefaultAccessPolicy(id_, this));
+ is_embed_root_ = (view->get_and_clear_pending_access_policy() &
+ ViewTree::ACCESS_POLICY_EMBED_ROOT) != 0;
+ }
}
ViewTreeImpl::~ViewTreeImpl() {
@@ -69,7 +73,9 @@ void ViewTreeImpl::Init(mojo::ViewTreeClient* client, mojo::ViewTreePtr tree) {
ViewIdToTransportId(focused_view ? focused_view->id() : ViewId()));
client->OnEmbed(id_, ViewToViewData(to_send.front()), tree.Pass(),
- focused_view_transport_id);
+ focused_view_transport_id,
+ is_embed_root_ ? ViewTree::ACCESS_POLICY_EMBED_ROOT
+ : ViewTree::ACCESS_POLICY_DEFAULT);
}
const ServerView* ViewTreeImpl::GetView(const ViewId& id) const {
@@ -626,10 +632,10 @@ void ViewTreeImpl::SetViewTextInputState(
view->SetTextInputState(state.To<ui::TextInputState>());
}
-void ViewTreeImpl::SetImeVisibility(uint32_t view_id,
+void ViewTreeImpl::SetImeVisibility(Id transport_view_id,
bool visible,
mojo::TextInputStatePtr state) {
- ServerView* view = GetView(ViewIdFromTransportId(view_id));
+ ServerView* view = GetView(ViewIdFromTransportId(transport_view_id));
bool success = view && access_policy_->CanSetViewTextInputState(view);
if (success) {
if (!state.is_null())
@@ -641,8 +647,20 @@ void ViewTreeImpl::SetImeVisibility(uint32_t view_id,
}
}
-void ViewTreeImpl::SetEmbedRoot() {
- is_embed_root_ = true;
+void ViewTreeImpl::SetAccessPolicy(Id transport_view_id,
+ uint32 policy_bitmask) {
+ const ViewId view_id(ViewIdFromTransportId(transport_view_id));
+ ServerView* view = GetView(view_id);
+ if (!view)
+ return;
+
+ ViewTreeImpl* existing_owner =
+ connection_manager_->GetConnectionWithRoot(view_id);
+ if (existing_owner)
+ return; // Only allow changing the access policy when nothing is embedded.
+
+ if (access_policy_->CanSetAccessPolicy(view))
+ view->set_pending_access_policy(policy_bitmask);
}
void ViewTreeImpl::Embed(mojo::Id transport_view_id,
« no previous file with comments | « components/view_manager/view_tree_impl.h ('k') | components/view_manager/view_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698