| 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 MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ | 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ |
| 6 #define MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ | 6 #define MOJO_SERVICES_VIEW_MANAGER_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 "mojo/public/cpp/bindings/array.h" | 12 #include "mojo/public/cpp/bindings/array.h" |
| 13 #include "mojo/services/view_manager/display_manager.h" | 13 #include "mojo/services/view_manager/display_manager.h" |
| 14 #include "mojo/services/view_manager/ids.h" | 14 #include "mojo/services/view_manager/ids.h" |
| 15 #include "mojo/services/view_manager/server_view.h" | 15 #include "mojo/services/view_manager/server_view.h" |
| 16 #include "mojo/services/view_manager/server_view_delegate.h" | 16 #include "mojo/services/view_manager/server_view_delegate.h" |
| 17 #include "mojo/services/view_manager/view_manager_export.h" | 17 #include "mojo/services/view_manager/view_manager_export.h" |
| 18 #include "mojo/services/view_manager/window_manager_client_impl.h" |
| 18 | 19 |
| 19 namespace ui { | 20 namespace ui { |
| 20 class Event; | 21 class Event; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace mojo { | 24 namespace mojo { |
| 24 | 25 |
| 25 class ApplicationConnection; | 26 class ApplicationConnection; |
| 26 | 27 |
| 27 namespace service { | 28 namespace service { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 ConnectionManager(ApplicationConnection* app_connection, | 69 ConnectionManager(ApplicationConnection* app_connection, |
| 69 const Callback<void()>& native_viewport_closed_callback); | 70 const Callback<void()>& native_viewport_closed_callback); |
| 70 virtual ~ConnectionManager(); | 71 virtual ~ConnectionManager(); |
| 71 | 72 |
| 72 // Returns the id for the next ViewManagerServiceImpl. | 73 // Returns the id for the next ViewManagerServiceImpl. |
| 73 ConnectionSpecificId GetAndAdvanceNextConnectionId(); | 74 ConnectionSpecificId GetAndAdvanceNextConnectionId(); |
| 74 | 75 |
| 75 void AddConnection(ViewManagerServiceImpl* connection); | 76 void AddConnection(ViewManagerServiceImpl* connection); |
| 76 void RemoveConnection(ViewManagerServiceImpl* connection); | 77 void RemoveConnection(ViewManagerServiceImpl* connection); |
| 77 | 78 |
| 78 // Establishes the initial client. Similar to Connect(), but the resulting | 79 // Used in two cases: |
| 79 // client is allowed to do anything. | 80 // . Establishes the client for the root. |
| 80 void EmbedRoot(const std::string& url, | 81 // . Requests to Embed() at an unspecified view. For this case the request |
| 81 InterfaceRequest<ServiceProvider> service_provider); | 82 // is passed on to the WindowManagerService. |
| 83 void Embed(const std::string& url, |
| 84 InterfaceRequest<ServiceProvider> service_provider); |
| 82 | 85 |
| 83 // See description of ViewManagerService::Embed() for details. This assumes | 86 // See description of ViewManagerService::Embed() for details. This assumes |
| 84 // |transport_view_id| is valid. | 87 // |transport_view_id| is valid. |
| 85 void Embed(ConnectionSpecificId creator_id, | 88 void EmbedAtView(ConnectionSpecificId creator_id, |
| 86 const String& url, | 89 const String& url, |
| 87 Id transport_view_id, | 90 Id transport_view_id, |
| 88 InterfaceRequest<ServiceProvider> service_provider); | 91 InterfaceRequest<ServiceProvider> service_provider); |
| 89 | 92 |
| 90 // Returns the connection by id. | 93 // Returns the connection by id. |
| 91 ViewManagerServiceImpl* GetConnection(ConnectionSpecificId connection_id); | 94 ViewManagerServiceImpl* GetConnection(ConnectionSpecificId connection_id); |
| 92 | 95 |
| 93 // Returns the View identified by |id|. | 96 // Returns the View identified by |id|. |
| 94 ServerView* GetView(const ViewId& id); | 97 ServerView* GetView(const ViewId& id); |
| 95 | 98 |
| 96 ServerView* root() { return root_.get(); } | 99 ServerView* root() { return root_.get(); } |
| 97 | 100 |
| 98 bool IsProcessingChange() const { return current_change_ != NULL; } | 101 bool IsProcessingChange() const { return current_change_ != NULL; } |
| 99 | 102 |
| 100 bool is_processing_delete_view() const { | 103 bool is_processing_delete_view() const { |
| 101 return current_change_ && current_change_->is_delete_view(); | 104 return current_change_ && current_change_->is_delete_view(); |
| 102 } | 105 } |
| 103 | 106 |
| 104 // Invoked when a connection messages a client about the change. This is used | 107 // Invoked when a connection messages a client about the change. This is used |
| 105 // to avoid sending ServerChangeIdAdvanced() unnecessarily. | 108 // to avoid sending ServerChangeIdAdvanced() unnecessarily. |
| 106 void OnConnectionMessagedClient(ConnectionSpecificId id); | 109 void OnConnectionMessagedClient(ConnectionSpecificId id); |
| 107 | 110 |
| 108 // Returns true if OnConnectionMessagedClient() was invoked for id. | 111 // Returns true if OnConnectionMessagedClient() was invoked for id. |
| 109 bool DidConnectionMessageClient(ConnectionSpecificId id) const; | 112 bool DidConnectionMessageClient(ConnectionSpecificId id) const; |
| 110 | 113 |
| 111 // Returns the ViewManagerServiceImpl that has |id| as a root. | 114 // Returns the ViewManagerServiceImpl that has |id| as a root. |
| 112 ViewManagerServiceImpl* GetConnectionWithRoot(const ViewId& id) { | 115 ViewManagerServiceImpl* GetConnectionWithRoot(const ViewId& id) { |
| 113 return const_cast<ViewManagerServiceImpl*>( | 116 return const_cast<ViewManagerServiceImpl*>( |
| 114 const_cast<const ConnectionManager*>(this)->GetConnectionWithRoot(id)); | 117 const_cast<const ConnectionManager*>(this)->GetConnectionWithRoot(id)); |
| 115 } | 118 } |
| 116 const ViewManagerServiceImpl* GetConnectionWithRoot(const ViewId& id) const; | 119 const ViewManagerServiceImpl* GetConnectionWithRoot(const ViewId& id) const; |
| 117 | 120 |
| 118 void DispatchViewInputEventToWindowManager(EventPtr event); | 121 void DispatchViewInputEventToDelegate(EventPtr event); |
| 119 | 122 |
| 120 // These functions trivially delegate to all ViewManagerServiceImpls, which in | 123 // These functions trivially delegate to all ViewManagerServiceImpls, which in |
| 121 // term notify their clients. | 124 // term notify their clients. |
| 122 void ProcessViewDestroyed(ServerView* view); | 125 void ProcessViewDestroyed(ServerView* view); |
| 123 void ProcessViewBoundsChanged(const ServerView* view, | 126 void ProcessViewBoundsChanged(const ServerView* view, |
| 124 const gfx::Rect& old_bounds, | 127 const gfx::Rect& old_bounds, |
| 125 const gfx::Rect& new_bounds); | 128 const gfx::Rect& new_bounds); |
| 126 void ProcessWillChangeViewHierarchy(const ServerView* view, | 129 void ProcessWillChangeViewHierarchy(const ServerView* view, |
| 127 const ServerView* new_parent, | 130 const ServerView* new_parent, |
| 128 const ServerView* old_parent); | 131 const ServerView* old_parent); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 const gfx::Rect& old_bounds, | 175 const gfx::Rect& old_bounds, |
| 173 const gfx::Rect& new_bounds) override; | 176 const gfx::Rect& new_bounds) override; |
| 174 virtual void OnViewSurfaceIdChanged(const ServerView* view) override; | 177 virtual void OnViewSurfaceIdChanged(const ServerView* view) override; |
| 175 virtual void OnViewReordered(const ServerView* view, | 178 virtual void OnViewReordered(const ServerView* view, |
| 176 const ServerView* relative, | 179 const ServerView* relative, |
| 177 OrderDirection direction) override; | 180 OrderDirection direction) override; |
| 178 virtual void OnWillChangeViewVisibility(const ServerView* view) override; | 181 virtual void OnWillChangeViewVisibility(const ServerView* view) override; |
| 179 | 182 |
| 180 ApplicationConnection* app_connection_; | 183 ApplicationConnection* app_connection_; |
| 181 | 184 |
| 185 WindowManagerClientImpl wm_client_impl_; |
| 186 |
| 182 // ID to use for next ViewManagerServiceImpl. | 187 // ID to use for next ViewManagerServiceImpl. |
| 183 ConnectionSpecificId next_connection_id_; | 188 ConnectionSpecificId next_connection_id_; |
| 184 | 189 |
| 185 // Set of ViewManagerServiceImpls. | 190 // Set of ViewManagerServiceImpls. |
| 186 ConnectionMap connection_map_; | 191 ConnectionMap connection_map_; |
| 187 | 192 |
| 188 DisplayManager display_manager_; | 193 DisplayManager display_manager_; |
| 189 | 194 |
| 190 scoped_ptr<ServerView> root_; | 195 scoped_ptr<ServerView> root_; |
| 191 | 196 |
| 192 // Set of ViewManagerServiceImpls created by way of Connect(). These have to | 197 // Set of ViewManagerServiceImpls created by way of Connect(). These have to |
| 193 // be explicitly destroyed. | 198 // be explicitly destroyed. |
| 194 std::set<ViewManagerServiceImpl*> connections_created_by_connect_; | 199 std::set<ViewManagerServiceImpl*> connections_created_by_connect_; |
| 195 | 200 |
| 196 // If non-null we're processing a change. The ScopedChange is not owned by us | 201 // If non-null we're processing a change. The ScopedChange is not owned by us |
| 197 // (it's created on the stack by ViewManagerServiceImpl). | 202 // (it's created on the stack by ViewManagerServiceImpl). |
| 198 ScopedChange* current_change_; | 203 ScopedChange* current_change_; |
| 199 | 204 |
| 200 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); | 205 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); |
| 201 }; | 206 }; |
| 202 | 207 |
| 203 } // namespace service | 208 } // namespace service |
| 204 } // namespace mojo | 209 } // namespace mojo |
| 205 | 210 |
| 206 #endif // MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ | 211 #endif // MOJO_SERVICES_VIEW_MANAGER_CONNECTION_MANAGER_H_ |
| OLD | NEW |