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

Side by Side Diff: mojo/services/view_manager/public/cpp/lib/view_manager_client_impl.h

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

Powered by Google App Engine
This is Rietveld 408576698