Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: services/window_manager/window_manager_root.h

Issue 1531403003: Delete the ViewManager and WindowManager services. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-3
Patch Set: rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_ROOT_H_
6 #define SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_ROOT_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h"
10 #include "mojo/public/cpp/application/application_delegate.h"
11 #include "mojo/public/cpp/application/interface_factory_impl.h"
12 #include "mojo/public/cpp/bindings/binding.h"
13 #include "mojo/public/cpp/bindings/string.h"
14 #include "mojo/services/view_manager/cpp/types.h"
15 #include "mojo/services/view_manager/cpp/view_manager_client_factory.h"
16 #include "mojo/services/view_manager/cpp/view_manager_delegate.h"
17 #include "mojo/services/view_manager/cpp/view_observer.h"
18 #include "mojo/services/window_manager/interfaces/window_manager_internal.mojom. h"
19 #include "services/window_manager/capture_controller_observer.h"
20 #include "services/window_manager/focus_controller_observer.h"
21 #include "services/window_manager/native_viewport_event_dispatcher_impl.h"
22 #include "services/window_manager/view_target.h"
23 #include "services/window_manager/window_manager_delegate.h"
24 #include "services/window_manager/window_manager_impl.h"
25 #include "ui/base/accelerators/accelerator_manager.h"
26 #include "ui/events/event_handler.h"
27
28 namespace gfx {
29 class Size;
30 }
31
32 namespace window_manager {
33
34 class CaptureController;
35 class FocusController;
36 class FocusRules;
37 class ViewEventDispatcher;
38 class WindowManagerDelegate;
39 class WindowManagerImpl;
40
41 // Represents the root of a Mojo-managed window hierarchy. Each root has a
42 // 1-to-1 link with a native platform window. WindowManagerRoot manages its own
43 // lifetime.
44 class WindowManagerRoot
45 : public mojo::ViewManagerDelegate,
46 public mojo::ViewObserver,
47 public ui::EventHandler,
48 public FocusControllerObserver,
49 public CaptureControllerObserver,
50 public mojo::InterfaceFactory<mojo::WindowManagerInternal>,
51 public mojo::InterfaceFactory<mojo::NativeViewportEventDispatcher>,
52 public mojo::WindowManagerInternal {
53 public:
54 WindowManagerRoot(mojo::ApplicationImpl* application_impl,
55 mojo::ApplicationConnection* connection,
56 WindowManagerControllerFactory* controller_factory,
57 mojo::InterfaceRequest<mojo::WindowManager> request);
58 ~WindowManagerRoot() override;
59
60 ViewEventDispatcher* event_dispatcher() {
61 return view_event_dispatcher_.get();
62 }
63
64 // Deregisters connections to the window manager service.
65 void RemoveConnectedService(WindowManagerImpl* service);
66
67 // These are canonical implementations of the window manager API methods.
68 bool SetCapture(mojo::Id view);
69 bool FocusWindow(mojo::Id view);
70 bool ActivateWindow(mojo::Id view);
71
72 void DispatchInputEventToView(mojo::View* view, mojo::EventPtr event);
73 void SetViewportSize(const gfx::Size& size);
74
75 bool IsReady() const;
76
77 FocusController* focus_controller() { return focus_controller_.get(); }
78 CaptureController* capture_controller() { return capture_controller_.get(); }
79
80 void InitFocus(scoped_ptr<FocusRules> rules);
81
82 ui::AcceleratorManager* accelerator_manager() {
83 return &accelerator_manager_;
84 }
85
86 // WindowManagerImpl::Embed() forwards to this. If connected to ViewManager
87 // then forwards to delegate, otherwise waits for connection to establish then
88 // forwards.
89 void Embed(const mojo::String& url,
90 mojo::InterfaceRequest<mojo::ServiceProvider> services,
91 mojo::ServiceProviderPtr exposed_services);
92
93 private:
94 typedef ScopedVector<WindowManagerImpl> ConnectedServices;
95 typedef std::set<mojo::Id> RegisteredViewIdSet;
96
97 void AddConnectedService(scoped_ptr<WindowManagerImpl> service);
98
99 struct PendingEmbed;
100 class WindowManagerInternalImpl;
101
102 mojo::ViewManager* view_manager() {
103 return root_ ? root_->view_manager() : nullptr;
104 }
105
106 bool SetCaptureImpl(mojo::View* view);
107 bool FocusWindowImpl(mojo::View* view);
108 bool ActivateWindowImpl(mojo::View* view);
109
110 ui::Accelerator ConvertEventToAccelerator(const ui::KeyEvent* event);
111
112 // Creates an ViewTarget for every view in the hierarchy beneath |view|,
113 // and adds to the registry so that it can be retrieved later via
114 // GetViewTargetForViewId().
115 // TODO(beng): perhaps View should have a property bag.
116 void RegisterSubtree(mojo::View* view);
117
118 // Recursively invokes Unregister() for |view| and all its descendants.
119 void UnregisterSubtree(mojo::View* view);
120
121 // Deletes the ViewTarget associated with the hierarchy beneath |id|,
122 // and removes from the registry.
123 void Unregister(mojo::View* view);
124
125 // Overridden from ViewManagerDelegate:
126 void OnEmbed(mojo::View* root,
127 mojo::InterfaceRequest<mojo::ServiceProvider> services,
128 mojo::ServiceProviderPtr exposed_services) override;
129 void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override;
130 bool OnPerformAction(mojo::View* view, const std::string& action) override;
131
132 // Overridden from ViewObserver:
133 void OnTreeChanged(const ViewObserver::TreeChangeParams& params) override;
134 void OnViewDestroying(mojo::View* view) override;
135
136 // Overridden from ui::EventHandler:
137 void OnEvent(ui::Event* event) override;
138
139 // Overridden from mojo::FocusControllerObserver:
140 void OnFocused(mojo::View* gained_focus) override;
141 void OnActivated(mojo::View* gained_active) override;
142
143 // Overridden from mojo::CaptureControllerObserver:
144 void OnCaptureChanged(mojo::View* gained_capture) override;
145
146 // Creates the connection to the ViewManager.
147 void LaunchViewManager(mojo::ApplicationImpl* app);
148
149 // InterfaceFactory<WindowManagerInternal>:
150 void Create(
151 mojo::ApplicationConnection* connection,
152 mojo::InterfaceRequest<mojo::WindowManagerInternal> request) override;
153
154 // InterfaceFactory<NativeViewportEventDispatcher>:
155 void Create(mojo::ApplicationConnection* connection,
156 mojo::InterfaceRequest<mojo::NativeViewportEventDispatcher>
157 request) override;
158
159 // WindowManagerInternal:
160 void CreateWindowManagerForViewManagerClient(
161 uint16_t connection_id,
162 mojo::ScopedMessagePipeHandle window_manager_pipe) override;
163 void SetViewManagerClient(
164 mojo::ScopedMessagePipeHandle view_manager_client_request) override;
165
166 mojo::ApplicationImpl* application_impl_;
167 mojo::ApplicationConnection* connection_;
168 scoped_ptr<WindowManagerController> window_manager_controller_;
169
170 ViewManagerDelegate* wrapped_view_manager_delegate_;
171 WindowManagerDelegate* window_manager_delegate_;
172
173 mojo::ViewManagerServicePtr view_manager_service_;
174 scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_;
175 mojo::View* root_;
176
177 scoped_ptr<FocusController> focus_controller_;
178 scoped_ptr<CaptureController> capture_controller_;
179
180 ui::AcceleratorManager accelerator_manager_;
181
182 ConnectedServices connected_services_;
183 RegisteredViewIdSet registered_view_id_set_;
184
185 mojo::WindowManagerInternalClientPtr window_manager_client_;
186
187 ScopedVector<PendingEmbed> pending_embeds_;
188
189 scoped_ptr<mojo::ViewManagerClient> view_manager_client_;
190
191 scoped_ptr<ViewEventDispatcher> view_event_dispatcher_;
192
193 scoped_ptr<mojo::Binding<WindowManagerInternal>> wm_internal_binding_;
194
195 DISALLOW_COPY_AND_ASSIGN(WindowManagerRoot);
196 };
197
198 } // namespace window_manager
199
200 #endif // SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_
OLDNEW
« no previous file with comments | « services/window_manager/window_manager_impl.cc ('k') | services/window_manager/window_manager_root.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698