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

Side by Side Diff: mojo/services/window_manager/window_manager_app.cc

Issue 658923003: Remove dependency on ui from view_manager. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase Created 6 years, 1 month 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
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/converters/geometry/geometry_type_converters.h"
10 #include "mojo/converters/input_events/input_events_type_converters.h" 11 #include "mojo/converters/input_events/input_events_type_converters.h"
11 #include "mojo/public/cpp/application/application_connection.h" 12 #include "mojo/public/cpp/application/application_connection.h"
12 #include "mojo/public/cpp/application/application_impl.h" 13 #include "mojo/public/cpp/application/application_impl.h"
13 #include "mojo/public/interfaces/application/shell.mojom.h" 14 #include "mojo/public/interfaces/application/shell.mojom.h"
14 #include "mojo/services/public/cpp/view_manager/view.h" 15 #include "mojo/services/public/cpp/view_manager/view.h"
15 #include "mojo/services/public/cpp/view_manager/view_manager.h" 16 #include "mojo/services/public/cpp/view_manager/view_manager.h"
16 #include "mojo/services/window_manager/window_manager_delegate.h" 17 #include "mojo/services/window_manager/window_manager_delegate.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
18 #include "ui/aura/window_delegate.h" 19 #include "ui/aura/window_delegate.h"
19 #include "ui/aura/window_property.h" 20 #include "ui/aura/window_property.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 193
193 void WindowManagerApp::OnEmbed(ViewManager* view_manager, 194 void WindowManagerApp::OnEmbed(ViewManager* view_manager,
194 View* root, 195 View* root,
195 ServiceProviderImpl* exported_services, 196 ServiceProviderImpl* exported_services,
196 scoped_ptr<ServiceProvider> imported_services) { 197 scoped_ptr<ServiceProvider> imported_services) {
197 DCHECK(!view_manager_ && !root_); 198 DCHECK(!view_manager_ && !root_);
198 view_manager_ = view_manager; 199 view_manager_ = view_manager;
199 root_ = root; 200 root_ = root;
200 201
201 window_tree_host_.reset(new WindowTreeHostMojo(shell_, root_)); 202 window_tree_host_.reset(new WindowTreeHostMojo(shell_, root_));
202 window_tree_host_->window()->SetBounds(root->bounds()); 203 window_tree_host_->window()->SetBounds(root->bounds().To<gfx::Rect>());
203 window_tree_host_->window()->Show(); 204 window_tree_host_->window()->Show();
204 205
205 RegisterSubtree(root_, window_tree_host_->window()); 206 RegisterSubtree(root_, window_tree_host_->window());
206 207
207 capture_client_.reset( 208 capture_client_.reset(
208 new wm::ScopedCaptureClient(window_tree_host_->window())); 209 new wm::ScopedCaptureClient(window_tree_host_->window()));
209 210
210 if (wrapped_view_manager_delegate_) { 211 if (wrapped_view_manager_delegate_) {
211 wrapped_view_manager_delegate_->OnEmbed( 212 wrapped_view_manager_delegate_->OnEmbed(
212 view_manager, root, exported_services, imported_services.Pass()); 213 view_manager, root, exported_services, imported_services.Pass());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 root_ = NULL; 266 root_ = NULL;
266 STLDeleteValues(&view_id_to_window_map_); 267 STLDeleteValues(&view_id_to_window_map_);
267 if (focus_client_.get()) 268 if (focus_client_.get())
268 focus_client_->RemoveObserver(this); 269 focus_client_->RemoveObserver(this);
269 if (activation_client_) 270 if (activation_client_)
270 activation_client_->RemoveObserver(this); 271 activation_client_->RemoveObserver(this);
271 window_tree_host_.reset(); 272 window_tree_host_.reset();
272 } 273 }
273 274
274 void WindowManagerApp::OnViewBoundsChanged(View* view, 275 void WindowManagerApp::OnViewBoundsChanged(View* view,
275 const gfx::Rect& old_bounds, 276 const Rect& old_bounds,
276 const gfx::Rect& new_bounds) { 277 const Rect& new_bounds) {
277 aura::Window* window = GetWindowForViewId(view->id()); 278 aura::Window* window = GetWindowForViewId(view->id());
278 window->SetBounds(new_bounds); 279 window->SetBounds(new_bounds.To<gfx::Rect>());
279 } 280 }
280 281
281 //////////////////////////////////////////////////////////////////////////////// 282 ////////////////////////////////////////////////////////////////////////////////
282 // WindowManagerApp, ui::EventHandler implementation: 283 // WindowManagerApp, ui::EventHandler implementation:
283 284
284 void WindowManagerApp::OnEvent(ui::Event* event) { 285 void WindowManagerApp::OnEvent(ui::Event* event) {
285 if (!window_manager_client_) 286 if (!window_manager_client_)
286 return; 287 return;
287 288
288 View* view = GetViewForWindow(static_cast<aura::Window*>(event->target())); 289 View* view = GetViewForWindow(static_cast<aura::Window*>(event->target()));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 DCHECK(view_id_to_window_map_.find(view->id()) == 330 DCHECK(view_id_to_window_map_.find(view->id()) ==
330 view_id_to_window_map_.end()); 331 view_id_to_window_map_.end());
331 aura::Window* window = new aura::Window(dummy_delegate_.get()); 332 aura::Window* window = new aura::Window(dummy_delegate_.get());
332 window->set_id(view->id()); 333 window->set_id(view->id());
333 window->SetProperty(kViewKey, view); 334 window->SetProperty(kViewKey, view);
334 // All events pass through the root during dispatch, so we only need a handler 335 // All events pass through the root during dispatch, so we only need a handler
335 // installed there. 336 // installed there.
336 if (view == root_) 337 if (view == root_)
337 window->AddPreTargetHandler(this); 338 window->AddPreTargetHandler(this);
338 parent->AddChild(window); 339 parent->AddChild(window);
339 window->SetBounds(view->bounds()); 340 window->SetBounds(view->bounds().To<gfx::Rect>());
340 window->Show(); 341 window->Show();
341 view_id_to_window_map_[view->id()] = window; 342 view_id_to_window_map_[view->id()] = window;
342 View::Children::const_iterator it = view->children().begin(); 343 View::Children::const_iterator it = view->children().begin();
343 for (; it != view->children().end(); ++it) 344 for (; it != view->children().end(); ++it)
344 RegisterSubtree(*it, window); 345 RegisterSubtree(*it, window);
345 } 346 }
346 347
347 void WindowManagerApp::UnregisterSubtree(View* view) { 348 void WindowManagerApp::UnregisterSubtree(View* view) {
348 for (View* child : view->children()) 349 for (View* child : view->children())
349 UnregisterSubtree(child); 350 UnregisterSubtree(child);
(...skipping 27 matching lines...) Expand all
377 view_manager_app->GetServiceProvider(); 378 view_manager_app->GetServiceProvider();
378 view_manager_service_provider->ConnectToService(ViewManagerService::Name_, 379 view_manager_service_provider->ConnectToService(ViewManagerService::Name_,
379 pipe.handle1.Pass()); 380 pipe.handle1.Pass());
380 view_manager_client_ = ViewManagerClientFactory::WeakBindViewManagerToPipe( 381 view_manager_client_ = ViewManagerClientFactory::WeakBindViewManagerToPipe(
381 pipe.handle0.Pass(), shell_, this).Pass(); 382 pipe.handle0.Pass(), shell_, this).Pass();
382 383
383 view_manager_app->AddService(&window_manager_internal_service_factory_); 384 view_manager_app->AddService(&window_manager_internal_service_factory_);
384 } 385 }
385 386
386 } // namespace mojo 387 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698