| OLD | NEW |
| 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 COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_ | 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_ |
| 6 #define COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_ | 6 #define COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_ |
| 7 | 7 |
| 8 #include "components/mus/public/cpp/types.h" | 8 #include "components/mus/public/cpp/types.h" |
| 9 #include "components/mus/public/cpp/view.h" | 9 #include "components/mus/public/cpp/view.h" |
| 10 #include "components/mus/public/cpp/view_tree_connection.h" | 10 #include "components/mus/public/cpp/view_tree_connection.h" |
| 11 #include "components/mus/public/interfaces/view_tree.mojom.h" | 11 #include "components/mus/public/interfaces/view_tree.mojom.h" |
| 12 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | 12 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
| 13 | 13 |
| 14 namespace mojo { | 14 namespace mus { |
| 15 class ViewTreeConnection; | 15 class ViewTreeConnection; |
| 16 class ViewTreeDelegate; | 16 class ViewTreeDelegate; |
| 17 | 17 |
| 18 // Manages the connection with the View Manager service. | 18 // Manages the connection with the View Manager service. |
| 19 class ViewTreeClientImpl : public ViewTreeConnection, public ViewTreeClient { | 19 class ViewTreeClientImpl : public ViewTreeConnection, |
| 20 public mojo::ViewTreeClient { |
| 20 public: | 21 public: |
| 21 ViewTreeClientImpl(ViewTreeDelegate* delegate, | 22 ViewTreeClientImpl(ViewTreeDelegate* delegate, |
| 22 InterfaceRequest<ViewTreeClient> request); | 23 mojo::InterfaceRequest<mojo::ViewTreeClient> request); |
| 23 ~ViewTreeClientImpl() override; | 24 ~ViewTreeClientImpl() override; |
| 24 | 25 |
| 25 bool connected() const { return tree_; } | 26 bool connected() const { return tree_; } |
| 26 ConnectionSpecificId connection_id() const { return connection_id_; } | 27 ConnectionSpecificId connection_id() const { return connection_id_; } |
| 27 | 28 |
| 28 // API exposed to the view implementations that pushes local changes to the | 29 // API exposed to the view implementations that pushes local changes to the |
| 29 // service. | 30 // service. |
| 30 void DestroyView(Id view_id); | 31 void DestroyView(Id view_id); |
| 31 | 32 |
| 32 // These methods take TransportIds. For views owned by the current connection, | 33 // 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 // the connection id high word can be zero. In all cases, the TransportId 0x1 |
| 34 // refers to the root view. | 35 // refers to the root view. |
| 35 void AddChild(Id child_id, Id parent_id); | 36 void AddChild(Id child_id, Id parent_id); |
| 36 void RemoveChild(Id child_id, Id parent_id); | 37 void RemoveChild(Id child_id, Id parent_id); |
| 37 | 38 |
| 38 void Reorder(Id view_id, Id relative_view_id, OrderDirection direction); | 39 void Reorder(Id view_id, Id relative_view_id, mojo::OrderDirection direction); |
| 39 | 40 |
| 40 // Returns true if the specified view was created by this connection. | 41 // Returns true if the specified view was created by this connection. |
| 41 bool OwnsView(Id id) const; | 42 bool OwnsView(Id id) const; |
| 42 | 43 |
| 43 void SetBounds(Id view_id, const Rect& bounds); | 44 void SetBounds(Id view_id, const mojo::Rect& bounds); |
| 44 void SetFocus(Id view_id); | 45 void SetFocus(Id view_id); |
| 45 void SetVisible(Id view_id, bool visible); | 46 void SetVisible(Id view_id, bool visible); |
| 46 void SetProperty(Id view_id, | 47 void SetProperty(Id view_id, |
| 47 const std::string& name, | 48 const std::string& name, |
| 48 const std::vector<uint8_t>& data); | 49 const std::vector<uint8_t>& data); |
| 49 void SetViewTextInputState(Id view_id, TextInputStatePtr state); | 50 void SetViewTextInputState(Id view_id, mojo::TextInputStatePtr state); |
| 50 void SetImeVisibility(Id view_id, bool visible, TextInputStatePtr state); | 51 void SetImeVisibility(Id view_id, |
| 52 bool visible, |
| 53 mojo::TextInputStatePtr state); |
| 51 | 54 |
| 52 void Embed(Id view_id, | 55 void Embed(Id view_id, |
| 53 ViewTreeClientPtr client, | 56 mojo::ViewTreeClientPtr client, |
| 54 uint32_t policy_bitmask, | 57 uint32_t policy_bitmask, |
| 55 const ViewTree::EmbedCallback& callback); | 58 const mojo::ViewTree::EmbedCallback& callback); |
| 56 | 59 |
| 57 void RequestSurface(Id view_id, | 60 void RequestSurface(Id view_id, |
| 58 InterfaceRequest<Surface> surface, | 61 mojo::InterfaceRequest<mojo::Surface> surface, |
| 59 SurfaceClientPtr client); | 62 mojo::SurfaceClientPtr client); |
| 60 | 63 |
| 61 void set_change_acked_callback(const Callback<void(void)>& callback) { | 64 void set_change_acked_callback(const mojo::Callback<void(void)>& callback) { |
| 62 change_acked_callback_ = callback; | 65 change_acked_callback_ = callback; |
| 63 } | 66 } |
| 64 void ClearChangeAckedCallback() { change_acked_callback_.reset(); } | 67 void ClearChangeAckedCallback() { change_acked_callback_.reset(); } |
| 65 | 68 |
| 66 // Start/stop tracking views. While tracked, they can be retrieved via | 69 // Start/stop tracking views. While tracked, they can be retrieved via |
| 67 // ViewTreeConnection::GetViewById. | 70 // ViewTreeConnection::GetViewById. |
| 68 void AddView(View* view); | 71 void AddView(View* view); |
| 69 void RemoveView(Id view_id); | 72 void RemoveView(Id view_id); |
| 70 | 73 |
| 71 bool is_embed_root() const { return is_embed_root_; } | 74 bool is_embed_root() const { return is_embed_root_; } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 83 // Overridden from ViewTreeConnection: | 86 // Overridden from ViewTreeConnection: |
| 84 View* GetRoot() override; | 87 View* GetRoot() override; |
| 85 View* GetViewById(Id id) override; | 88 View* GetViewById(Id id) override; |
| 86 View* GetFocusedView() override; | 89 View* GetFocusedView() override; |
| 87 View* CreateView() override; | 90 View* CreateView() override; |
| 88 bool IsEmbedRoot() override; | 91 bool IsEmbedRoot() override; |
| 89 ConnectionSpecificId GetConnectionId() override; | 92 ConnectionSpecificId GetConnectionId() override; |
| 90 | 93 |
| 91 // Overridden from ViewTreeClient: | 94 // Overridden from ViewTreeClient: |
| 92 void OnEmbed(ConnectionSpecificId connection_id, | 95 void OnEmbed(ConnectionSpecificId connection_id, |
| 93 ViewDataPtr root, | 96 mojo::ViewDataPtr root, |
| 94 ViewTreePtr tree, | 97 mojo::ViewTreePtr tree, |
| 95 Id focused_view_id, | 98 Id focused_view_id, |
| 96 uint32_t access_policy) override; | 99 uint32_t access_policy) override; |
| 97 void OnEmbeddedAppDisconnected(Id view_id) override; | 100 void OnEmbeddedAppDisconnected(Id view_id) override; |
| 98 void OnUnembed() override; | 101 void OnUnembed() override; |
| 99 void OnViewBoundsChanged(Id view_id, | 102 void OnViewBoundsChanged(Id view_id, |
| 100 RectPtr old_bounds, | 103 mojo::RectPtr old_bounds, |
| 101 RectPtr new_bounds) override; | 104 mojo::RectPtr new_bounds) override; |
| 102 void OnViewViewportMetricsChanged(ViewportMetricsPtr old_metrics, | 105 void OnViewViewportMetricsChanged( |
| 103 ViewportMetricsPtr new_metrics) override; | 106 mojo::ViewportMetricsPtr old_metrics, |
| 107 mojo::ViewportMetricsPtr new_metrics) override; |
| 104 void OnViewHierarchyChanged(Id view_id, | 108 void OnViewHierarchyChanged(Id view_id, |
| 105 Id new_parent_id, | 109 Id new_parent_id, |
| 106 Id old_parent_id, | 110 Id old_parent_id, |
| 107 Array<ViewDataPtr> views) override; | 111 mojo::Array<mojo::ViewDataPtr> views) override; |
| 108 void OnViewReordered(Id view_id, | 112 void OnViewReordered(Id view_id, |
| 109 Id relative_view_id, | 113 Id relative_view_id, |
| 110 OrderDirection direction) override; | 114 mojo::OrderDirection direction) override; |
| 111 void OnViewDeleted(Id view_id) override; | 115 void OnViewDeleted(Id view_id) override; |
| 112 void OnViewVisibilityChanged(Id view_id, bool visible) override; | 116 void OnViewVisibilityChanged(Id view_id, bool visible) override; |
| 113 void OnViewDrawnStateChanged(Id view_id, bool drawn) override; | 117 void OnViewDrawnStateChanged(Id view_id, bool drawn) override; |
| 114 void OnViewSharedPropertyChanged(Id view_id, | 118 void OnViewSharedPropertyChanged(Id view_id, |
| 115 const String& name, | 119 const mojo::String& name, |
| 116 Array<uint8_t> new_data) override; | 120 mojo::Array<uint8_t> new_data) override; |
| 117 void OnViewInputEvent(Id view_id, | 121 void OnViewInputEvent(Id view_id, |
| 118 EventPtr event, | 122 mojo::EventPtr event, |
| 119 const Callback<void()>& callback) override; | 123 const mojo::Callback<void()>& callback) override; |
| 120 void OnViewFocused(Id focused_view_id) override; | 124 void OnViewFocused(Id focused_view_id) override; |
| 121 | 125 |
| 122 void RootDestroyed(View* root); | 126 void RootDestroyed(View* root); |
| 123 | 127 |
| 124 void OnActionCompleted(bool success); | 128 void OnActionCompleted(bool success); |
| 125 | 129 |
| 126 Callback<void(bool)> ActionCompletedCallback(); | 130 mojo::Callback<void(bool)> ActionCompletedCallback(); |
| 127 | 131 |
| 128 ConnectionSpecificId connection_id_; | 132 ConnectionSpecificId connection_id_; |
| 129 ConnectionSpecificId next_id_; | 133 ConnectionSpecificId next_id_; |
| 130 | 134 |
| 131 Callback<void(void)> change_acked_callback_; | 135 mojo::Callback<void(void)> change_acked_callback_; |
| 132 | 136 |
| 133 ViewTreeDelegate* delegate_; | 137 ViewTreeDelegate* delegate_; |
| 134 | 138 |
| 135 View* root_; | 139 View* root_; |
| 136 | 140 |
| 137 IdToViewMap views_; | 141 IdToViewMap views_; |
| 138 | 142 |
| 139 View* capture_view_; | 143 View* capture_view_; |
| 140 View* focused_view_; | 144 View* focused_view_; |
| 141 View* activated_view_; | 145 View* activated_view_; |
| 142 | 146 |
| 143 Binding<ViewTreeClient> binding_; | 147 mojo::Binding<ViewTreeClient> binding_; |
| 144 ViewTreePtr tree_; | 148 mojo::ViewTreePtr tree_; |
| 145 | 149 |
| 146 bool is_embed_root_; | 150 bool is_embed_root_; |
| 147 | 151 |
| 148 bool in_destructor_; | 152 bool in_destructor_; |
| 149 | 153 |
| 150 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewTreeClientImpl); | 154 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewTreeClientImpl); |
| 151 }; | 155 }; |
| 152 | 156 |
| 153 } // namespace mojo | 157 } // namespace mus |
| 154 | 158 |
| 155 #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_ | 159 #endif // COMPONENTS_MUS_PUBLIC_CPP_LIB_VIEW_TREE_CLIENT_IMPL_H_ |
| OLD | NEW |