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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "examples/keyboard/keyboard.mojom.h" | 7 #include "examples/keyboard/keyboard.mojom.h" |
8 #include "examples/window_manager/debug_panel.h" | 8 #include "examples/window_manager/debug_panel.h" |
9 #include "examples/window_manager/window_manager.mojom.h" | 9 #include "examples/window_manager/window_manager.mojom.h" |
10 #include "mojo/application/application_runner_chromium.h" | 10 #include "mojo/application/application_runner_chromium.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 virtual void Create(ApplicationConnection* connection, | 245 virtual void Create(ApplicationConnection* connection, |
246 InterfaceRequest<NavigatorHost> request) override { | 246 InterfaceRequest<NavigatorHost> request) override { |
247 BindToRequest(new NavigatorHostImpl(window_manager_, view_->id()), | 247 BindToRequest(new NavigatorHostImpl(window_manager_, view_->id()), |
248 &request); | 248 &request); |
249 } | 249 } |
250 | 250 |
251 WindowManager* window_manager_; | 251 WindowManager* window_manager_; |
252 View* view_; | 252 View* view_; |
253 }; | 253 }; |
254 | 254 |
255 class WindowManager | 255 class WindowManager : public ApplicationDelegate, |
256 : public ApplicationDelegate, | 256 public DebugPanel::Delegate, |
257 public DebugPanel::Delegate, | 257 public ViewManagerDelegate, |
258 public ViewManagerDelegate, | 258 public window_manager::WindowManagerDelegate, |
259 public WindowManagerDelegate, | 259 public ui::EventHandler { |
260 public ui::EventHandler { | |
261 public: | 260 public: |
262 WindowManager() | 261 WindowManager() |
263 : shell_(nullptr), | 262 : shell_(nullptr), |
264 window_manager_factory_(this), | 263 window_manager_factory_(this), |
265 launcher_ui_(NULL), | 264 launcher_ui_(NULL), |
266 view_manager_(NULL), | 265 view_manager_(NULL), |
267 window_manager_app_(new WindowManagerApp(this, this)), | 266 window_manager_app_(new window_manager::WindowManagerApp(this, this)), |
268 app_(NULL) {} | 267 app_(NULL) {} |
269 | 268 |
270 virtual ~WindowManager() { | 269 virtual ~WindowManager() { |
271 // host() may be destroyed by the time we get here. | 270 // host() may be destroyed by the time we get here. |
272 // TODO: figure out a way to always cleanly remove handler. | 271 // TODO: figure out a way to always cleanly remove handler. |
273 | 272 |
274 // TODO(erg): In the aura version, we removed ourselves from the | 273 // TODO(erg): In the aura version, we removed ourselves from the |
275 // PreTargetHandler list here. We may need to do something analogous when | 274 // PreTargetHandler list here. We may need to do something analogous when |
276 // we get event handling without aura working. | 275 // we get event handling without aura working. |
277 } | 276 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 content_view_id_, | 370 content_view_id_, |
372 launcher_ui_id, | 371 launcher_ui_id, |
373 control_panel_id)); | 372 control_panel_id)); |
374 root->AddObserver(root_layout_manager_.get()); | 373 root->AddObserver(root_layout_manager_.get()); |
375 | 374 |
376 // TODO(erg): In the aura version, we explicitly added ourselves as a | 375 // TODO(erg): In the aura version, we explicitly added ourselves as a |
377 // PreTargetHandler to the window() here. We probably have to do something | 376 // PreTargetHandler to the window() here. We probably have to do something |
378 // analogous here. | 377 // analogous here. |
379 | 378 |
380 window_manager_app_->InitFocus( | 379 window_manager_app_->InitFocus( |
381 scoped_ptr<mojo::FocusRules>(new mojo::BasicFocusRules(view))); | 380 make_scoped_ptr(new window_manager::BasicFocusRules(view))); |
382 } | 381 } |
383 virtual void OnViewManagerDisconnected(ViewManager* view_manager) override { | 382 virtual void OnViewManagerDisconnected(ViewManager* view_manager) override { |
384 DCHECK_EQ(view_manager_, view_manager); | 383 DCHECK_EQ(view_manager_, view_manager); |
385 view_manager_ = NULL; | 384 view_manager_ = NULL; |
386 base::MessageLoop::current()->Quit(); | 385 base::MessageLoop::current()->Quit(); |
387 } | 386 } |
388 | 387 |
389 // Overridden from WindowManagerDelegate: | 388 // Overridden from WindowManagerDelegate: |
390 virtual void Embed( | 389 virtual void Embed( |
391 const String& url, | 390 const String& url, |
392 InterfaceRequest<ServiceProvider> service_provider) override { | 391 InterfaceRequest<ServiceProvider> service_provider) override { |
393 const Id kInvalidSourceViewId = 0; | 392 const Id kInvalidSourceViewId = 0; |
394 OnLaunch(kInvalidSourceViewId, TARGET_DEFAULT, url); | 393 OnLaunch(kInvalidSourceViewId, TARGET_DEFAULT, url); |
395 } | 394 } |
396 | 395 |
397 // Overridden from ui::EventHandler: | 396 // Overridden from ui::EventHandler: |
398 virtual void OnEvent(ui::Event* event) override { | 397 virtual void OnEvent(ui::Event* event) override { |
399 View* view = static_cast<ViewTarget*>(event->target())->view(); | 398 View* view = |
| 399 static_cast<window_manager::ViewTarget*>(event->target())->view(); |
400 if (event->type() == ui::ET_MOUSE_PRESSED && | 400 if (event->type() == ui::ET_MOUSE_PRESSED && |
401 !IsDescendantOfKeyboard(view)) { | 401 !IsDescendantOfKeyboard(view)) { |
402 view->SetFocus(); | 402 view->SetFocus(); |
403 } | 403 } |
404 } | 404 } |
405 | 405 |
406 void OnLaunch(uint32 source_view_id, | 406 void OnLaunch(uint32 source_view_id, |
407 Target requested_target, | 407 Target requested_target, |
408 const mojo::String& url) { | 408 const mojo::String& url) { |
409 Target target = debug_panel_->navigation_target(); | 409 Target target = debug_panel_->navigation_target(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 InterfaceFactoryImplWithContext<WindowManagerConnection, WindowManager> | 511 InterfaceFactoryImplWithContext<WindowManagerConnection, WindowManager> |
512 window_manager_factory_; | 512 window_manager_factory_; |
513 | 513 |
514 scoped_ptr<ViewsInit> views_init_; | 514 scoped_ptr<ViewsInit> views_init_; |
515 DebugPanel* debug_panel_; | 515 DebugPanel* debug_panel_; |
516 Window* launcher_ui_; | 516 Window* launcher_ui_; |
517 WindowVector windows_; | 517 WindowVector windows_; |
518 ViewManager* view_manager_; | 518 ViewManager* view_manager_; |
519 scoped_ptr<RootLayoutManager> root_layout_manager_; | 519 scoped_ptr<RootLayoutManager> root_layout_manager_; |
520 | 520 |
521 scoped_ptr<WindowManagerApp> window_manager_app_; | 521 scoped_ptr<window_manager::WindowManagerApp> window_manager_app_; |
522 | 522 |
523 // Id of the view most content is added to. The keyboard is NOT added here. | 523 // Id of the view most content is added to. The keyboard is NOT added here. |
524 Id content_view_id_; | 524 Id content_view_id_; |
525 | 525 |
526 scoped_ptr<KeyboardManager> keyboard_manager_; | 526 scoped_ptr<KeyboardManager> keyboard_manager_; |
527 ApplicationImpl* app_; | 527 ApplicationImpl* app_; |
528 | 528 |
529 DISALLOW_COPY_AND_ASSIGN(WindowManager); | 529 DISALLOW_COPY_AND_ASSIGN(WindowManager); |
530 }; | 530 }; |
531 | 531 |
(...skipping 17 matching lines...) Expand all Loading... |
549 window_manager_->RequestNavigate(view_id_, target, request.Pass()); | 549 window_manager_->RequestNavigate(view_id_, target, request.Pass()); |
550 } | 550 } |
551 | 551 |
552 } // namespace examples | 552 } // namespace examples |
553 } // namespace mojo | 553 } // namespace mojo |
554 | 554 |
555 MojoResult MojoMain(MojoHandle shell_handle) { | 555 MojoResult MojoMain(MojoHandle shell_handle) { |
556 mojo::ApplicationRunnerChromium runner(new mojo::examples::WindowManager); | 556 mojo::ApplicationRunnerChromium runner(new mojo::examples::WindowManager); |
557 return runner.Run(shell_handle); | 557 return runner.Run(shell_handle); |
558 } | 558 } |
OLD | NEW |