| 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.h" | 11 #include "mojo/aura/window_tree_host_mojo.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/types.h" | 15 #include "mojo/services/public/cpp/view_manager/types.h" |
| 16 #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" |
| 17 #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" | 18 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
| 19 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h" | 19 #include "mojo/services/window_manager/view_manager_service_delegate_impl.h" |
| 20 #include "mojo/services/window_manager/window_manager_service_impl.h" | 20 #include "mojo/services/window_manager/window_manager_service_impl.h" |
| 21 #include "ui/aura/client/focus_change_observer.h" | 21 #include "ui/aura/client/focus_change_observer.h" |
| 22 #include "ui/events/event_handler.h" | 22 #include "ui/events/event_handler.h" |
| 23 #include "ui/wm/public/activation_change_observer.h" | 23 #include "ui/wm/public/activation_change_observer.h" |
| 24 | 24 |
| 25 namespace aura { | 25 namespace aura { |
| 26 namespace client { | 26 namespace client { |
| 27 class ActivationClient; | 27 class ActivationClient; |
| 28 class FocusClient; | 28 class FocusClient; |
| 29 } | 29 } |
| 30 class Window; | 30 class Window; |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace wm { | 33 namespace wm { |
| 34 class FocusRules; | 34 class FocusRules; |
| 35 class ScopedCaptureClient; | 35 class ScopedCaptureClient; |
| 36 } | 36 } |
| 37 | 37 |
| 38 namespace mojo { | 38 namespace mojo { |
| 39 | 39 |
| 40 class AuraInit; | 40 class AuraInit; |
| 41 class DummyDelegate; | 41 class DummyDelegate; |
| 42 class ViewManagerServiceDelegateClient; |
| 43 class WindowManagerDelegate; |
| 42 class WindowManagerServiceImpl; | 44 class WindowManagerServiceImpl; |
| 43 class WindowTreeHostMojo; | |
| 44 | 45 |
| 45 // Implements core window manager functionality that could conceivably be shared | 46 // Implements core window manager functionality that could conceivably be shared |
| 46 // across multiple window managers implementing superficially different user | 47 // across multiple window managers implementing superficially different user |
| 47 // experiences. Establishes communication with the view manager. | 48 // experiences. Establishes communication with the view manager. |
| 48 // A window manager wishing to use this core should create and own an instance | 49 // A window manager wishing to use this core should create and own an instance |
| 49 // of this object. They may implement the associated ViewManager/WindowManager | 50 // of this object. They may implement the associated ViewManager/WindowManager |
| 50 // delegate interfaces exposed by the view manager, this object provides the | 51 // delegate interfaces exposed by the view manager, this object provides the |
| 51 // canonical implementation of said interfaces but will call out to the wrapped | 52 // canonical implementation of said interfaces but will call out to the wrapped |
| 52 // instances. | 53 // instances. |
| 53 // This object maintains an aura::WindowTreeHost containing a hierarchy of | 54 // This object maintains an aura::WindowTreeHost containing a hierarchy of |
| 54 // aura::Windows. Window manager functionality (e.g. focus, activation, | 55 // aura::Windows. Window manager functionality (e.g. focus, activation, |
| 55 // modality, etc.) are implemented using aura core window manager components. | 56 // modality, etc.) are implemented using aura core window manager components. |
| 56 class WindowManagerApp | 57 class WindowManagerApp |
| 57 : public ApplicationDelegate, | 58 : public ApplicationDelegate, |
| 58 public ViewManagerDelegate, | 59 public ViewManagerDelegate, |
| 59 public WindowManagerDelegate, | |
| 60 public ViewObserver, | 60 public ViewObserver, |
| 61 public ui::EventHandler, | 61 public ui::EventHandler, |
| 62 public aura::client::FocusChangeObserver, | 62 public aura::client::FocusChangeObserver, |
| 63 public aura::client::ActivationChangeObserver { | 63 public aura::client::ActivationChangeObserver { |
| 64 public: | 64 public: |
| 65 WindowManagerApp(ViewManagerDelegate* view_manager_delegate, | 65 WindowManagerApp(ViewManagerDelegate* view_manager_delegate, |
| 66 WindowManagerDelegate* window_manager_delegate); | 66 WindowManagerDelegate* window_manager_delegate); |
| 67 virtual ~WindowManagerApp(); | 67 virtual ~WindowManagerApp(); |
| 68 | 68 |
| 69 static View* GetViewForWindow(aura::Window* window); | 69 static View* GetViewForWindow(aura::Window* window); |
| 70 aura::Window* GetWindowForViewId(Id view); | 70 aura::Window* GetWindowForViewId(Id view); |
| 71 | 71 |
| 72 // Register/deregister new connections to the window manager service. | 72 // Register/deregister new connections to the window manager service. |
| 73 void AddConnection(WindowManagerServiceImpl* connection); | 73 void AddConnection(WindowManagerServiceImpl* connection); |
| 74 void RemoveConnection(WindowManagerServiceImpl* connection); | 74 void RemoveConnection(WindowManagerServiceImpl* connection); |
| 75 | 75 |
| 76 // These are canonical implementations of the window manager API methods. | 76 // These are canonical implementations of the window manager API methods. |
| 77 void SetCapture(Id view); | 77 void SetCapture(Id view); |
| 78 void FocusWindow(Id view); | 78 void FocusWindow(Id view); |
| 79 void ActivateWindow(Id view); | 79 void ActivateWindow(Id view); |
| 80 | 80 |
| 81 bool IsReady() const; | 81 bool IsReady() const; |
| 82 | 82 |
| 83 // A client of this object will use this accessor to gain access to the | 83 // A client of this object will use this accessor to gain access to the |
| 84 // aura::Window hierarchy and attach event handlers. | 84 // aura::Window hierarchy and attach event handlers. |
| 85 aura::WindowTreeHost* host() { return window_tree_host_.get(); } | 85 WindowTreeHostMojo* host() { return window_tree_host_.get(); } |
| 86 |
| 87 WindowManagerDelegate* window_manager_delegate() { |
| 88 return window_manager_delegate_; |
| 89 } |
| 86 | 90 |
| 87 void InitFocus(wm::FocusRules* rules); | 91 void InitFocus(wm::FocusRules* rules); |
| 88 | 92 |
| 93 void set_view_manager_service_client_delegate( |
| 94 ViewManagerServiceDelegateClient* client) { |
| 95 view_manager_service_delegate_client_ = client; |
| 96 } |
| 97 |
| 89 // Overridden from ApplicationDelegate: | 98 // Overridden from ApplicationDelegate: |
| 90 virtual void Initialize(ApplicationImpl* impl) override; | 99 virtual void Initialize(ApplicationImpl* impl) override; |
| 91 virtual bool ConfigureIncomingConnection( | 100 virtual bool ConfigureIncomingConnection( |
| 92 ApplicationConnection* connection) override; | 101 ApplicationConnection* connection) override; |
| 93 | 102 |
| 94 private: | 103 private: |
| 95 typedef std::set<WindowManagerServiceImpl*> Connections; | 104 typedef std::set<WindowManagerServiceImpl*> Connections; |
| 96 typedef std::map<Id, aura::Window*> ViewIdToWindowMap; | 105 typedef std::map<Id, aura::Window*> ViewIdToWindowMap; |
| 97 | 106 |
| 98 // Overridden from ViewManagerDelegate: | 107 // Overridden from ViewManagerDelegate: |
| 99 virtual void OnEmbed(ViewManager* view_manager, | 108 virtual void OnEmbed(ViewManager* view_manager, |
| 100 View* root, | 109 View* root, |
| 101 ServiceProviderImpl* exported_services, | 110 ServiceProviderImpl* exported_services, |
| 102 scoped_ptr<ServiceProvider> imported_services) override; | 111 scoped_ptr<ServiceProvider> imported_services) override; |
| 103 virtual void OnViewManagerDisconnected(ViewManager* view_manager) override; | 112 virtual void OnViewManagerDisconnected(ViewManager* view_manager) override; |
| 104 | 113 |
| 105 // Overridden from WindowManagerDelegate: | |
| 106 virtual void Embed( | |
| 107 const String& url, | |
| 108 InterfaceRequest<ServiceProvider> service_provider) override; | |
| 109 virtual void DispatchEvent(EventPtr event) override; | |
| 110 | |
| 111 // Overridden from ViewObserver: | 114 // Overridden from ViewObserver: |
| 112 virtual void OnTreeChanged( | 115 virtual void OnTreeChanged( |
| 113 const ViewObserver::TreeChangeParams& params) override; | 116 const ViewObserver::TreeChangeParams& params) override; |
| 114 virtual void OnViewDestroying(View* view) override; | 117 virtual void OnViewDestroying(View* view) override; |
| 115 virtual void OnViewBoundsChanged(View* view, | 118 virtual void OnViewBoundsChanged(View* view, |
| 116 const gfx::Rect& old_bounds, | 119 const gfx::Rect& old_bounds, |
| 117 const gfx::Rect& new_bounds) override; | 120 const gfx::Rect& new_bounds) override; |
| 118 | 121 |
| 119 // Overridden from ui::EventHandler: | 122 // Overridden from ui::EventHandler: |
| 120 virtual void OnEvent(ui::Event* event) override; | 123 virtual void OnEvent(ui::Event* event) override; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 136 void UnregisterSubtree(View* view); | 139 void UnregisterSubtree(View* view); |
| 137 // Deletes the aura::Windows associated with the hierarchy beneath |id|, | 140 // Deletes the aura::Windows associated with the hierarchy beneath |id|, |
| 138 // and removes from the registry. | 141 // and removes from the registry. |
| 139 void Unregister(View* view); | 142 void Unregister(View* view); |
| 140 | 143 |
| 141 Shell* shell_; | 144 Shell* shell_; |
| 142 | 145 |
| 143 InterfaceFactoryImplWithContext<WindowManagerServiceImpl, WindowManagerApp> | 146 InterfaceFactoryImplWithContext<WindowManagerServiceImpl, WindowManagerApp> |
| 144 window_manager_service_factory_; | 147 window_manager_service_factory_; |
| 145 | 148 |
| 149 InterfaceFactoryImplWithContext<ViewManagerServiceDelegateImpl, |
| 150 WindowManagerApp> |
| 151 view_manager_service_delegate_factory_; |
| 152 |
| 146 ViewManagerDelegate* wrapped_view_manager_delegate_; | 153 ViewManagerDelegate* wrapped_view_manager_delegate_; |
| 147 WindowManagerDelegate* wrapped_window_manager_delegate_; | 154 WindowManagerDelegate* window_manager_delegate_; |
| 148 | 155 |
| 149 ViewManager* view_manager_; | 156 ViewManager* view_manager_; |
| 150 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; | 157 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; |
| 151 View* root_; | 158 View* root_; |
| 152 | 159 |
| 153 scoped_ptr<AuraInit> aura_init_; | 160 scoped_ptr<AuraInit> aura_init_; |
| 154 scoped_ptr<WindowTreeHostMojo> window_tree_host_; | 161 scoped_ptr<WindowTreeHostMojo> window_tree_host_; |
| 155 | 162 |
| 156 scoped_ptr<wm::ScopedCaptureClient> capture_client_; | 163 scoped_ptr<wm::ScopedCaptureClient> capture_client_; |
| 157 scoped_ptr<aura::client::FocusClient> focus_client_; | 164 scoped_ptr<aura::client::FocusClient> focus_client_; |
| 158 aura::client::ActivationClient* activation_client_; | 165 aura::client::ActivationClient* activation_client_; |
| 159 | 166 |
| 160 Connections connections_; | 167 Connections connections_; |
| 161 ViewIdToWindowMap view_id_to_window_map_; | 168 ViewIdToWindowMap view_id_to_window_map_; |
| 162 | 169 |
| 163 scoped_ptr<DummyDelegate> dummy_delegate_; | 170 scoped_ptr<DummyDelegate> dummy_delegate_; |
| 164 | 171 |
| 172 ViewManagerServiceDelegateClient* view_manager_service_delegate_client_; |
| 173 |
| 165 DISALLOW_COPY_AND_ASSIGN(WindowManagerApp); | 174 DISALLOW_COPY_AND_ASSIGN(WindowManagerApp); |
| 166 }; | 175 }; |
| 167 | 176 |
| 168 } // namespace mojo | 177 } // namespace mojo |
| 169 | 178 |
| 170 #endif // MOJO_SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_ | 179 #endif // MOJO_SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_ |
| OLD | NEW |