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 "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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 DISALLOW_COPY_AND_ASSIGN(WMFocusRules); | 65 DISALLOW_COPY_AND_ASSIGN(WMFocusRules); |
66 }; | 66 }; |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
70 //////////////////////////////////////////////////////////////////////////////// | 70 //////////////////////////////////////////////////////////////////////////////// |
71 // WindowManagerApp, public: | 71 // WindowManagerApp, public: |
72 | 72 |
73 WindowManagerApp::WindowManagerApp() | 73 WindowManagerApp::WindowManagerApp(view_manager::ViewManagerDelegate* delegate) |
74 : InterfaceFactoryWithContext(this), | 74 : InterfaceFactoryWithContext(this), |
| 75 wrapped_delegate_(delegate), |
75 view_manager_(NULL), | 76 view_manager_(NULL), |
76 view_manager_client_factory_(this), | 77 view_manager_client_factory_(this), |
77 root_(NULL) { | 78 root_(NULL) { |
78 } | 79 } |
| 80 |
79 WindowManagerApp::~WindowManagerApp() { | 81 WindowManagerApp::~WindowManagerApp() { |
80 // TODO(beng): Figure out if this should be done in | 82 // TODO(beng): Figure out if this should be done in |
81 // OnViewManagerDisconnected(). | 83 // OnViewManagerDisconnected(). |
82 STLDeleteValues(&node_id_to_window_map_); | 84 STLDeleteValues(&node_id_to_window_map_); |
83 if (focus_client_.get()) | 85 if (focus_client_.get()) |
84 focus_client_->RemoveObserver(this); | 86 focus_client_->RemoveObserver(this); |
85 if (activation_client_) | 87 if (activation_client_) |
86 activation_client_->RemoveObserver(this); | 88 activation_client_->RemoveObserver(this); |
87 } | 89 } |
88 | 90 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 capture_client_.reset( | 164 capture_client_.reset( |
163 new wm::ScopedCaptureClient(window_tree_host_->window())); | 165 new wm::ScopedCaptureClient(window_tree_host_->window())); |
164 wm::FocusController* focus_controller = | 166 wm::FocusController* focus_controller = |
165 new wm::FocusController(new WMFocusRules); | 167 new wm::FocusController(new WMFocusRules); |
166 activation_client_ = focus_controller; | 168 activation_client_ = focus_controller; |
167 focus_client_.reset(focus_controller); | 169 focus_client_.reset(focus_controller); |
168 | 170 |
169 focus_client_->AddObserver(this); | 171 focus_client_->AddObserver(this); |
170 activation_client_->AddObserver(this); | 172 activation_client_->AddObserver(this); |
171 | 173 |
172 // TODO(beng): Create the universe. | 174 wrapped_delegate_->OnRootAdded(view_manager, root); |
173 | 175 |
174 for (Connections::const_iterator it = connections_.begin(); | 176 for (Connections::const_iterator it = connections_.begin(); |
175 it != connections_.end(); ++it) { | 177 it != connections_.end(); ++it) { |
176 (*it)->NotifyReady(); | 178 (*it)->NotifyReady(); |
177 } | 179 } |
178 } | 180 } |
179 | 181 |
180 void WindowManagerApp::OnViewManagerDisconnected( | 182 void WindowManagerApp::OnViewManagerDisconnected( |
181 view_manager::ViewManager* view_manager) { | 183 view_manager::ViewManager* view_manager) { |
182 DCHECK_EQ(view_manager_, view_manager); | 184 DCHECK_EQ(view_manager_, view_manager); |
| 185 wrapped_delegate_->OnViewManagerDisconnected(view_manager); |
183 root_->RemoveObserver(this); | 186 root_->RemoveObserver(this); |
184 root_ = NULL; | 187 root_ = NULL; |
185 view_manager_ = NULL; | 188 view_manager_ = NULL; |
186 base::MessageLoop::current()->Quit(); | 189 base::MessageLoop::current()->Quit(); |
187 } | 190 } |
188 | 191 |
189 //////////////////////////////////////////////////////////////////////////////// | 192 //////////////////////////////////////////////////////////////////////////////// |
190 // WindowManagerApp, view_manager::NodeObserver implementation: | 193 // WindowManagerApp, view_manager::NodeObserver implementation: |
191 | 194 |
192 void WindowManagerApp::OnTreeChanged( | 195 void WindowManagerApp::OnTreeChanged( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 view_manager::Node* node = view_manager_->GetNodeById(id); | 270 view_manager::Node* node = view_manager_->GetNodeById(id); |
268 NodeIdToWindowMap::iterator it = node_id_to_window_map_.find(id); | 271 NodeIdToWindowMap::iterator it = node_id_to_window_map_.find(id); |
269 DCHECK(it != node_id_to_window_map_.end()); | 272 DCHECK(it != node_id_to_window_map_.end()); |
270 scoped_ptr<aura::Window> window(it->second); | 273 scoped_ptr<aura::Window> window(it->second); |
271 node_id_to_window_map_.erase(it); | 274 node_id_to_window_map_.erase(it); |
272 view_manager::Node::Children::const_iterator child = node->children().begin(); | 275 view_manager::Node::Children::const_iterator child = node->children().begin(); |
273 for (; child != node->children().end(); ++child) | 276 for (; child != node->children().end(); ++child) |
274 UnregisterSubtree((*child)->id()); | 277 UnregisterSubtree((*child)->id()); |
275 } | 278 } |
276 | 279 |
277 //////////////////////////////////////////////////////////////////////////////// | |
278 // ApplicationDelegate, public: | |
279 | |
280 // static | |
281 ApplicationDelegate* ApplicationDelegate::Create() { | |
282 return new WindowManagerApp; | |
283 } | |
284 | |
285 } // namespace mojo | 280 } // namespace mojo |
OLD | NEW |