Move PseudoTCP and channel auth out of LibjingleTransportFactory.
[chromium-blink-merge.git] / mojo / services / window_manager / window_manager_app.h
blobc60adc5fdf77455075440b8b31a53d5477243c50
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
3 // found in the LICENSE file.
5 #ifndef MOJO_SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_
6 #define MOJO_SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_
8 #include <set>
10 #include "base/memory/scoped_ptr.h"
11 #include "mojo/aura/window_tree_host_mojo.h"
12 #include "mojo/aura/window_tree_host_mojo_delegate.h"
13 #include "mojo/public/cpp/application/application_delegate.h"
14 #include "mojo/public/cpp/application/interface_factory_impl.h"
15 #include "mojo/public/cpp/bindings/string.h"
16 #include "mojo/services/public/cpp/view_manager/types.h"
17 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h"
18 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
19 #include "mojo/services/public/cpp/view_manager/view_observer.h"
20 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h"
21 #include "mojo/services/window_manager/window_manager_service_impl.h"
22 #include "ui/aura/client/focus_change_observer.h"
23 #include "ui/events/event_handler.h"
24 #include "ui/wm/public/activation_change_observer.h"
26 namespace aura {
27 namespace client {
28 class ActivationClient;
29 class FocusClient;
31 class Window;
34 namespace wm {
35 class ScopedCaptureClient;
38 namespace mojo {
40 class AuraInit;
41 class DummyDelegate;
42 class WindowManagerServiceImpl;
43 class WindowTreeHostMojo;
45 // Implements core window manager functionality that could conceivably be shared
46 // across multiple window managers implementing superficially different user
47 // experiences. Establishes communication with the view manager.
48 // 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 // 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 // instances.
53 // This object maintains an aura::WindowTreeHost containing a hierarchy of
54 // aura::Windows. Window manager functionality (e.g. focus, activation,
55 // modality, etc.) are implemented using aura core window manager components.
56 class WindowManagerApp
57 : public ApplicationDelegate,
58 public ViewManagerDelegate,
59 public WindowManagerDelegate,
60 public ViewObserver,
61 public WindowTreeHostMojoDelegate,
62 public ui::EventHandler,
63 public aura::client::FocusChangeObserver,
64 public aura::client::ActivationChangeObserver {
65 public:
66 WindowManagerApp(ViewManagerDelegate* view_manager_delegate,
67 WindowManagerDelegate* window_manager_delegate);
68 virtual ~WindowManagerApp();
70 static View* GetViewForWindow(aura::Window* window);
72 // Register/deregister new connections to the window manager service.
73 void AddConnection(WindowManagerServiceImpl* connection);
74 void RemoveConnection(WindowManagerServiceImpl* connection);
76 // These are canonical implementations of the window manager API methods.
77 void SetCapture(Id view);
78 void FocusWindow(Id view);
79 void ActivateWindow(Id view);
81 bool IsReady() const;
83 // A client of this object will use this accessor to gain access to the
84 // aura::Window hierarchy and attach event handlers.
85 aura::WindowTreeHost* host() { return window_tree_host_.get(); }
87 // Overridden from ApplicationDelegate:
88 virtual void Initialize(ApplicationImpl* impl) MOJO_OVERRIDE;
89 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
90 MOJO_OVERRIDE;
92 private:
93 typedef std::set<WindowManagerServiceImpl*> Connections;
94 typedef std::map<Id, aura::Window*> ViewIdToWindowMap;
96 // Overridden from ViewManagerDelegate:
97 virtual void OnEmbed(
98 ViewManager* view_manager,
99 View* root,
100 ServiceProviderImpl* exported_services,
101 scoped_ptr<ServiceProvider> imported_services) MOJO_OVERRIDE;
102 virtual void OnViewManagerDisconnected(
103 ViewManager* view_manager) MOJO_OVERRIDE;
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;
111 // Overridden from ViewObserver:
112 virtual void OnTreeChanged(
113 const ViewObserver::TreeChangeParams& params) MOJO_OVERRIDE;
114 virtual void OnViewDestroyed(View* view) MOJO_OVERRIDE;
115 virtual void OnViewBoundsChanged(View* view,
116 const gfx::Rect& old_bounds,
117 const gfx::Rect& new_bounds) MOJO_OVERRIDE;
119 // Overridden from WindowTreeHostMojoDelegate:
120 virtual void CompositorContentsChanged(const SkBitmap& bitmap) MOJO_OVERRIDE;
122 // Overridden from ui::EventHandler:
123 virtual void OnEvent(ui::Event* event) MOJO_OVERRIDE;
125 // Overridden from aura::client::FocusChangeObserver:
126 virtual void OnWindowFocused(aura::Window* gained_focus,
127 aura::Window* lost_focus) MOJO_OVERRIDE;
129 // Overridden from aura::client::ActivationChangeObserver:
130 virtual void OnWindowActivated(aura::Window* gained_active,
131 aura::Window* lost_active) MOJO_OVERRIDE;
133 aura::Window* GetWindowForViewId(Id view) const;
135 // Creates an aura::Window for every view in the hierarchy beneath |view|,
136 // and adds to the registry so that it can be retrieved later via
137 // GetWindowForViewId().
138 // TODO(beng): perhaps View should have a property bag.
139 void RegisterSubtree(View* view, aura::Window* parent);
140 // Deletes the aura::Windows associated with the hierarchy beneath |id|,
141 // and removes from the registry.
142 void UnregisterSubtree(View* view);
144 InterfaceFactoryImplWithContext<WindowManagerServiceImpl, WindowManagerApp>
145 window_manager_service_factory_;
147 ViewManagerDelegate* wrapped_view_manager_delegate_;
148 WindowManagerDelegate* wrapped_window_manager_delegate_;
150 ViewManager* view_manager_;
151 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_;
152 View* root_;
154 scoped_ptr<AuraInit> aura_init_;
155 scoped_ptr<WindowTreeHostMojo> window_tree_host_;
157 scoped_ptr<wm::ScopedCaptureClient> capture_client_;
158 scoped_ptr<aura::client::FocusClient> focus_client_;
159 aura::client::ActivationClient* activation_client_;
161 Connections connections_;
162 ViewIdToWindowMap view_id_to_window_map_;
164 scoped_ptr<DummyDelegate> dummy_delegate_;
166 DISALLOW_COPY_AND_ASSIGN(WindowManagerApp);
169 } // namespace mojo
171 #endif // MOJO_SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_