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

Side by Side Diff: mojo/services/window_manager/window_manager_app.h

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 years, 8 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 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.
4
5 #ifndef SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_
6 #define SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_
7
8 #include <set>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "mojo/public/cpp/application/application_delegate.h"
13 #include "mojo/public/cpp/application/interface_factory_impl.h"
14 #include "mojo/public/cpp/bindings/binding.h"
15 #include "mojo/public/cpp/bindings/string.h"
16 #include "mojo/services/window_manager/capture_controller_observer.h"
17 #include "mojo/services/window_manager/focus_controller_observer.h"
18 #include "mojo/services/window_manager/native_viewport_event_dispatcher_impl.h"
19 #include "mojo/services/window_manager/view_target.h"
20 #include "mojo/services/window_manager/window_manager_impl.h"
21 #include "third_party/mojo_services/src/view_manager/public/cpp/types.h"
22 #include "third_party/mojo_services/src/view_manager/public/cpp/view_manager_cli ent_factory.h"
23 #include "third_party/mojo_services/src/view_manager/public/cpp/view_manager_del egate.h"
24 #include "third_party/mojo_services/src/view_manager/public/cpp/view_observer.h"
25 #include "third_party/mojo_services/src/window_manager/public/interfaces/window_ manager_internal.mojom.h"
26 #include "ui/base/accelerators/accelerator_manager.h"
27 #include "ui/events/event_handler.h"
28
29 namespace gfx {
30 class Size;
31 }
32
33 namespace window_manager {
34
35 class CaptureController;
36 class FocusController;
37 class FocusRules;
38 class ViewEventDispatcher;
39 class WindowManagerDelegate;
40 class WindowManagerImpl;
41
42 // Implements core window manager functionality that could conceivably be shared
43 // across multiple window managers implementing superficially different user
44 // experiences. Establishes communication with the view manager.
45 // A window manager wishing to use this core should create and own an instance
46 // of this object. They may implement the associated ViewManager/WindowManager
47 // delegate interfaces exposed by the view manager, this object provides the
48 // canonical implementation of said interfaces but will call out to the wrapped
49 // instances.
50 class WindowManagerApp
51 : public mojo::ApplicationDelegate,
52 public mojo::ViewManagerDelegate,
53 public mojo::ViewObserver,
54 public ui::EventHandler,
55 public FocusControllerObserver,
56 public CaptureControllerObserver,
57 public mojo::InterfaceFactory<mojo::WindowManager>,
58 public mojo::InterfaceFactory<mojo::WindowManagerInternal>,
59 public mojo::InterfaceFactory<mojo::NativeViewportEventDispatcher>,
60 public mojo::WindowManagerInternal {
61 public:
62 WindowManagerApp(ViewManagerDelegate* view_manager_delegate,
63 WindowManagerDelegate* window_manager_delegate);
64 ~WindowManagerApp() override;
65
66 ViewEventDispatcher* event_dispatcher() {
67 return view_event_dispatcher_.get();
68 }
69
70 // Register/deregister new connections to the window manager service.
71 void AddConnection(WindowManagerImpl* connection);
72 void RemoveConnection(WindowManagerImpl* connection);
73
74 // These are canonical implementations of the window manager API methods.
75 bool SetCapture(mojo::Id view);
76 bool FocusWindow(mojo::Id view);
77 bool ActivateWindow(mojo::Id view);
78
79 void DispatchInputEventToView(mojo::View* view, mojo::EventPtr event);
80 void SetViewportSize(const gfx::Size& size);
81
82 bool IsReady() const;
83
84 FocusController* focus_controller() { return focus_controller_.get(); }
85 CaptureController* capture_controller() { return capture_controller_.get(); }
86
87 void InitFocus(scoped_ptr<FocusRules> rules);
88
89 ui::AcceleratorManager* accelerator_manager() {
90 return &accelerator_manager_;
91 }
92
93 // WindowManagerImpl::Embed() forwards to this. If connected to ViewManager
94 // then forwards to delegate, otherwise waits for connection to establish then
95 // forwards.
96 void Embed(const mojo::String& url,
97 mojo::InterfaceRequest<mojo::ServiceProvider> services,
98 mojo::ServiceProviderPtr exposed_services);
99
100 // Overridden from ApplicationDelegate:
101 void Initialize(mojo::ApplicationImpl* impl) override;
102 bool ConfigureIncomingConnection(
103 mojo::ApplicationConnection* connection) override;
104
105 private:
106 // TODO(sky): rename this. Connections is ambiguous.
107 typedef std::set<WindowManagerImpl*> Connections;
108 typedef std::set<mojo::Id> RegisteredViewIdSet;
109
110 struct PendingEmbed;
111 class WindowManagerInternalImpl;
112
113 mojo::ViewManager* view_manager() {
114 return root_ ? root_->view_manager() : nullptr;
115 }
116
117 bool SetCaptureImpl(mojo::View* view);
118 bool FocusWindowImpl(mojo::View* view);
119 bool ActivateWindowImpl(mojo::View* view);
120
121 ui::Accelerator ConvertEventToAccelerator(const ui::KeyEvent* event);
122
123 // Creates an ViewTarget for every view in the hierarchy beneath |view|,
124 // and adds to the registry so that it can be retrieved later via
125 // GetViewTargetForViewId().
126 // TODO(beng): perhaps View should have a property bag.
127 void RegisterSubtree(mojo::View* view);
128
129 // Recursively invokes Unregister() for |view| and all its descendants.
130 void UnregisterSubtree(mojo::View* view);
131
132 // Deletes the ViewTarget associated with the hierarchy beneath |id|,
133 // and removes from the registry.
134 void Unregister(mojo::View* view);
135
136 // Overridden from ViewManagerDelegate:
137 void OnEmbed(mojo::View* root,
138 mojo::InterfaceRequest<mojo::ServiceProvider> services,
139 mojo::ServiceProviderPtr exposed_services) override;
140 void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override;
141 bool OnPerformAction(mojo::View* view, const std::string& action) override;
142
143 // Overridden from ViewObserver:
144 void OnTreeChanged(const ViewObserver::TreeChangeParams& params) override;
145 void OnViewDestroying(mojo::View* view) override;
146
147 // Overridden from ui::EventHandler:
148 void OnEvent(ui::Event* event) override;
149
150 // Overridden from mojo::FocusControllerObserver:
151 void OnFocused(mojo::View* gained_focus) override;
152 void OnActivated(mojo::View* gained_active) override;
153
154 // Overridden from mojo::CaptureControllerObserver:
155 void OnCaptureChanged(mojo::View* gained_capture) override;
156
157 // Creates the connection to the ViewManager.
158 void LaunchViewManager(mojo::ApplicationImpl* app);
159
160 // InterfaceFactory<WindowManagerInternal>:
161 void Create(
162 mojo::ApplicationConnection* connection,
163 mojo::InterfaceRequest<mojo::WindowManagerInternal> request) override;
164
165 // InterfaceFactory<WindowManager>:
166 void Create(mojo::ApplicationConnection* connection,
167 mojo::InterfaceRequest<mojo::WindowManager> request) override;
168
169 // InterfaceFactory<NativeViewportEventDispatcher>:
170 void Create(mojo::ApplicationConnection* connection,
171 mojo::InterfaceRequest<mojo::NativeViewportEventDispatcher>
172 request) override;
173
174 // WindowManagerInternal:
175 void CreateWindowManagerForViewManagerClient(
176 uint16_t connection_id,
177 mojo::ScopedMessagePipeHandle window_manager_pipe) override;
178 void SetViewManagerClient(
179 mojo::ScopedMessagePipeHandle view_manager_client_request) override;
180
181 mojo::Shell* shell_;
182
183 ViewManagerDelegate* wrapped_view_manager_delegate_;
184 WindowManagerDelegate* window_manager_delegate_;
185
186 mojo::ViewManagerServicePtr view_manager_service_;
187 scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_;
188 mojo::View* root_;
189
190 scoped_ptr<FocusController> focus_controller_;
191 scoped_ptr<CaptureController> capture_controller_;
192
193 ui::AcceleratorManager accelerator_manager_;
194
195 Connections connections_;
196 RegisteredViewIdSet registered_view_id_set_;
197
198 mojo::WindowManagerInternalClientPtr window_manager_client_;
199
200 ScopedVector<PendingEmbed> pending_embeds_;
201
202 scoped_ptr<mojo::ViewManagerClient> view_manager_client_;
203
204 scoped_ptr<ViewEventDispatcher> view_event_dispatcher_;
205
206 scoped_ptr<mojo::Binding<WindowManagerInternal>> wm_internal_binding_;
207
208 DISALLOW_COPY_AND_ASSIGN(WindowManagerApp);
209 };
210
211 } // namespace window_manager
212
213 #endif // SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_
OLDNEW
« no previous file with comments | « mojo/services/window_manager/window_manager_api_unittest.cc ('k') | mojo/services/window_manager/window_manager_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698