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

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

Issue 636363002: Splits window manager like methods into ViewManagerServiceDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge 2 trunk Created 6 years, 2 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
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/window_manager_service2_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 WindowManagerServiceImpl; 42 class WindowManagerClient;
43 class WindowTreeHostMojo; 43 class WindowManagerDelegate;
44 class WindowManagerService2Impl;
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(WindowManagerService2Impl* connection);
74 void RemoveConnection(WindowManagerServiceImpl* connection); 74 void RemoveConnection(WindowManagerService2Impl* 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_window_manager_client(WindowManagerClient* client) {
94 window_manager_client_ = client;
95 }
96
89 // Overridden from ApplicationDelegate: 97 // Overridden from ApplicationDelegate:
90 virtual void Initialize(ApplicationImpl* impl) override; 98 virtual void Initialize(ApplicationImpl* impl) override;
91 virtual bool ConfigureIncomingConnection( 99 virtual bool ConfigureIncomingConnection(
92 ApplicationConnection* connection) override; 100 ApplicationConnection* connection) override;
93 101
94 private: 102 private:
95 typedef std::set<WindowManagerServiceImpl*> Connections; 103 typedef std::set<WindowManagerService2Impl*> Connections;
96 typedef std::map<Id, aura::Window*> ViewIdToWindowMap; 104 typedef std::map<Id, aura::Window*> ViewIdToWindowMap;
97 105
98 // Overridden from ViewManagerDelegate: 106 // Overridden from ViewManagerDelegate:
99 virtual void OnEmbed(ViewManager* view_manager, 107 virtual void OnEmbed(ViewManager* view_manager,
100 View* root, 108 View* root,
101 ServiceProviderImpl* exported_services, 109 ServiceProviderImpl* exported_services,
102 scoped_ptr<ServiceProvider> imported_services) override; 110 scoped_ptr<ServiceProvider> imported_services) override;
103 virtual void OnViewManagerDisconnected(ViewManager* view_manager) override; 111 virtual void OnViewManagerDisconnected(ViewManager* view_manager) override;
104 112
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: 113 // Overridden from ViewObserver:
112 virtual void OnTreeChanged( 114 virtual void OnTreeChanged(
113 const ViewObserver::TreeChangeParams& params) override; 115 const ViewObserver::TreeChangeParams& params) override;
114 virtual void OnViewDestroying(View* view) override; 116 virtual void OnViewDestroying(View* view) override;
115 virtual void OnViewBoundsChanged(View* view, 117 virtual void OnViewBoundsChanged(View* view,
116 const gfx::Rect& old_bounds, 118 const gfx::Rect& old_bounds,
117 const gfx::Rect& new_bounds) override; 119 const gfx::Rect& new_bounds) override;
118 120
119 // Overridden from ui::EventHandler: 121 // Overridden from ui::EventHandler:
120 virtual void OnEvent(ui::Event* event) override; 122 virtual void OnEvent(ui::Event* event) override;
(...skipping 12 matching lines...) Expand all
133 // TODO(beng): perhaps View should have a property bag. 135 // TODO(beng): perhaps View should have a property bag.
134 void RegisterSubtree(View* view, aura::Window* parent); 136 void RegisterSubtree(View* view, aura::Window* parent);
135 // Recursively invokes Unregister() for |view| and all its descendants. 137 // Recursively invokes Unregister() for |view| and all its descendants.
136 void UnregisterSubtree(View* view); 138 void UnregisterSubtree(View* view);
137 // Deletes the aura::Windows associated with the hierarchy beneath |id|, 139 // Deletes the aura::Windows associated with the hierarchy beneath |id|,
138 // and removes from the registry. 140 // and removes from the registry.
139 void Unregister(View* view); 141 void Unregister(View* view);
140 142
141 Shell* shell_; 143 Shell* shell_;
142 144
145 InterfaceFactoryImplWithContext<WindowManagerService2Impl, WindowManagerApp>
146 window_manager_service2_factory_;
147
143 InterfaceFactoryImplWithContext<WindowManagerServiceImpl, WindowManagerApp> 148 InterfaceFactoryImplWithContext<WindowManagerServiceImpl, WindowManagerApp>
144 window_manager_service_factory_; 149 window_manager_service_factory_;
145 150
146 ViewManagerDelegate* wrapped_view_manager_delegate_; 151 ViewManagerDelegate* wrapped_view_manager_delegate_;
147 WindowManagerDelegate* wrapped_window_manager_delegate_; 152 WindowManagerDelegate* window_manager_delegate_;
148 153
149 ViewManager* view_manager_; 154 ViewManager* view_manager_;
150 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; 155 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_;
151 View* root_; 156 View* root_;
152 157
153 scoped_ptr<AuraInit> aura_init_; 158 scoped_ptr<AuraInit> aura_init_;
154 scoped_ptr<WindowTreeHostMojo> window_tree_host_; 159 scoped_ptr<WindowTreeHostMojo> window_tree_host_;
155 160
156 scoped_ptr<wm::ScopedCaptureClient> capture_client_; 161 scoped_ptr<wm::ScopedCaptureClient> capture_client_;
157 scoped_ptr<aura::client::FocusClient> focus_client_; 162 scoped_ptr<aura::client::FocusClient> focus_client_;
158 aura::client::ActivationClient* activation_client_; 163 aura::client::ActivationClient* activation_client_;
159 164
160 Connections connections_; 165 Connections connections_;
161 ViewIdToWindowMap view_id_to_window_map_; 166 ViewIdToWindowMap view_id_to_window_map_;
162 167
163 scoped_ptr<DummyDelegate> dummy_delegate_; 168 scoped_ptr<DummyDelegate> dummy_delegate_;
164 169
170 WindowManagerClient* window_manager_client_;
171
165 DISALLOW_COPY_AND_ASSIGN(WindowManagerApp); 172 DISALLOW_COPY_AND_ASSIGN(WindowManagerApp);
166 }; 173 };
167 174
168 } // namespace mojo 175 } // namespace mojo
169 176
170 #endif // MOJO_SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_ 177 #endif // MOJO_SERVICES_WINDOW_MANAGER_WINDOW_MANAGER_APP_H_
OLDNEW
« no previous file with comments | « mojo/services/window_manager/main.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