| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef COMPONENTS_MUS_EXAMPLE_WM_WINDOW_MANAGER_APPLICATION_H_ | 5 #ifndef COMPONENTS_MUS_EXAMPLE_WM_WINDOW_MANAGER_APPLICATION_H_ | 
| 6 #define COMPONENTS_MUS_EXAMPLE_WM_WINDOW_MANAGER_APPLICATION_H_ | 6 #define COMPONENTS_MUS_EXAMPLE_WM_WINDOW_MANAGER_APPLICATION_H_ | 
| 7 | 7 | 
| 8 #include "base/macros.h" | 8 #include "base/macros.h" | 
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" | 
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" | 
| 11 #include "components/mus/public/cpp/types.h" | 11 #include "components/mus/public/cpp/types.h" | 
|  | 12 #include "components/mus/public/cpp/window_observer.h" | 
| 12 #include "components/mus/public/cpp/window_tree_delegate.h" | 13 #include "components/mus/public/cpp/window_tree_delegate.h" | 
| 13 #include "components/mus/public/interfaces/window_manager.mojom.h" | 14 #include "components/mus/public/interfaces/window_manager.mojom.h" | 
| 14 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 15 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 
| 15 #include "mojo/application/public/cpp/application_delegate.h" | 16 #include "mojo/application/public/cpp/application_delegate.h" | 
| 16 #include "mojo/application/public/cpp/interface_factory_impl.h" | 17 #include "mojo/application/public/cpp/interface_factory_impl.h" | 
| 17 #include "mojo/common/weak_binding_set.h" | 18 #include "mojo/common/weak_binding_set.h" | 
| 18 | 19 | 
| 19 enum class Container; | 20 enum class Container; | 
| 20 class WindowLayout; | 21 class WindowLayout; | 
| 21 | 22 | 
| 22 class WindowManagerImpl; | 23 class WindowManagerImpl; | 
| 23 | 24 | 
| 24 class WindowManagerApplication | 25 class WindowManagerApplication | 
| 25     : public mojo::ApplicationDelegate, | 26     : public mojo::ApplicationDelegate, | 
|  | 27       public mus::WindowObserver, | 
| 26       public mus::WindowTreeDelegate, | 28       public mus::WindowTreeDelegate, | 
| 27       public mojo::InterfaceFactory<mus::mojom::WindowManager> { | 29       public mojo::InterfaceFactory<mus::mojom::WindowManager> { | 
| 28  public: | 30  public: | 
| 29   WindowManagerApplication(); | 31   WindowManagerApplication(); | 
| 30   ~WindowManagerApplication() override; | 32   ~WindowManagerApplication() override; | 
| 31 | 33 | 
| 32   mus::Window* root() { return root_; } | 34   mus::Window* root() { return root_; } | 
| 33 | 35 | 
| 34   int window_count() { return window_count_; } | 36   int window_count() { return window_count_; } | 
| 35   void IncrementWindowCount() { ++window_count_; } | 37   void IncrementWindowCount() { ++window_count_; } | 
| 36 | 38 | 
| 37   mus::Window* GetWindowForContainer(Container container); | 39   mus::Window* GetWindowForContainer(Container container); | 
| 38   mus::Window* GetWindowById(mus::Id id); | 40   mus::Window* GetWindowById(mus::Id id); | 
| 39 | 41 | 
| 40  private: | 42  private: | 
| 41   // ApplicationDelegate: | 43   // ApplicationDelegate: | 
| 42   void Initialize(mojo::ApplicationImpl* app) override; | 44   void Initialize(mojo::ApplicationImpl* app) override; | 
| 43   bool ConfigureIncomingConnection( | 45   bool ConfigureIncomingConnection( | 
| 44       mojo::ApplicationConnection* connection) override; | 46       mojo::ApplicationConnection* connection) override; | 
| 45 | 47 | 
| 46   // WindowTreeDelegate: | 48   // WindowTreeDelegate: | 
| 47   void OnEmbed(mus::Window* root) override; | 49   void OnEmbed(mus::Window* root) override; | 
| 48   void OnConnectionLost(mus::WindowTreeConnection* connection) override; | 50   void OnConnectionLost(mus::WindowTreeConnection* connection) override; | 
| 49 | 51 | 
| 50   // InterfaceFactory<mus::mojom::WindowManager>: | 52   // InterfaceFactory<mus::mojom::WindowManager>: | 
| 51   void Create( | 53   void Create( | 
| 52       mojo::ApplicationConnection* connection, | 54       mojo::ApplicationConnection* connection, | 
| 53       mojo::InterfaceRequest<mus::mojom::WindowManager> request) override; | 55       mojo::InterfaceRequest<mus::mojom::WindowManager> request) override; | 
| 54 | 56 | 
|  | 57   // mus::WindowObserver: | 
|  | 58   void OnWindowDestroyed(mus::Window* window) override; | 
|  | 59 | 
| 55   // Sets up the window containers used for z-space management. | 60   // Sets up the window containers used for z-space management. | 
| 56   void CreateContainers(); | 61   void CreateContainers(); | 
| 57 | 62 | 
| 58   // nullptr until the Mus connection is established via OnEmbed(). | 63   // nullptr until the Mus connection is established via OnEmbed(). | 
| 59   mus::Window* root_; | 64   mus::Window* root_; | 
| 60   int window_count_; | 65   int window_count_; | 
| 61 | 66 | 
| 62   mus::mojom::WindowTreeHostPtr host_; | 67   mus::mojom::WindowTreeHostPtr host_; | 
| 63 | 68 | 
| 64   // |window_manager_| is created once OnEmbed() is called. Until that time | 69   // |window_manager_| is created once OnEmbed() is called. Until that time | 
| 65   // |requests_| stores any pending WindowManager interface requests. | 70   // |requests_| stores any pending WindowManager interface requests. | 
| 66   scoped_ptr<WindowManagerImpl> window_manager_; | 71   scoped_ptr<WindowManagerImpl> window_manager_; | 
| 67   mojo::WeakBindingSet<mus::mojom::WindowManager> window_manager_binding_; | 72   mojo::WeakBindingSet<mus::mojom::WindowManager> window_manager_binding_; | 
| 68   ScopedVector<mojo::InterfaceRequest<mus::mojom::WindowManager>> requests_; | 73   ScopedVector<mojo::InterfaceRequest<mus::mojom::WindowManager>> requests_; | 
| 69 | 74 | 
| 70   scoped_ptr<WindowLayout> layout_; | 75   scoped_ptr<WindowLayout> layout_; | 
| 71 | 76 | 
| 72   DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication); | 77   DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication); | 
| 73 }; | 78 }; | 
| 74 | 79 | 
| 75 #endif  // COMPONENTS_MUS_EXAMPLE_WM_WINDOW_MANAGER_APPLICATION_H_ | 80 #endif  // COMPONENTS_MUS_EXAMPLE_WM_WINDOW_MANAGER_APPLICATION_H_ | 
| OLD | NEW | 
|---|