OLD | NEW |
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/view_manager/connection_manager.h" | 5 #include "components/view_manager/connection_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "components/view_manager/client_connection.h" | 9 #include "components/view_manager/client_connection.h" |
10 #include "components/view_manager/connection_manager_delegate.h" | 10 #include "components/view_manager/connection_manager_delegate.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 ConnectionManager::ScopedChange::~ScopedChange() { | 109 ConnectionManager::ScopedChange::~ScopedChange() { |
110 connection_manager_->FinishChange(); | 110 connection_manager_->FinishChange(); |
111 } | 111 } |
112 | 112 |
113 ConnectionManager::ConnectionManager(ConnectionManagerDelegate* delegate, | 113 ConnectionManager::ConnectionManager(ConnectionManagerDelegate* delegate, |
114 scoped_ptr<DisplayManager> display_manager) | 114 scoped_ptr<DisplayManager> display_manager) |
115 : delegate_(delegate), | 115 : delegate_(delegate), |
116 window_manager_client_connection_(nullptr), | 116 window_manager_client_connection_(nullptr), |
117 next_connection_id_(1), | 117 next_connection_id_(1), |
118 event_dispatcher_(this), | |
119 display_manager_(display_manager.Pass()), | 118 display_manager_(display_manager.Pass()), |
120 root_(CreateServerView(RootViewId())), | 119 root_(CreateServerView(RootViewId())), |
121 current_change_(nullptr), | 120 current_change_(nullptr), |
122 in_destructor_(false), | 121 in_destructor_(false), |
123 animation_runner_(base::TimeTicks::Now()), | 122 animation_runner_(base::TimeTicks::Now()), |
| 123 event_dispatcher_(this), |
| 124 event_dispatcher_binding_(&event_dispatcher_), |
124 focus_controller_(new FocusController(this, root_.get())) { | 125 focus_controller_(new FocusController(this, root_.get())) { |
125 root_->SetBounds(gfx::Rect(800, 600)); | 126 root_->SetBounds(gfx::Rect(800, 600)); |
126 root_->SetVisible(true); | 127 root_->SetVisible(true); |
127 | 128 |
128 display_manager_->Init(this, &event_dispatcher_); | 129 mojo::NativeViewportEventDispatcherPtr event_dispatcher_ptr; |
| 130 event_dispatcher_binding_.Bind(GetProxy(&event_dispatcher_ptr)); |
| 131 display_manager_->Init(this, event_dispatcher_ptr.Pass()); |
129 } | 132 } |
130 | 133 |
131 ConnectionManager::~ConnectionManager() { | 134 ConnectionManager::~ConnectionManager() { |
132 in_destructor_ = true; | 135 in_destructor_ = true; |
133 | 136 |
134 // Deleting views will attempt to advance focus. When we're being destroyed | 137 // Deleting views will attempt to advance focus. When we're being destroyed |
135 // that is not necessary. Additionally |focus_controller_| needs to be | 138 // that is not necessary. Additionally |focus_controller_| needs to be |
136 // destroyed before |root_|. | 139 // destroyed before |root_|. |
137 focus_controller_.reset(); | 140 focus_controller_.reset(); |
138 | 141 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 this, &ConnectionManager::DoAnimation); | 305 this, &ConnectionManager::DoAnimation); |
303 } | 306 } |
304 ServerView* clone = CloneView(view, this); | 307 ServerView* clone = CloneView(view, this); |
305 CloneViewTree(view, clone, this); | 308 CloneViewTree(view, clone, this); |
306 view->parent()->Add(clone); | 309 view->parent()->Add(clone); |
307 view->parent()->Reorder(clone, view, mojo::ORDER_DIRECTION_ABOVE); | 310 view->parent()->Reorder(clone, view, mojo::ORDER_DIRECTION_ABOVE); |
308 return true; | 311 return true; |
309 } | 312 } |
310 | 313 |
311 void ConnectionManager::ProcessEvent(mojo::EventPtr event) { | 314 void ConnectionManager::ProcessEvent(mojo::EventPtr event) { |
312 event_dispatcher_.OnEvent(event.Pass()); | 315 event_dispatcher_.OnEvent(event.Pass(), EventDispatcher::OnEventCallback()); |
313 } | 316 } |
314 | 317 |
315 void ConnectionManager::DispatchInputEventToView(const ServerView* view, | 318 void ConnectionManager::DispatchInputEventToView(const ServerView* view, |
316 mojo::EventPtr event) { | 319 mojo::EventPtr event) { |
317 // If the view is an embed root, forward to the embedded view, not the owner. | 320 // If the view is an embed root, forward to the embedded view, not the owner. |
318 ViewManagerServiceImpl* connection = GetConnectionWithRoot(view->id()); | 321 ViewManagerServiceImpl* connection = GetConnectionWithRoot(view->id()); |
319 if (!connection) | 322 if (!connection) |
320 connection = GetConnection(view->id().connection_id); | 323 connection = GetConnection(view->id().connection_id); |
321 CHECK(connection); | 324 CHECK(connection); |
322 connection->client()->OnViewInputEvent(ViewIdToTransportId(view->id()), | 325 connection->client()->OnViewInputEvent(ViewIdToTransportId(view->id()), |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 if (wm_connection != owning_connection_old && | 615 if (wm_connection != owning_connection_old && |
613 wm_connection != embedded_connection_old && | 616 wm_connection != embedded_connection_old && |
614 wm_connection != owning_connection_new && | 617 wm_connection != owning_connection_new && |
615 wm_connection != embedded_connection_new) { | 618 wm_connection != embedded_connection_new) { |
616 wm_connection->ProcessFocusChanged(old_focused_view, new_focused_view); | 619 wm_connection->ProcessFocusChanged(old_focused_view, new_focused_view); |
617 } | 620 } |
618 } | 621 } |
619 } | 622 } |
620 | 623 |
621 } // namespace view_manager | 624 } // namespace view_manager |
OLD | NEW |