| 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "mojo/application/application_runner_chromium.h" | 6 #include "mojo/application/application_runner_chromium.h" |
| 7 #include "mojo/public/c/system/main.h" | 7 #include "mojo/public/c/system/main.h" |
| 8 #include "mojo/public/cpp/application/application_delegate.h" | 8 #include "mojo/public/cpp/application/application_delegate.h" |
| 9 #include "mojo/public/cpp/application/service_provider_impl.h" | 9 #include "mojo/public/cpp/application/service_provider_impl.h" |
| 10 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 10 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
| 11 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 11 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
| 12 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h" | |
| 13 #include "mojo/services/window_manager/window_manager_app.h" | 12 #include "mojo/services/window_manager/window_manager_app.h" |
| 13 #include "mojo/services/window_manager/window_manager_delegate.h" |
| 14 | 14 |
| 15 // ApplicationDelegate implementation file for WindowManager users (e.g. | 15 // ApplicationDelegate implementation file for WindowManager users (e.g. |
| 16 // core window manager tests) that do not want to provide their own | 16 // core window manager tests) that do not want to provide their own |
| 17 // ApplicationDelegate::Create(). | 17 // ApplicationDelegate::Create(). |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace mojo { |
| 20 | 20 |
| 21 class DefaultWindowManager : public ApplicationDelegate, | 21 class DefaultWindowManager : public ApplicationDelegate, |
| 22 public ViewManagerDelegate, | 22 public ViewManagerDelegate, |
| 23 public WindowManagerDelegate { | 23 public WindowManagerDelegate { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 39 return true; | 39 return true; |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Overridden from ViewManagerDelegate: | 42 // Overridden from ViewManagerDelegate: |
| 43 virtual void OnEmbed(ViewManager* view_manager, | 43 virtual void OnEmbed(ViewManager* view_manager, |
| 44 View* root, | 44 View* root, |
| 45 ServiceProviderImpl* exported_services, | 45 ServiceProviderImpl* exported_services, |
| 46 scoped_ptr<ServiceProvider> imported_services) override { | 46 scoped_ptr<ServiceProvider> imported_services) override { |
| 47 view_manager_ = view_manager; | 47 view_manager_ = view_manager; |
| 48 root_ = root; | 48 root_ = root; |
| 49 view_manager_->SetWindowManagerDelegate(this); | |
| 50 } | 49 } |
| 51 virtual void OnViewManagerDisconnected(ViewManager* view_manager) override {} | 50 virtual void OnViewManagerDisconnected(ViewManager* view_manager) override {} |
| 52 | 51 |
| 53 // Overridden from WindowManagerDelegate: | 52 // Overridden from WindowManagerDelegate: |
| 54 virtual void Embed( | 53 virtual void Embed( |
| 55 const String& url, | 54 const String& url, |
| 56 InterfaceRequest<ServiceProvider> service_provider) override { | 55 InterfaceRequest<ServiceProvider> service_provider) override { |
| 57 View* view = View::Create(view_manager_); | 56 View* view = View::Create(view_manager_); |
| 58 root_->AddChild(view); | 57 root_->AddChild(view); |
| 59 view->Embed(url, scoped_ptr<mojo::ServiceProviderImpl>( | 58 view->Embed(url, scoped_ptr<mojo::ServiceProviderImpl>( |
| 60 new mojo::ServiceProviderImpl).Pass()); | 59 new mojo::ServiceProviderImpl).Pass()); |
| 61 } | 60 } |
| 62 virtual void DispatchEvent(EventPtr event) override {} | |
| 63 | 61 |
| 64 scoped_ptr<WindowManagerApp> window_manager_app_; | 62 scoped_ptr<WindowManagerApp> window_manager_app_; |
| 65 | 63 |
| 66 ViewManager* view_manager_; | 64 ViewManager* view_manager_; |
| 67 View* root_; | 65 View* root_; |
| 68 | 66 |
| 69 MOJO_DISALLOW_COPY_AND_ASSIGN(DefaultWindowManager); | 67 MOJO_DISALLOW_COPY_AND_ASSIGN(DefaultWindowManager); |
| 70 }; | 68 }; |
| 71 | 69 |
| 72 } // namespace mojo | 70 } // namespace mojo |
| 73 | 71 |
| 74 MojoResult MojoMain(MojoHandle shell_handle) { | 72 MojoResult MojoMain(MojoHandle shell_handle) { |
| 75 mojo::ApplicationRunnerChromium runner(new mojo::DefaultWindowManager); | 73 mojo::ApplicationRunnerChromium runner(new mojo::DefaultWindowManager); |
| 76 return runner.Run(shell_handle); | 74 return runner.Run(shell_handle); |
| 77 } | 75 } |
| OLD | NEW |