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

Side by Side Diff: mojo/services/view_manager/root_node_manager.cc

Issue 433513005: Pass ServiceProvider thru ViewManagerService::Embed() allowing embedder & embeddee to expose servic… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 | Annotate | Revision Log
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 "mojo/services/view_manager/root_node_manager.h" 5 #include "mojo/services/view_manager/root_node_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/public/cpp/application/application_connection.h" 8 #include "mojo/public/cpp/application/application_connection.h"
9 #include "mojo/public/interfaces/application/service_provider.mojom.h" 9 #include "mojo/public/interfaces/application/service_provider.mojom.h"
10 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" 10 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 connection_map_.erase(connection->id()); 79 connection_map_.erase(connection->id());
80 connections_created_by_connect_.erase(connection); 80 connections_created_by_connect_.erase(connection);
81 81
82 // Notify remaining connections so that they can cleanup. 82 // Notify remaining connections so that they can cleanup.
83 for (ConnectionMap::const_iterator i = connection_map_.begin(); 83 for (ConnectionMap::const_iterator i = connection_map_.begin();
84 i != connection_map_.end(); ++i) { 84 i != connection_map_.end(); ++i) {
85 i->second->OnViewManagerServiceImplDestroyed(connection->id()); 85 i->second->OnViewManagerServiceImplDestroyed(connection->id());
86 } 86 }
87 } 87 }
88 88
89 void RootNodeManager::EmbedRoot(const std::string& url) { 89 void RootNodeManager::EmbedRoot(
90 const std::string& url,
91 InterfaceRequest<ServiceProvider> service_provider) {
90 if (connection_map_.empty()) { 92 if (connection_map_.empty()) {
91 EmbedImpl(kInvalidConnectionId, String::From(url), RootNodeId()); 93 EmbedImpl(kInvalidConnectionId, String::From(url), RootNodeId(),
94 service_provider.Pass());
92 return; 95 return;
93 } 96 }
94 ViewManagerServiceImpl* connection = GetConnection(kWindowManagerConnection); 97 ViewManagerServiceImpl* connection = GetConnection(kWindowManagerConnection);
95 connection->client()->Embed(url); 98 connection->client()->Embed(url, service_provider.Pass());
96 } 99 }
97 100
98 void RootNodeManager::Embed(ConnectionSpecificId creator_id, 101 void RootNodeManager::Embed(
99 const String& url, 102 ConnectionSpecificId creator_id,
100 Id transport_node_id) { 103 const String& url,
101 EmbedImpl(creator_id, url, NodeIdFromTransportId(transport_node_id))-> 104 Id transport_node_id,
102 set_delete_on_connection_error(); 105 InterfaceRequest<ServiceProvider> service_provider) {
106 EmbedImpl(creator_id,
107 url,
108 NodeIdFromTransportId(transport_node_id),
109 service_provider.Pass())->set_delete_on_connection_error();
103 } 110 }
104 111
105 ViewManagerServiceImpl* RootNodeManager::GetConnection( 112 ViewManagerServiceImpl* RootNodeManager::GetConnection(
106 ConnectionSpecificId connection_id) { 113 ConnectionSpecificId connection_id) {
107 ConnectionMap::iterator i = connection_map_.find(connection_id); 114 ConnectionMap::iterator i = connection_map_.find(connection_id);
108 return i == connection_map_.end() ? NULL : i->second; 115 return i == connection_map_.end() ? NULL : i->second;
109 } 116 }
110 117
111 Node* RootNodeManager::GetNode(const NodeId& id) { 118 Node* RootNodeManager::GetNode(const NodeId& id) {
112 if (id == root_->id()) 119 if (id == root_->id())
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 244
238 void RootNodeManager::FinishChange() { 245 void RootNodeManager::FinishChange() {
239 // PrepareForChange/FinishChange should be balanced. 246 // PrepareForChange/FinishChange should be balanced.
240 CHECK(current_change_); 247 CHECK(current_change_);
241 current_change_ = NULL; 248 current_change_ = NULL;
242 } 249 }
243 250
244 ViewManagerServiceImpl* RootNodeManager::EmbedImpl( 251 ViewManagerServiceImpl* RootNodeManager::EmbedImpl(
245 const ConnectionSpecificId creator_id, 252 const ConnectionSpecificId creator_id,
246 const String& url, 253 const String& url,
247 const NodeId& root_id) { 254 const NodeId& root_id,
255 InterfaceRequest<ServiceProvider> service_provider) {
248 MessagePipe pipe; 256 MessagePipe pipe;
249 257
250 ServiceProvider* service_provider = 258 ServiceProvider* view_manager_service_provider =
251 app_connection_->ConnectToApplication(url)->GetServiceProvider(); 259 app_connection_->ConnectToApplication(url)->GetServiceProvider();
252 service_provider->ConnectToService( 260 view_manager_service_provider->ConnectToService(
253 ViewManagerServiceImpl::Client::Name_, 261 ViewManagerServiceImpl::Client::Name_,
254 pipe.handle1.Pass()); 262 pipe.handle1.Pass());
255 263
256 std::string creator_url; 264 std::string creator_url;
257 ConnectionMap::const_iterator it = connection_map_.find(creator_id); 265 ConnectionMap::const_iterator it = connection_map_.find(creator_id);
258 if (it != connection_map_.end()) 266 if (it != connection_map_.end())
259 creator_url = it->second->url(); 267 creator_url = it->second->url();
260 268
261 ViewManagerServiceImpl* connection = 269 ViewManagerServiceImpl* connection =
262 new ViewManagerServiceImpl(this, 270 new ViewManagerServiceImpl(this,
263 creator_id, 271 creator_id,
264 creator_url, 272 creator_url,
265 url.To<std::string>(), 273 url.To<std::string>(),
266 root_id); 274 root_id,
275 service_provider.Pass());
267 WeakBindToPipe(connection, pipe.handle0.Pass()); 276 WeakBindToPipe(connection, pipe.handle0.Pass());
268 connections_created_by_connect_.insert(connection); 277 connections_created_by_connect_.insert(connection);
269 OnConnectionMessagedClient(connection->id()); 278 OnConnectionMessagedClient(connection->id());
270 return connection; 279 return connection;
271 } 280 }
272 281
273 void RootNodeManager::OnNodeDestroyed(const Node* node) { 282 void RootNodeManager::OnNodeDestroyed(const Node* node) {
274 ProcessNodeDeleted(node->id()); 283 ProcessNodeDeleted(node->id());
275 } 284 }
276 285
(...skipping 16 matching lines...) Expand all
293 ProcessNodeViewReplaced(node, new_view, old_view); 302 ProcessNodeViewReplaced(node, new_view, old_view);
294 } 303 }
295 304
296 void RootNodeManager::OnViewInputEvent(const View* view, 305 void RootNodeManager::OnViewInputEvent(const View* view,
297 const ui::Event* event) { 306 const ui::Event* event) {
298 DispatchViewInputEventToWindowManager(view, event); 307 DispatchViewInputEventToWindowManager(view, event);
299 } 308 }
300 309
301 } // namespace service 310 } // namespace service
302 } // namespace mojo 311 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/root_node_manager.h ('k') | mojo/services/view_manager/view_manager_init_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698