cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / components / view_manager / public / cpp / lib / view_tree_client_impl.h
blob9edd333f21d174cdda7db2e1758331a5c08464a2
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.
5 #ifndef COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_
6 #define COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_
8 #include "components/view_manager/public/cpp/types.h"
9 #include "components/view_manager/public/cpp/view.h"
10 #include "components/view_manager/public/cpp/view_tree_connection.h"
11 #include "components/view_manager/public/interfaces/view_tree.mojom.h"
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
14 namespace mojo {
15 class ViewTreeConnection;
16 class ViewTreeDelegate;
18 // Manages the connection with the View Manager service.
19 class ViewTreeClientImpl : public ViewTreeConnection, public ViewTreeClient {
20 public:
21 ViewTreeClientImpl(ViewTreeDelegate* delegate,
22 InterfaceRequest<ViewTreeClient> request);
23 ~ViewTreeClientImpl() override;
25 bool connected() const { return tree_; }
26 ConnectionSpecificId connection_id() const { return connection_id_; }
28 // API exposed to the view implementations that pushes local changes to the
29 // service.
30 void DestroyView(Id view_id);
32 // These methods take TransportIds. For views owned by the current connection,
33 // the connection id high word can be zero. In all cases, the TransportId 0x1
34 // refers to the root view.
35 void AddChild(Id child_id, Id parent_id);
36 void RemoveChild(Id child_id, Id parent_id);
38 void Reorder(Id view_id, Id relative_view_id, OrderDirection direction);
40 // Returns true if the specified view was created by this connection.
41 bool OwnsView(Id id) const;
43 void SetBounds(Id view_id, const Rect& bounds);
44 void SetFocus(Id view_id);
45 void SetVisible(Id view_id, bool visible);
46 void SetProperty(Id view_id,
47 const std::string& name,
48 const std::vector<uint8_t>& data);
49 void SetViewTextInputState(Id view_id, TextInputStatePtr state);
50 void SetImeVisibility(Id view_id, bool visible, TextInputStatePtr state);
51 void SetAccessPolicy(Id view_id, uint32_t access_policy);
53 void Embed(Id view_id, ViewTreeClientPtr client);
55 void RequestSurface(Id view_id,
56 InterfaceRequest<Surface> surface,
57 SurfaceClientPtr client);
59 void set_change_acked_callback(const Callback<void(void)>& callback) {
60 change_acked_callback_ = callback;
62 void ClearChangeAckedCallback() { change_acked_callback_.reset(); }
64 // Start/stop tracking views. While tracked, they can be retrieved via
65 // ViewTreeConnection::GetViewById.
66 void AddView(View* view);
67 void RemoveView(Id view_id);
69 bool is_embed_root() const { return is_embed_root_; }
71 // Called after the root view's observers have been notified of destruction
72 // (as the last step of ~View). This ordering ensures that the View Manager
73 // is torn down after the root.
74 void OnRootDestroyed(View* root);
76 private:
77 typedef std::map<Id, View*> IdToViewMap;
79 Id CreateViewOnServer();
81 // Overridden from ViewTreeConnection:
82 View* GetRoot() override;
83 View* GetViewById(Id id) override;
84 View* GetFocusedView() override;
85 View* CreateView() override;
86 bool IsEmbedRoot() override;
88 // Overridden from ViewTreeClient:
89 void OnEmbed(ConnectionSpecificId connection_id,
90 ViewDataPtr root,
91 ViewTreePtr tree,
92 Id focused_view_id,
93 uint32_t access_policy) override;
94 void OnEmbeddedAppDisconnected(Id view_id) override;
95 void OnUnembed() override;
96 void OnViewBoundsChanged(Id view_id,
97 RectPtr old_bounds,
98 RectPtr new_bounds) override;
99 void OnViewViewportMetricsChanged(ViewportMetricsPtr old_metrics,
100 ViewportMetricsPtr new_metrics) override;
101 void OnViewHierarchyChanged(Id view_id,
102 Id new_parent_id,
103 Id old_parent_id,
104 Array<ViewDataPtr> views) override;
105 void OnViewReordered(Id view_id,
106 Id relative_view_id,
107 OrderDirection direction) override;
108 void OnViewDeleted(Id view_id) override;
109 void OnViewVisibilityChanged(Id view_id, bool visible) override;
110 void OnViewDrawnStateChanged(Id view_id, bool drawn) override;
111 void OnViewSharedPropertyChanged(Id view_id,
112 const String& name,
113 Array<uint8_t> new_data) override;
114 void OnViewInputEvent(Id view_id,
115 EventPtr event,
116 const Callback<void()>& callback) override;
117 void OnViewFocused(Id focused_view_id) override;
119 void RootDestroyed(View* root);
121 void OnActionCompleted(bool success);
123 Callback<void(bool)> ActionCompletedCallback();
125 ConnectionSpecificId connection_id_;
126 ConnectionSpecificId next_id_;
128 Callback<void(void)> change_acked_callback_;
130 ViewTreeDelegate* delegate_;
132 View* root_;
134 IdToViewMap views_;
136 View* capture_view_;
137 View* focused_view_;
138 View* activated_view_;
140 Binding<ViewTreeClient> binding_;
141 ViewTreePtr tree_;
143 bool is_embed_root_;
145 bool in_destructor_;
147 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewTreeClientImpl);
150 } // namespace mojo
152 #endif // COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_