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

Side by Side Diff: mojo/services/window_manager/window_manager_app.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
« no previous file with comments | « mojo/services/window_manager/window_manager_app.h ('k') | no next file » | 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 "mojo/services/window_manager/window_manager_app.h" 5 #include "mojo/services/window_manager/window_manager_app.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "mojo/aura/aura_init.h" 9 #include "mojo/aura/aura_init.h"
10 #include "mojo/aura/window_tree_host_mojo.h" 10 #include "mojo/aura/window_tree_host_mojo.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 bool WindowManagerApp::ConfigureIncomingConnection( 143 bool WindowManagerApp::ConfigureIncomingConnection(
144 ApplicationConnection* connection) { 144 ApplicationConnection* connection) {
145 connection->AddService(&window_manager_service_factory_); 145 connection->AddService(&window_manager_service_factory_);
146 connection->AddService(&view_manager_client_factory_); 146 connection->AddService(&view_manager_client_factory_);
147 return true; 147 return true;
148 } 148 }
149 149
150 //////////////////////////////////////////////////////////////////////////////// 150 ////////////////////////////////////////////////////////////////////////////////
151 // WindowManagerApp, ViewManagerDelegate implementation: 151 // WindowManagerApp, ViewManagerDelegate implementation:
152 152
153 void WindowManagerApp::OnEmbed(ViewManager* view_manager, Node* root) { 153 void WindowManagerApp::OnEmbed(ViewManager* view_manager,
154 Node* root,
155 ServiceProviderImpl* exported_services,
156 scoped_ptr<ServiceProvider> imported_services) {
154 DCHECK(!view_manager_ && !root_); 157 DCHECK(!view_manager_ && !root_);
155 view_manager_ = view_manager; 158 view_manager_ = view_manager;
156 root_ = root; 159 root_ = root;
157 root_->AddObserver(this); 160 root_->AddObserver(this);
158 161
159 window_tree_host_.reset(new WindowTreeHostMojo(root_, this)); 162 window_tree_host_.reset(new WindowTreeHostMojo(root_, this));
160 163
161 RegisterSubtree(root_->id(), window_tree_host_->window()); 164 RegisterSubtree(root_->id(), window_tree_host_->window());
162 165
163 capture_client_.reset( 166 capture_client_.reset(
164 new wm::ScopedCaptureClient(window_tree_host_->window())); 167 new wm::ScopedCaptureClient(window_tree_host_->window()));
165 wm::FocusController* focus_controller = 168 wm::FocusController* focus_controller =
166 new wm::FocusController(new WMFocusRules); 169 new wm::FocusController(new WMFocusRules);
167 activation_client_ = focus_controller; 170 activation_client_ = focus_controller;
168 focus_client_.reset(focus_controller); 171 focus_client_.reset(focus_controller);
169 172
170 focus_client_->AddObserver(this); 173 focus_client_->AddObserver(this);
171 activation_client_->AddObserver(this); 174 activation_client_->AddObserver(this);
172 175
173 if (wrapped_delegate_) 176 if (wrapped_delegate_) {
174 wrapped_delegate_->OnEmbed(view_manager, root); 177 wrapped_delegate_->OnEmbed(view_manager, root, exported_services,
178 imported_services.Pass());
179 }
175 180
176 for (Connections::const_iterator it = connections_.begin(); 181 for (Connections::const_iterator it = connections_.begin();
177 it != connections_.end(); ++it) { 182 it != connections_.end(); ++it) {
178 (*it)->NotifyReady(); 183 (*it)->NotifyReady();
179 } 184 }
180 } 185 }
181 186
182 void WindowManagerApp::OnViewManagerDisconnected( 187 void WindowManagerApp::OnViewManagerDisconnected(
183 ViewManager* view_manager) { 188 ViewManager* view_manager) {
184 DCHECK_EQ(view_manager_, view_manager); 189 DCHECK_EQ(view_manager_, view_manager);
185 if (wrapped_delegate_) 190 if (wrapped_delegate_)
186 wrapped_delegate_->OnViewManagerDisconnected(view_manager); 191 wrapped_delegate_->OnViewManagerDisconnected(view_manager);
187 root_->RemoveObserver(this);
188 root_ = NULL;
189 view_manager_ = NULL; 192 view_manager_ = NULL;
190 base::MessageLoop::current()->Quit(); 193 base::MessageLoop::current()->Quit();
191 } 194 }
192 195
193 //////////////////////////////////////////////////////////////////////////////// 196 ////////////////////////////////////////////////////////////////////////////////
194 // WindowManagerApp, NodeObserver implementation: 197 // WindowManagerApp, NodeObserver implementation:
195 198
196 void WindowManagerApp::OnTreeChanged( 199 void WindowManagerApp::OnTreeChanged(
197 const NodeObserver::TreeChangeParams& params) { 200 const NodeObserver::TreeChangeParams& params) {
198 DCHECK_EQ(params.receiver, root_); 201 DCHECK_EQ(params.receiver, root_);
199 DCHECK(params.old_parent || params.new_parent); 202 DCHECK(params.old_parent || params.new_parent);
200 if (!params.target) 203 if (!params.target)
201 return; 204 return;
202 205
203 if (params.new_parent) { 206 if (params.new_parent) {
204 if (node_id_to_window_map_.find(params.target->id()) == 207 if (node_id_to_window_map_.find(params.target->id()) ==
205 node_id_to_window_map_.end()) { 208 node_id_to_window_map_.end()) {
206 NodeIdToWindowMap::const_iterator it = 209 NodeIdToWindowMap::const_iterator it =
207 node_id_to_window_map_.find(params.new_parent->id()); 210 node_id_to_window_map_.find(params.new_parent->id());
208 DCHECK(it != node_id_to_window_map_.end()); 211 DCHECK(it != node_id_to_window_map_.end());
209 RegisterSubtree(params.target->id(), it->second); 212 RegisterSubtree(params.target->id(), it->second);
210 } 213 }
211 } else if (params.old_parent) { 214 } else if (params.old_parent) {
212 UnregisterSubtree(params.target->id()); 215 UnregisterSubtree(params.target->id());
213 } 216 }
214 } 217 }
215 218
219 void WindowManagerApp::OnNodeDestroyed(Node* node) {
220 root_ = NULL;
221 window_tree_host_.reset();
222 }
223
216 //////////////////////////////////////////////////////////////////////////////// 224 ////////////////////////////////////////////////////////////////////////////////
217 // WindowManagerApp, WindowTreeHostMojoDelegate implementation: 225 // WindowManagerApp, WindowTreeHostMojoDelegate implementation:
218 226
219 void WindowManagerApp::CompositorContentsChanged(const SkBitmap& bitmap) { 227 void WindowManagerApp::CompositorContentsChanged(const SkBitmap& bitmap) {
220 // We draw nothing. 228 // We draw nothing.
221 NOTREACHED(); 229 NOTREACHED();
222 } 230 }
223 231
224 //////////////////////////////////////////////////////////////////////////////// 232 ////////////////////////////////////////////////////////////////////////////////
225 // WindowManagerApp, aura::client::FocusChangeObserver implementation: 233 // WindowManagerApp, aura::client::FocusChangeObserver implementation:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 NodeIdToWindowMap::iterator it = node_id_to_window_map_.find(id); 280 NodeIdToWindowMap::iterator it = node_id_to_window_map_.find(id);
273 DCHECK(it != node_id_to_window_map_.end()); 281 DCHECK(it != node_id_to_window_map_.end());
274 scoped_ptr<aura::Window> window(it->second); 282 scoped_ptr<aura::Window> window(it->second);
275 node_id_to_window_map_.erase(it); 283 node_id_to_window_map_.erase(it);
276 Node::Children::const_iterator child = node->children().begin(); 284 Node::Children::const_iterator child = node->children().begin();
277 for (; child != node->children().end(); ++child) 285 for (; child != node->children().end(); ++child)
278 UnregisterSubtree((*child)->id()); 286 UnregisterSubtree((*child)->id());
279 } 287 }
280 288
281 } // namespace mojo 289 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/window_manager/window_manager_app.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698