| 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 #ifndef MOJO_SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_ | 5 #ifndef MOJO_SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_ |
| 6 #define MOJO_SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_ | 6 #define MOJO_SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "mojo/aura/window_tree_host_mojo_delegate.h" | 11 #include "mojo/aura/window_tree_host_mojo_delegate.h" |
| 12 #include "mojo/public/cpp/application/application_delegate.h" | 12 #include "mojo/public/cpp/application/application_delegate.h" |
| 13 #include "mojo/public/cpp/application/interface_factory_impl.h" | 13 #include "mojo/public/cpp/application/interface_factory_impl.h" |
| 14 #include "mojo/public/cpp/bindings/string.h" | 14 #include "mojo/public/cpp/bindings/string.h" |
| 15 #include "mojo/services/public/cpp/view_manager/node_observer.h" | |
| 16 #include "mojo/services/public/cpp/view_manager/types.h" | 15 #include "mojo/services/public/cpp/view_manager/types.h" |
| 17 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" | 16 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" |
| 18 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 17 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
| 18 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
| 19 #include "mojo/services/window_manager/window_manager_service_impl.h" | 19 #include "mojo/services/window_manager/window_manager_service_impl.h" |
| 20 #include "ui/aura/client/focus_change_observer.h" | 20 #include "ui/aura/client/focus_change_observer.h" |
| 21 #include "ui/wm/public/activation_change_observer.h" | 21 #include "ui/wm/public/activation_change_observer.h" |
| 22 | 22 |
| 23 namespace aura { | 23 namespace aura { |
| 24 namespace client { | 24 namespace client { |
| 25 class ActivationClient; | 25 class ActivationClient; |
| 26 class FocusClient; | 26 class FocusClient; |
| 27 } | 27 } |
| 28 class Window; | 28 class Window; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace wm { | 31 namespace wm { |
| 32 class ScopedCaptureClient; | 32 class ScopedCaptureClient; |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace mojo { | 35 namespace mojo { |
| 36 | 36 |
| 37 class AuraInit; | 37 class AuraInit; |
| 38 class WindowManagerServiceImpl; | 38 class WindowManagerServiceImpl; |
| 39 class WindowTreeHostMojo; | 39 class WindowTreeHostMojo; |
| 40 | 40 |
| 41 class WindowManagerApp | 41 class WindowManagerApp |
| 42 : public ApplicationDelegate, | 42 : public ApplicationDelegate, |
| 43 public ViewManagerDelegate, | 43 public ViewManagerDelegate, |
| 44 public NodeObserver, | 44 public ViewObserver, |
| 45 public WindowTreeHostMojoDelegate, | 45 public WindowTreeHostMojoDelegate, |
| 46 public aura::client::FocusChangeObserver, | 46 public aura::client::FocusChangeObserver, |
| 47 public aura::client::ActivationChangeObserver { | 47 public aura::client::ActivationChangeObserver { |
| 48 public: | 48 public: |
| 49 explicit WindowManagerApp(ViewManagerDelegate* delegate); | 49 explicit WindowManagerApp(ViewManagerDelegate* delegate); |
| 50 virtual ~WindowManagerApp(); | 50 virtual ~WindowManagerApp(); |
| 51 | 51 |
| 52 void AddConnection(WindowManagerServiceImpl* connection); | 52 void AddConnection(WindowManagerServiceImpl* connection); |
| 53 void RemoveConnection(WindowManagerServiceImpl* connection); | 53 void RemoveConnection(WindowManagerServiceImpl* connection); |
| 54 | 54 |
| 55 Id OpenWindow(); | 55 Id OpenWindow(); |
| 56 Id OpenWindowWithURL(const String& url); | 56 Id OpenWindowWithURL(const String& url); |
| 57 void SetCapture(Id node); | 57 void SetCapture(Id view); |
| 58 void FocusWindow(Id node); | 58 void FocusWindow(Id view); |
| 59 void ActivateWindow(Id node); | 59 void ActivateWindow(Id view); |
| 60 | 60 |
| 61 bool IsReady() const; | 61 bool IsReady() const; |
| 62 | 62 |
| 63 // Overridden from ApplicationDelegate: | 63 // Overridden from ApplicationDelegate: |
| 64 virtual void Initialize(ApplicationImpl* impl) MOJO_OVERRIDE; | 64 virtual void Initialize(ApplicationImpl* impl) MOJO_OVERRIDE; |
| 65 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) | 65 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) |
| 66 MOJO_OVERRIDE; | 66 MOJO_OVERRIDE; |
| 67 | 67 |
| 68 private: | 68 private: |
| 69 typedef std::set<WindowManagerServiceImpl*> Connections; | 69 typedef std::set<WindowManagerServiceImpl*> Connections; |
| 70 typedef std::map<Id, aura::Window*> NodeIdToWindowMap; | 70 typedef std::map<Id, aura::Window*> ViewIdToWindowMap; |
| 71 | 71 |
| 72 // Overridden from ViewManagerDelegate: | 72 // Overridden from ViewManagerDelegate: |
| 73 virtual void OnEmbed( | 73 virtual void OnEmbed( |
| 74 ViewManager* view_manager, | 74 ViewManager* view_manager, |
| 75 Node* root, | 75 View* root, |
| 76 ServiceProviderImpl* exported_services, | 76 ServiceProviderImpl* exported_services, |
| 77 scoped_ptr<ServiceProvider> imported_services) MOJO_OVERRIDE; | 77 scoped_ptr<ServiceProvider> imported_services) MOJO_OVERRIDE; |
| 78 virtual void OnViewManagerDisconnected( | 78 virtual void OnViewManagerDisconnected( |
| 79 ViewManager* view_manager) MOJO_OVERRIDE; | 79 ViewManager* view_manager) MOJO_OVERRIDE; |
| 80 | 80 |
| 81 // Overridden from NodeObserver: | 81 // Overridden from ViewObserver: |
| 82 virtual void OnTreeChanged( | 82 virtual void OnTreeChanged( |
| 83 const NodeObserver::TreeChangeParams& params) MOJO_OVERRIDE; | 83 const ViewObserver::TreeChangeParams& params) MOJO_OVERRIDE; |
| 84 virtual void OnNodeDestroyed(Node* node) MOJO_OVERRIDE; | 84 virtual void OnViewDestroyed(View* view) MOJO_OVERRIDE; |
| 85 | 85 |
| 86 // Overridden from WindowTreeHostMojoDelegate: | 86 // Overridden from WindowTreeHostMojoDelegate: |
| 87 virtual void CompositorContentsChanged(const SkBitmap& bitmap) MOJO_OVERRIDE; | 87 virtual void CompositorContentsChanged(const SkBitmap& bitmap) MOJO_OVERRIDE; |
| 88 | 88 |
| 89 // Overridden from aura::client::FocusChangeObserver: | 89 // Overridden from aura::client::FocusChangeObserver: |
| 90 virtual void OnWindowFocused(aura::Window* gained_focus, | 90 virtual void OnWindowFocused(aura::Window* gained_focus, |
| 91 aura::Window* lost_focus) MOJO_OVERRIDE; | 91 aura::Window* lost_focus) MOJO_OVERRIDE; |
| 92 | 92 |
| 93 // Overridden from aura::client::ActivationChangeObserver: | 93 // Overridden from aura::client::ActivationChangeObserver: |
| 94 virtual void OnWindowActivated(aura::Window* gained_active, | 94 virtual void OnWindowActivated(aura::Window* gained_active, |
| 95 aura::Window* lost_active) MOJO_OVERRIDE; | 95 aura::Window* lost_active) MOJO_OVERRIDE; |
| 96 | 96 |
| 97 aura::Window* GetWindowForNodeId(Id node) const; | 97 aura::Window* GetWindowForViewId(Id view) const; |
| 98 | 98 |
| 99 // Creates an aura::Window for every node in the hierarchy beneath |id|, | 99 // Creates an aura::Window for every view in the hierarchy beneath |id|, |
| 100 // and adds to the registry so that it can be retrieved later via | 100 // and adds to the registry so that it can be retrieved later via |
| 101 // GetWindowForNodeId(). | 101 // GetWindowForViewId(). |
| 102 // TODO(beng): perhaps Node should have a property bag. | 102 // TODO(beng): perhaps View should have a property bag. |
| 103 void RegisterSubtree(Id id, aura::Window* parent); | 103 void RegisterSubtree(Id id, aura::Window* parent); |
| 104 // Deletes the aura::Windows associated with the hierarchy beneath |id|, | 104 // Deletes the aura::Windows associated with the hierarchy beneath |id|, |
| 105 // and removes from the registry. | 105 // and removes from the registry. |
| 106 void UnregisterSubtree(Id id); | 106 void UnregisterSubtree(Id id); |
| 107 | 107 |
| 108 InterfaceFactoryImplWithContext<WindowManagerServiceImpl, WindowManagerApp> | 108 InterfaceFactoryImplWithContext<WindowManagerServiceImpl, WindowManagerApp> |
| 109 window_manager_service_factory_; | 109 window_manager_service_factory_; |
| 110 | 110 |
| 111 ViewManagerDelegate* wrapped_delegate_; | 111 ViewManagerDelegate* wrapped_delegate_; |
| 112 | 112 |
| 113 ViewManager* view_manager_; | 113 ViewManager* view_manager_; |
| 114 ViewManagerClientFactory view_manager_client_factory_; | 114 ViewManagerClientFactory view_manager_client_factory_; |
| 115 Node* root_; | 115 View* root_; |
| 116 | 116 |
| 117 scoped_ptr<AuraInit> aura_init_; | 117 scoped_ptr<AuraInit> aura_init_; |
| 118 scoped_ptr<WindowTreeHostMojo> window_tree_host_; | 118 scoped_ptr<WindowTreeHostMojo> window_tree_host_; |
| 119 | 119 |
| 120 scoped_ptr<wm::ScopedCaptureClient> capture_client_; | 120 scoped_ptr<wm::ScopedCaptureClient> capture_client_; |
| 121 scoped_ptr<aura::client::FocusClient> focus_client_; | 121 scoped_ptr<aura::client::FocusClient> focus_client_; |
| 122 aura::client::ActivationClient* activation_client_; | 122 aura::client::ActivationClient* activation_client_; |
| 123 | 123 |
| 124 Connections connections_; | 124 Connections connections_; |
| 125 NodeIdToWindowMap node_id_to_window_map_; | 125 ViewIdToWindowMap view_id_to_window_map_; |
| 126 | 126 |
| 127 DISALLOW_COPY_AND_ASSIGN(WindowManagerApp); | 127 DISALLOW_COPY_AND_ASSIGN(WindowManagerApp); |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 } // namespace mojo | 130 } // namespace mojo |
| 131 | 131 |
| 132 #endif // MOJO_SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_ | 132 #endif // MOJO_SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_ |
| OLD | NEW |