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

Side by Side Diff: mojo/services/view_manager/cpp/lib/view_manager_client_impl.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, 11 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 MOJO_SERVICES_VIEW_MANAGER_CPP_LIB_VIEW_MANAGER_CLIENT_IMPL_H_
6 #define MOJO_SERVICES_VIEW_MANAGER_CPP_LIB_VIEW_MANAGER_CLIENT_IMPL_H_
7
8 #include "mojo/public/cpp/bindings/binding.h"
9 #include "view_manager/cpp/types.h"
10 #include "view_manager/cpp/view.h"
11 #include "view_manager/cpp/view_manager.h"
12 #include "view_manager/interfaces/view_manager.mojom.h"
13 #include "window_manager/interfaces/window_manager.mojom.h"
14
15 namespace mojo {
16 class Shell;
17 class ViewManager;
18 class ViewManagerDelegate;
19 class ViewManagerTransaction;
20
21 // Manages the connection with the View Manager service.
22 class ViewManagerClientImpl : public ViewManager,
23 public ViewManagerClient,
24 public WindowManagerObserver {
25 public:
26 ViewManagerClientImpl(ViewManagerDelegate* delegate,
27 Shell* shell,
28 InterfaceRequest<ViewManagerClient> request,
29 bool delete_on_error);
30 ~ViewManagerClientImpl() override;
31
32 bool connected() const { return !!service_; }
33 ConnectionSpecificId connection_id() const { return connection_id_; }
34
35 // API exposed to the view implementations that pushes local changes to the
36 // service.
37 void DestroyView(Id view_id);
38
39 // These methods take TransportIds. For views owned by the current connection,
40 // the connection id high word can be zero. In all cases, the TransportId 0x1
41 // refers to the root view.
42 void AddChild(Id child_id, Id parent_id);
43 void RemoveChild(Id child_id, Id parent_id);
44
45 void Reorder(Id view_id, Id relative_view_id, OrderDirection direction);
46
47 // Returns true if the specified view was created by this connection.
48 bool OwnsView(Id id) const;
49
50 void SetBounds(Id view_id, const Rect& bounds);
51 void SetSurfaceId(Id view_id, SurfaceIdPtr surface_id);
52 void SetFocus(Id view_id);
53 void SetVisible(Id view_id, bool visible);
54 void SetProperty(Id view_id,
55 const std::string& name,
56 const std::vector<uint8_t>& data);
57
58 void Embed(const String& url, Id view_id);
59 void Embed(const String& url,
60 Id view_id,
61 InterfaceRequest<ServiceProvider> services,
62 ServiceProviderPtr exposed_services);
63 void Embed(Id view_id, ViewManagerClientPtr client);
64
65 void set_change_acked_callback(const Callback<void(void)>& callback) {
66 change_acked_callback_ = callback;
67 }
68 void ClearChangeAckedCallback() { change_acked_callback_.reset(); }
69
70 // Start/stop tracking views. While tracked, they can be retrieved via
71 // ViewManager::GetViewById.
72 void AddView(View* view);
73 void RemoveView(Id view_id);
74
75 void SetViewManagerService(ViewManagerServicePtr service);
76
77 private:
78 friend class RootObserver;
79
80 typedef std::map<Id, View*> IdToViewMap;
81
82 Id CreateViewOnServer();
83
84 // Overridden from ViewManager:
85 const std::string& GetEmbedderURL() const override;
86 View* GetRoot() override;
87 View* GetViewById(Id id) override;
88 View* GetFocusedView() override;
89 View* CreateView() override;
90
91 // Overridden from ViewManagerClient:
92 void OnEmbed(ConnectionSpecificId connection_id,
93 const String& creator_url,
94 ViewDataPtr root,
95 ViewManagerServicePtr view_manager_service,
96 InterfaceRequest<ServiceProvider> services,
97 ServiceProviderPtr exposed_services,
98 ScopedMessagePipeHandle window_manager_pipe) override;
99 void OnEmbeddedAppDisconnected(Id view_id) override;
100 void OnViewBoundsChanged(Id view_id,
101 RectPtr old_bounds,
102 RectPtr new_bounds) override;
103 void OnViewViewportMetricsChanged(ViewportMetricsPtr old_metrics,
104 ViewportMetricsPtr new_metrics) override;
105 void OnViewHierarchyChanged(Id view_id,
106 Id new_parent_id,
107 Id old_parent_id,
108 Array<ViewDataPtr> views) override;
109 void OnViewReordered(Id view_id,
110 Id relative_view_id,
111 OrderDirection direction) override;
112 void OnViewDeleted(Id view_id) override;
113 void OnViewVisibilityChanged(Id view_id, bool visible) override;
114 void OnViewDrawnStateChanged(Id view_id, bool drawn) override;
115 void OnViewSharedPropertyChanged(Id view_id,
116 const String& name,
117 Array<uint8_t> new_data) override;
118 void OnViewInputEvent(Id view_id,
119 EventPtr event,
120 const Callback<void()>& callback) override;
121 void OnPerformAction(Id view_id,
122 const String& name,
123 const Callback<void(bool)>& callback) override;
124
125 // Overridden from WindowManagerObserver:
126 void OnCaptureChanged(Id capture_view_id) override;
127 void OnFocusChanged(Id focused_view_id) override;
128 void OnActiveWindowChanged(Id focused_view_id) override;
129
130 void RootDestroyed(View* root);
131
132 void OnActionCompleted(bool success);
133
134 Callback<void(bool)> ActionCompletedCallback();
135
136 ConnectionSpecificId connection_id_;
137 ConnectionSpecificId next_id_;
138
139 std::string creator_url_;
140
141 Callback<void(void)> change_acked_callback_;
142
143 ViewManagerDelegate* delegate_;
144
145 View* root_;
146
147 IdToViewMap views_;
148
149 View* capture_view_;
150 View* focused_view_;
151 View* activated_view_;
152
153 WindowManagerPtr window_manager_;
154 Binding<WindowManagerObserver> wm_observer_binding_;
155
156 Binding<ViewManagerClient> binding_;
157 ViewManagerServicePtr service_;
158
159 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerClientImpl);
160 };
161
162 } // namespace mojo
163
164 #endif // MOJO_SERVICES_VIEW_MANAGER_CPP_LIB_VIEW_MANAGER_CLIENT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698