| 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_WS_CONNECTION_MANAGER_H_ | 5 #ifndef COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ |
| 6 #define COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ | 6 #define COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 14 #include "components/mus/public/interfaces/view_tree.mojom.h" | 14 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 15 #include "components/mus/public/interfaces/view_tree_host.mojom.h" | 15 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
| 16 #include "components/mus/surfaces/surfaces_state.h" | 16 #include "components/mus/surfaces/surfaces_state.h" |
| 17 #include "components/mus/ws/focus_controller_delegate.h" | 17 #include "components/mus/ws/focus_controller_delegate.h" |
| 18 #include "components/mus/ws/ids.h" | 18 #include "components/mus/ws/ids.h" |
| 19 #include "components/mus/ws/server_view_delegate.h" | 19 #include "components/mus/ws/server_view_delegate.h" |
| 20 #include "components/mus/ws/server_view_observer.h" | 20 #include "components/mus/ws/server_view_observer.h" |
| 21 #include "components/mus/ws/view_tree_host_impl.h" | 21 #include "components/mus/ws/view_tree_host_impl.h" |
| 22 #include "mojo/converters/surfaces/custom_surface_converter.h" | 22 #include "mojo/converters/surfaces/custom_surface_converter.h" |
| 23 #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h" | 23 #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h" |
| 24 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | 24 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
| 25 | 25 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 // See description of ViewTree::Embed() for details. This assumes | 95 // See description of ViewTree::Embed() for details. This assumes |
| 96 // |transport_view_id| is valid. | 96 // |transport_view_id| is valid. |
| 97 void EmbedAtView(ConnectionSpecificId creator_id, | 97 void EmbedAtView(ConnectionSpecificId creator_id, |
| 98 const ViewId& view_id, | 98 const ViewId& view_id, |
| 99 uint32_t policy_bitmask, | 99 uint32_t policy_bitmask, |
| 100 mojo::URLRequestPtr request); | 100 mojo::URLRequestPtr request); |
| 101 ViewTreeImpl* EmbedAtView(ConnectionSpecificId creator_id, | 101 ViewTreeImpl* EmbedAtView(ConnectionSpecificId creator_id, |
| 102 const ViewId& view_id, | 102 const ViewId& view_id, |
| 103 uint32_t policy_bitmask, | 103 uint32_t policy_bitmask, |
| 104 mojo::ViewTreeClientPtr client); | 104 mojom::WindowTreeClientPtr client); |
| 105 | 105 |
| 106 // Returns the connection by id. | 106 // Returns the connection by id. |
| 107 ViewTreeImpl* GetConnection(ConnectionSpecificId connection_id); | 107 ViewTreeImpl* GetConnection(ConnectionSpecificId connection_id); |
| 108 | 108 |
| 109 // Returns the View identified by |id|. | 109 // Returns the View identified by |id|. |
| 110 ServerView* GetView(const ViewId& id); | 110 ServerView* GetView(const ViewId& id); |
| 111 | 111 |
| 112 // Returns whether |view| is a descendant of some root view but not itself a | 112 // Returns whether |view| is a descendant of some root view but not itself a |
| 113 // root view. | 113 // root view. |
| 114 bool IsViewAttachedToRoot(const ServerView* view) const; | 114 bool IsViewAttachedToRoot(const ServerView* view) const; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 126 void OnDisplayClosed(); | 126 void OnDisplayClosed(); |
| 127 | 127 |
| 128 // Invoked when a connection messages a client about the change. This is used | 128 // Invoked when a connection messages a client about the change. This is used |
| 129 // to avoid sending ServerChangeIdAdvanced() unnecessarily. | 129 // to avoid sending ServerChangeIdAdvanced() unnecessarily. |
| 130 void OnConnectionMessagedClient(ConnectionSpecificId id); | 130 void OnConnectionMessagedClient(ConnectionSpecificId id); |
| 131 | 131 |
| 132 // Returns true if OnConnectionMessagedClient() was invoked for id. | 132 // Returns true if OnConnectionMessagedClient() was invoked for id. |
| 133 bool DidConnectionMessageClient(ConnectionSpecificId id) const; | 133 bool DidConnectionMessageClient(ConnectionSpecificId id) const; |
| 134 | 134 |
| 135 // Returns the metrics of the viewport where the provided |view| is displayed. | 135 // Returns the metrics of the viewport where the provided |view| is displayed. |
| 136 mojo::ViewportMetricsPtr GetViewportMetricsForView(const ServerView* view); | 136 mojom::ViewportMetricsPtr GetViewportMetricsForView(const ServerView* view); |
| 137 | 137 |
| 138 // Returns the ViewTreeImpl that has |id| as a root. | 138 // Returns the ViewTreeImpl that has |id| as a root. |
| 139 ViewTreeImpl* GetConnectionWithRoot(const ViewId& id) { | 139 ViewTreeImpl* GetConnectionWithRoot(const ViewId& id) { |
| 140 return const_cast<ViewTreeImpl*>( | 140 return const_cast<ViewTreeImpl*>( |
| 141 const_cast<const ConnectionManager*>(this)->GetConnectionWithRoot(id)); | 141 const_cast<const ConnectionManager*>(this)->GetConnectionWithRoot(id)); |
| 142 } | 142 } |
| 143 const ViewTreeImpl* GetConnectionWithRoot(const ViewId& id) const; | 143 const ViewTreeImpl* GetConnectionWithRoot(const ViewId& id) const; |
| 144 | 144 |
| 145 ViewTreeHostImpl* GetViewTreeHostByView(const ServerView* view); | 145 ViewTreeHostImpl* GetWindowTreeHostByView(const ServerView* view); |
| 146 const ViewTreeHostImpl* GetViewTreeHostByView(const ServerView* view) const; | 146 const ViewTreeHostImpl* GetWindowTreeHostByView(const ServerView* view) const; |
| 147 | 147 |
| 148 // Returns the first ancestor of |service| that is marked as an embed root. | 148 // Returns the first ancestor of |service| that is marked as an embed root. |
| 149 ViewTreeImpl* GetEmbedRoot(ViewTreeImpl* service); | 149 ViewTreeImpl* GetEmbedRoot(ViewTreeImpl* service); |
| 150 | 150 |
| 151 // ViewTreeHost implementation helper; see mojom for details. | 151 // ViewTreeHost implementation helper; see mojom for details. |
| 152 bool CloneAndAnimate(const ViewId& view_id); | 152 bool CloneAndAnimate(const ViewId& view_id); |
| 153 | 153 |
| 154 // These functions trivially delegate to all ViewTreeImpls, which in | 154 // These functions trivially delegate to all ViewTreeImpls, which in |
| 155 // term notify their clients. | 155 // term notify their clients. |
| 156 void ProcessViewDestroyed(ServerView* view); | 156 void ProcessViewDestroyed(ServerView* view); |
| 157 void ProcessViewBoundsChanged(const ServerView* view, | 157 void ProcessViewBoundsChanged(const ServerView* view, |
| 158 const gfx::Rect& old_bounds, | 158 const gfx::Rect& old_bounds, |
| 159 const gfx::Rect& new_bounds); | 159 const gfx::Rect& new_bounds); |
| 160 void ProcessClientAreaChanged(const ServerView* window, | 160 void ProcessClientAreaChanged(const ServerView* window, |
| 161 const gfx::Rect& old_client_area, | 161 const gfx::Rect& old_client_area, |
| 162 const gfx::Rect& new_client_area); | 162 const gfx::Rect& new_client_area); |
| 163 void ProcessViewportMetricsChanged(const mojo::ViewportMetrics& old_metrics, | 163 void ProcessViewportMetricsChanged(const mojom::ViewportMetrics& old_metrics, |
| 164 const mojo::ViewportMetrics& new_metrics); | 164 const mojom::ViewportMetrics& new_metrics); |
| 165 void ProcessWillChangeViewHierarchy(const ServerView* view, | 165 void ProcessWillChangeViewHierarchy(const ServerView* view, |
| 166 const ServerView* new_parent, | 166 const ServerView* new_parent, |
| 167 const ServerView* old_parent); | 167 const ServerView* old_parent); |
| 168 void ProcessViewHierarchyChanged(const ServerView* view, | 168 void ProcessViewHierarchyChanged(const ServerView* view, |
| 169 const ServerView* new_parent, | 169 const ServerView* new_parent, |
| 170 const ServerView* old_parent); | 170 const ServerView* old_parent); |
| 171 void ProcessViewReorder(const ServerView* view, | 171 void ProcessViewReorder(const ServerView* view, |
| 172 const ServerView* relative_view, | 172 const ServerView* relative_view, |
| 173 const mojo::OrderDirection direction); | 173 const mojom::OrderDirection direction); |
| 174 void ProcessViewDeleted(const ViewId& view); | 174 void ProcessViewDeleted(const ViewId& view); |
| 175 | 175 |
| 176 private: | 176 private: |
| 177 using ConnectionMap = std::map<ConnectionSpecificId, ClientConnection*>; | 177 using ConnectionMap = std::map<ConnectionSpecificId, ClientConnection*>; |
| 178 using HostConnectionMap = | 178 using HostConnectionMap = |
| 179 std::map<ViewTreeHostImpl*, ViewTreeHostConnection*>; | 179 std::map<ViewTreeHostImpl*, ViewTreeHostConnection*>; |
| 180 | 180 |
| 181 // Invoked when a connection is about to make a change. Subsequently followed | 181 // Invoked when a connection is about to make a change. Subsequently followed |
| 182 // by FinishChange() once the change is done. | 182 // by FinishChange() once the change is done. |
| 183 // | 183 // |
| (...skipping 27 matching lines...) Expand all Loading... |
| 211 ServerView* new_parent, | 211 ServerView* new_parent, |
| 212 ServerView* old_parent) override; | 212 ServerView* old_parent) override; |
| 213 void OnViewBoundsChanged(ServerView* view, | 213 void OnViewBoundsChanged(ServerView* view, |
| 214 const gfx::Rect& old_bounds, | 214 const gfx::Rect& old_bounds, |
| 215 const gfx::Rect& new_bounds) override; | 215 const gfx::Rect& new_bounds) override; |
| 216 void OnWindowClientAreaChanged(ServerView* window, | 216 void OnWindowClientAreaChanged(ServerView* window, |
| 217 const gfx::Rect& old_client_area, | 217 const gfx::Rect& old_client_area, |
| 218 const gfx::Rect& new_client_area) override; | 218 const gfx::Rect& new_client_area) override; |
| 219 void OnViewReordered(ServerView* view, | 219 void OnViewReordered(ServerView* view, |
| 220 ServerView* relative, | 220 ServerView* relative, |
| 221 mojo::OrderDirection direction) override; | 221 mojom::OrderDirection direction) override; |
| 222 void OnWillChangeViewVisibility(ServerView* view) override; | 222 void OnWillChangeViewVisibility(ServerView* view) override; |
| 223 void OnViewSharedPropertyChanged( | 223 void OnViewSharedPropertyChanged( |
| 224 ServerView* view, | 224 ServerView* view, |
| 225 const std::string& name, | 225 const std::string& name, |
| 226 const std::vector<uint8_t>* new_data) override; | 226 const std::vector<uint8_t>* new_data) override; |
| 227 void OnViewTextInputStateChanged(ServerView* view, | 227 void OnViewTextInputStateChanged(ServerView* view, |
| 228 const ui::TextInputState& state) override; | 228 const ui::TextInputState& state) override; |
| 229 | 229 |
| 230 ConnectionManagerDelegate* delegate_; | 230 ConnectionManagerDelegate* delegate_; |
| 231 | 231 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 249 ScopedChange* current_change_; | 249 ScopedChange* current_change_; |
| 250 | 250 |
| 251 bool in_destructor_; | 251 bool in_destructor_; |
| 252 | 252 |
| 253 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); | 253 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); |
| 254 }; | 254 }; |
| 255 | 255 |
| 256 } // namespace mus | 256 } // namespace mus |
| 257 | 257 |
| 258 #endif // COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ | 258 #endif // COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ |
| OLD | NEW |