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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "mojo/examples/keyboard/keyboard.mojom.h" | 7 #include "mojo/examples/keyboard/keyboard.mojom.h" |
8 #include "mojo/examples/window_manager/debug_panel.h" | 8 #include "mojo/examples/window_manager/debug_panel.h" |
9 #include "mojo/examples/window_manager/window_manager.mojom.h" | 9 #include "mojo/examples/window_manager/window_manager.mojom.h" |
10 #include "mojo/public/c/system/main.h" | 10 #include "mojo/public/c/system/main.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 public: | 258 public: |
259 WindowManager() | 259 WindowManager() |
260 : window_manager_factory_(this), | 260 : window_manager_factory_(this), |
261 navigator_host_factory_(this), | 261 navigator_host_factory_(this), |
262 launcher_ui_(NULL), | 262 launcher_ui_(NULL), |
263 view_manager_(NULL), | 263 view_manager_(NULL), |
264 window_manager_app_(new WindowManagerApp(this, this)), | 264 window_manager_app_(new WindowManagerApp(this, this)), |
265 app_(NULL) {} | 265 app_(NULL) {} |
266 | 266 |
267 virtual ~WindowManager() { | 267 virtual ~WindowManager() { |
268 window_manager_app_->host()->window()->RemovePreTargetHandler(this); | 268 // host() may be destroyed by the time we get here. |
| 269 // TODO: figure out a way to always cleanly remove handler. |
| 270 if (window_manager_app_->host()) |
| 271 window_manager_app_->host()->window()->RemovePreTargetHandler(this); |
269 } | 272 } |
270 | 273 |
271 void CloseWindow(Id view_id) { | 274 void CloseWindow(Id view_id) { |
272 View* view = view_manager_->GetViewById(view_id); | 275 View* view = view_manager_->GetViewById(view_id); |
273 DCHECK(view); | 276 DCHECK(view); |
274 std::vector<View*>::iterator iter = | 277 std::vector<View*>::iterator iter = |
275 std::find(windows_.begin(), windows_.end(), view); | 278 std::find(windows_.begin(), windows_.end(), view); |
276 DCHECK(iter != windows_.end()); | 279 DCHECK(iter != windows_.end()); |
277 windows_.erase(iter); | 280 windows_.erase(iter); |
278 view->Destroy(); | 281 view->Destroy(); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 window_manager_->RequestNavigate(source_view_id, target, nav_details.Pass()); | 564 window_manager_->RequestNavigate(source_view_id, target, nav_details.Pass()); |
562 } | 565 } |
563 | 566 |
564 } // namespace examples | 567 } // namespace examples |
565 } // namespace mojo | 568 } // namespace mojo |
566 | 569 |
567 MojoResult MojoMain(MojoHandle shell_handle) { | 570 MojoResult MojoMain(MojoHandle shell_handle) { |
568 mojo::ApplicationRunnerChromium runner(new mojo::examples::WindowManager); | 571 mojo::ApplicationRunnerChromium runner(new mojo::examples::WindowManager); |
569 return runner.Run(shell_handle); | 572 return runner.Run(shell_handle); |
570 } | 573 } |
OLD | NEW |