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

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

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