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