Chromium Code Reviews| Index: mojo/services/window_manager/main.cc |
| diff --git a/mojo/services/window_manager/main.cc b/mojo/services/window_manager/main.cc |
| index b77d3885a469c72bf7777220e8dec2654c8f3bd4..1e5041bb9eb2ad58d213c619d401814af26e51b8 100644 |
| --- a/mojo/services/window_manager/main.cc |
| +++ b/mojo/services/window_manager/main.cc |
| @@ -2,7 +2,12 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "mojo/public/cpp/application/application_delegate.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "mojo/public/cpp/application/application_delegate.h" |
| +#include "mojo/public/cpp/application/service_provider_impl.h" |
| +#include "mojo/services/public/cpp/view_manager/view_manager.h" |
| +#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
| +#include "mojo/services/public/cpp/view_manager/window_manager_delegate.h" |
| #include "mojo/services/window_manager/window_manager_app.h" |
| // ApplicationDelegate implementation file for WindowManager users (e.g. |
| @@ -11,9 +16,61 @@ |
| namespace mojo { |
| -// static |
| -ApplicationDelegate* ApplicationDelegate::Create() { |
| - return new WindowManagerApp(NULL); |
| +class DefaultWindowManager : public ApplicationDelegate, |
| + public ViewManagerDelegate, |
| + public WindowManagerDelegate { |
| + public: |
| + DefaultWindowManager() |
| + : window_manager_app_(new WindowManagerApp(this)), |
| + view_manager_(NULL) {} |
|
sky
2014/08/13 14:41:53
root_(NULL) too.
|
| + virtual ~DefaultWindowManager() {} |
| + |
| + private: |
| + // Overridden from ApplicationDelegate: |
| + virtual void Initialize(ApplicationImpl* impl) MOJO_OVERRIDE { |
| + window_manager_app_->Initialize(impl); |
| + } |
| + virtual bool ConfigureIncomingConnection( |
| + ApplicationConnection* connection) MOJO_OVERRIDE { |
| + window_manager_app_->ConfigureIncomingConnection(connection); |
| + return true; |
| + } |
| + |
| + // Overridden from ViewManagerDelegate: |
| + virtual void OnEmbed( |
| + ViewManager* view_manager, |
| + View* root, |
| + ServiceProviderImpl* exported_services, |
| + scoped_ptr<ServiceProvider> imported_services) MOJO_OVERRIDE { |
| + view_manager_ = view_manager; |
| + root_ = root; |
| + view_manager_->SetWindowManagerDelegate(this); |
| + } |
| + virtual void OnViewManagerDisconnected( |
| + ViewManager* view_manager) MOJO_OVERRIDE {} |
| + |
| + // Overridden from WindowManagerDelegate: |
| + virtual void Embed( |
| + const String& url, |
| + InterfaceRequest<ServiceProvider> service_provider) MOJO_OVERRIDE { |
| + View* view = View::Create(view_manager_); |
| + root_->AddChild(view); |
| + view->Embed(url, scoped_ptr<mojo::ServiceProviderImpl>( |
| + new mojo::ServiceProviderImpl).Pass()); |
| + } |
| + virtual void DispatchEvent(View* target, EventPtr event) MOJO_OVERRIDE {} |
| + |
| + scoped_ptr<WindowManagerApp> window_manager_app_; |
| + |
| + ViewManager* view_manager_; |
| + View* root_; |
| + |
| + MOJO_DISALLOW_COPY_AND_ASSIGN(DefaultWindowManager); |
| +}; |
| + |
| +// static |
| +ApplicationDelegate* ApplicationDelegate::Create() { |
| + return new DefaultWindowManager; |
| } |
| } // namespace mojo |