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

Side by Side Diff: components/mus/view_tree_impl.cc

Issue 1340983002: Mandoline UI Process: Update namespaces and file names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased 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 unified diff | Download patch
« no previous file with comments | « components/mus/view_tree_impl.h ('k') | components/mus/view_tree_unittest.cc » ('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/view_tree_impl.h" 5 #include "components/mus/view_tree_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "components/mus/connection_manager.h" 9 #include "components/mus/connection_manager.h"
10 #include "components/mus/default_access_policy.h" 10 #include "components/mus/default_access_policy.h"
11 #include "components/mus/display_manager.h" 11 #include "components/mus/display_manager.h"
12 #include "components/mus/server_view.h" 12 #include "components/mus/server_view.h"
13 #include "components/mus/view_tree_host_impl.h" 13 #include "components/mus/view_tree_host_impl.h"
14 #include "components/mus/window_manager_access_policy.h" 14 #include "components/mus/window_manager_access_policy.h"
15 #include "mojo/converters/geometry/geometry_type_converters.h" 15 #include "mojo/converters/geometry/geometry_type_converters.h"
16 #include "mojo/converters/ime/ime_type_converters.h" 16 #include "mojo/converters/ime/ime_type_converters.h"
17 #include "mojo/converters/input_events/input_events_type_converters.h" 17 #include "mojo/converters/input_events/input_events_type_converters.h"
18 #include "mojo/converters/surfaces/surfaces_type_converters.h" 18 #include "mojo/converters/surfaces/surfaces_type_converters.h"
19 #include "ui/platform_window/text_input_state.h" 19 #include "ui/platform_window/text_input_state.h"
20 20
21 using mojo::Array; 21 using mojo::Array;
22 using mojo::Callback; 22 using mojo::Callback;
23 using mojo::Id;
24 using mojo::InterfaceRequest; 23 using mojo::InterfaceRequest;
25 using mojo::OrderDirection; 24 using mojo::OrderDirection;
26 using mojo::Rect; 25 using mojo::Rect;
27 using mojo::ServiceProvider; 26 using mojo::ServiceProvider;
28 using mojo::ServiceProviderPtr; 27 using mojo::ServiceProviderPtr;
29 using mojo::String; 28 using mojo::String;
30 using mojo::ViewDataPtr; 29 using mojo::ViewDataPtr;
31 30
32 namespace view_manager { 31 namespace mus {
33 32
34 ViewTreeImpl::ViewTreeImpl(ConnectionManager* connection_manager, 33 ViewTreeImpl::ViewTreeImpl(ConnectionManager* connection_manager,
35 mojo::ConnectionSpecificId creator_id, 34 ConnectionSpecificId creator_id,
36 const ViewId& root_id, 35 const ViewId& root_id,
37 uint32_t policy_bitmask) 36 uint32_t policy_bitmask)
38 : connection_manager_(connection_manager), 37 : connection_manager_(connection_manager),
39 id_(connection_manager_->GetAndAdvanceNextConnectionId()), 38 id_(connection_manager_->GetAndAdvanceNextConnectionId()),
40 creator_id_(creator_id), 39 creator_id_(creator_id),
41 client_(nullptr), 40 client_(nullptr),
42 is_embed_root_(false) { 41 is_embed_root_(false) {
43 ServerView* view = GetView(root_id); 42 ServerView* view = GetView(root_id);
44 CHECK(view); 43 CHECK(view);
45 root_.reset(new ViewId(root_id)); 44 root_.reset(new ViewId(root_id));
(...skipping 15 matching lines...) Expand all
61 client_ = client; 60 client_ = client;
62 std::vector<const ServerView*> to_send; 61 std::vector<const ServerView*> to_send;
63 if (root_.get()) 62 if (root_.get())
64 GetUnknownViewsFrom(GetView(*root_), &to_send); 63 GetUnknownViewsFrom(GetView(*root_), &to_send);
65 64
66 // TODO(beng): verify that host can actually be nullptr here. 65 // TODO(beng): verify that host can actually be nullptr here.
67 ViewTreeHostImpl* host = GetHost(); 66 ViewTreeHostImpl* host = GetHost();
68 const ServerView* focused_view = host ? host->GetFocusedView() : nullptr; 67 const ServerView* focused_view = host ? host->GetFocusedView() : nullptr;
69 if (focused_view) 68 if (focused_view)
70 focused_view = access_policy_->GetViewForFocusChange(focused_view); 69 focused_view = access_policy_->GetViewForFocusChange(focused_view);
71 const mojo::Id focused_view_transport_id( 70 const Id focused_view_transport_id(
72 ViewIdToTransportId(focused_view ? focused_view->id() : ViewId())); 71 ViewIdToTransportId(focused_view ? focused_view->id() : ViewId()));
73 72
74 client->OnEmbed(id_, ViewToViewData(to_send.front()), tree.Pass(), 73 client->OnEmbed(id_, ViewToViewData(to_send.front()), tree.Pass(),
75 focused_view_transport_id, 74 focused_view_transport_id,
76 is_embed_root_ ? ViewTree::ACCESS_POLICY_EMBED_ROOT 75 is_embed_root_ ? ViewTree::ACCESS_POLICY_EMBED_ROOT
77 : ViewTree::ACCESS_POLICY_DEFAULT); 76 : ViewTree::ACCESS_POLICY_DEFAULT);
78 } 77 }
79 78
80 const ServerView* ViewTreeImpl::GetView(const ViewId& id) const { 79 const ServerView* ViewTreeImpl::GetView(const ViewId& id) const {
81 if (id_ == id.connection_id) { 80 if (id_ == id.connection_id) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return false; 148 return false;
150 } 149 }
151 ConnectionManager::ScopedChange change(this, connection_manager_, false); 150 ConnectionManager::ScopedChange change(this, connection_manager_, false);
152 view->SetVisible(visible); 151 view->SetVisible(visible);
153 return true; 152 return true;
154 } 153 }
155 154
156 bool ViewTreeImpl::Embed(const ViewId& view_id, 155 bool ViewTreeImpl::Embed(const ViewId& view_id,
157 mojo::ViewTreeClientPtr client, 156 mojo::ViewTreeClientPtr client,
158 uint32_t policy_bitmask, 157 uint32_t policy_bitmask,
159 mojo::ConnectionSpecificId* connection_id) { 158 ConnectionSpecificId* connection_id) {
160 *connection_id = kInvalidConnectionId; 159 *connection_id = kInvalidConnectionId;
161 if (!client.get() || !CanEmbed(view_id, policy_bitmask)) 160 if (!client.get() || !CanEmbed(view_id, policy_bitmask))
162 return false; 161 return false;
163 PrepareForEmbed(view_id); 162 PrepareForEmbed(view_id);
164 ViewTreeImpl* new_connection = connection_manager_->EmbedAtView( 163 ViewTreeImpl* new_connection = connection_manager_->EmbedAtView(
165 id_, view_id, policy_bitmask, client.Pass()); 164 id_, view_id, policy_bitmask, client.Pass());
166 if (is_embed_root_) 165 if (is_embed_root_)
167 *connection_id = new_connection->id(); 166 *connection_id = new_connection->id();
168 return true; 167 return true;
169 } 168 }
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 if (value.is_null()) { 598 if (value.is_null()) {
600 view->SetProperty(name, nullptr); 599 view->SetProperty(name, nullptr);
601 } else { 600 } else {
602 std::vector<uint8_t> data = value.To<std::vector<uint8_t>>(); 601 std::vector<uint8_t> data = value.To<std::vector<uint8_t>>();
603 view->SetProperty(name, &data); 602 view->SetProperty(name, &data);
604 } 603 }
605 } 604 }
606 callback.Run(success); 605 callback.Run(success);
607 } 606 }
608 607
609 void ViewTreeImpl::RequestSurface(mojo::Id view_id, 608 void ViewTreeImpl::RequestSurface(Id view_id,
610 mojo::InterfaceRequest<mojo::Surface> surface, 609 mojo::InterfaceRequest<mojo::Surface> surface,
611 mojo::SurfaceClientPtr client) { 610 mojo::SurfaceClientPtr client) {
612 ServerView* view = GetView(ViewIdFromTransportId(view_id)); 611 ServerView* view = GetView(ViewIdFromTransportId(view_id));
613 const bool success = view && access_policy_->CanSetViewSurfaceId(view); 612 const bool success = view && access_policy_->CanSetViewSurfaceId(view);
614 if (!success) 613 if (!success)
615 return; 614 return;
616 view->Bind(surface.Pass(), client.Pass()); 615 view->Bind(surface.Pass(), client.Pass());
617 } 616 }
618 617
619 void ViewTreeImpl::SetViewTextInputState(uint32_t view_id, 618 void ViewTreeImpl::SetViewTextInputState(uint32_t view_id,
(...skipping 12 matching lines...) Expand all
632 if (success) { 631 if (success) {
633 if (!state.is_null()) 632 if (!state.is_null())
634 view->SetTextInputState(state.To<ui::TextInputState>()); 633 view->SetTextInputState(state.To<ui::TextInputState>());
635 634
636 ViewTreeHostImpl* host = GetHost(); 635 ViewTreeHostImpl* host = GetHost();
637 if (host) 636 if (host)
638 host->SetImeVisibility(view, visible); 637 host->SetImeVisibility(view, visible);
639 } 638 }
640 } 639 }
641 640
642 void ViewTreeImpl::Embed(mojo::Id transport_view_id, 641 void ViewTreeImpl::Embed(Id transport_view_id,
643 mojo::ViewTreeClientPtr client, 642 mojo::ViewTreeClientPtr client,
644 uint32_t policy_bitmask, 643 uint32_t policy_bitmask,
645 const EmbedCallback& callback) { 644 const EmbedCallback& callback) {
646 mojo::ConnectionSpecificId connection_id = kInvalidConnectionId; 645 ConnectionSpecificId connection_id = kInvalidConnectionId;
647 const bool result = Embed(ViewIdFromTransportId(transport_view_id), 646 const bool result = Embed(ViewIdFromTransportId(transport_view_id),
648 client.Pass(), policy_bitmask, &connection_id); 647 client.Pass(), policy_bitmask, &connection_id);
649 callback.Run(result, connection_id); 648 callback.Run(result, connection_id);
650 } 649 }
651 650
652 void ViewTreeImpl::SetFocus(uint32_t view_id) { 651 void ViewTreeImpl::SetFocus(uint32_t view_id) {
653 ServerView* view = GetView(ViewIdFromTransportId(view_id)); 652 ServerView* view = GetView(ViewIdFromTransportId(view_id));
654 // TODO(beng): consider shifting non-policy drawn check logic to VTH's 653 // TODO(beng): consider shifting non-policy drawn check logic to VTH's
655 // FocusController. 654 // FocusController.
656 if (view && view->IsDrawn() && access_policy_->CanSetFocus(view)) { 655 if (view && view->IsDrawn() && access_policy_->CanSetFocus(view)) {
(...skipping 16 matching lines...) Expand all
673 const ServerView* view) const { 672 const ServerView* view) const {
674 ViewTreeImpl* connection = 673 ViewTreeImpl* connection =
675 connection_manager_->GetConnectionWithRoot(view->id()); 674 connection_manager_->GetConnectionWithRoot(view->id());
676 return connection && connection != this; 675 return connection && connection != this;
677 } 676 }
678 677
679 bool ViewTreeImpl::IsDescendantOfEmbedRoot(const ServerView* view) { 678 bool ViewTreeImpl::IsDescendantOfEmbedRoot(const ServerView* view) {
680 return is_embed_root_ && root_ && GetView(*root_)->Contains(view); 679 return is_embed_root_ && root_ && GetView(*root_)->Contains(view);
681 } 680 }
682 681
683 } // namespace view_manager 682 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/view_tree_impl.h ('k') | components/mus/view_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698