| 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_VIEW_MANAGER_SERVICE_IMPL_H_ | 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ |
| 6 #define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ | 6 #define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 ConnectionSpecificId creator_id() const { return creator_id_; } | 55 ConnectionSpecificId creator_id() const { return creator_id_; } |
| 56 const std::string& url() const { return url_; } | 56 const std::string& url() const { return url_; } |
| 57 | 57 |
| 58 // Returns the View with the specified id. | 58 // Returns the View with the specified id. |
| 59 ServerView* GetView(const ViewId& id) { | 59 ServerView* GetView(const ViewId& id) { |
| 60 return const_cast<ServerView*>( | 60 return const_cast<ServerView*>( |
| 61 const_cast<const ViewManagerServiceImpl*>(this)->GetView(id)); | 61 const_cast<const ViewManagerServiceImpl*>(this)->GetView(id)); |
| 62 } | 62 } |
| 63 const ServerView* GetView(const ViewId& id) const; | 63 const ServerView* GetView(const ViewId& id) const; |
| 64 | 64 |
| 65 // Returns true if this has |id| as a root. | 65 // Returns true if this connection's root is |id|. |
| 66 bool HasRoot(const ViewId& id) const; | 66 bool IsRoot(const ViewId& id) const; |
| 67 const ViewIdSet& roots() const { return roots_; } | |
| 68 | 67 |
| 69 // Invoked when a connection is about to be destroyed. | 68 // Invoked when a connection is about to be destroyed. |
| 70 void OnWillDestroyViewManagerServiceImpl(ViewManagerServiceImpl* connection); | 69 void OnWillDestroyViewManagerServiceImpl(ViewManagerServiceImpl* connection); |
| 71 | 70 |
| 72 // The following methods are invoked after the corresponding change has been | 71 // The following methods are invoked after the corresponding change has been |
| 73 // processed. They do the appropriate bookkeeping and update the client as | 72 // processed. They do the appropriate bookkeeping and update the client as |
| 74 // necessary. | 73 // necessary. |
| 75 void ProcessViewBoundsChanged(const ServerView* view, | 74 void ProcessViewBoundsChanged(const ServerView* view, |
| 76 const gfx::Rect& old_bounds, | 75 const gfx::Rect& old_bounds, |
| 77 const gfx::Rect& new_bounds, | 76 const gfx::Rect& new_bounds, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 101 // TODO(sky): move this to private section (currently can't because of | 100 // TODO(sky): move this to private section (currently can't because of |
| 102 // bindings). | 101 // bindings). |
| 103 // InterfaceImp overrides: | 102 // InterfaceImp overrides: |
| 104 void OnConnectionError() override; | 103 void OnConnectionError() override; |
| 105 | 104 |
| 106 private: | 105 private: |
| 107 typedef std::map<ConnectionSpecificId, ServerView*> ViewMap; | 106 typedef std::map<ConnectionSpecificId, ServerView*> ViewMap; |
| 108 | 107 |
| 109 bool IsViewKnown(const ServerView* view) const; | 108 bool IsViewKnown(const ServerView* view) const; |
| 110 | 109 |
| 111 // Returns true if this ViewManagerServiceImpl is providing a root for | |
| 112 // |connection|. That is, |connection| is embedded in one of our views. If | |
| 113 // this ViewManagerServiceImpl does provide a root, |root_id| | |
| 114 // is set to that root. | |
| 115 bool ProvidesRoot(const ViewManagerServiceImpl* connection, | |
| 116 ViewId* root_id) const; | |
| 117 | |
| 118 // These functions return true if the corresponding mojom function is allowed | 110 // These functions return true if the corresponding mojom function is allowed |
| 119 // for this connection. | 111 // for this connection. |
| 120 bool CanReorderView(const ServerView* view, | 112 bool CanReorderView(const ServerView* view, |
| 121 const ServerView* relative_view, | 113 const ServerView* relative_view, |
| 122 OrderDirection direction) const; | 114 OrderDirection direction) const; |
| 123 | 115 |
| 124 // Deletes a view owned by this connection. Returns true on success. |source| | 116 // Deletes a view owned by this connection. Returns true on success. |source| |
| 125 // is the connection that originated the change. | 117 // is the connection that originated the change. |
| 126 bool DeleteViewImpl(ViewManagerServiceImpl* source, ServerView* view); | 118 bool DeleteViewImpl(ViewManagerServiceImpl* source, ServerView* view); |
| 127 | 119 |
| 128 // If |view| is known (in |known_views_|) does nothing. Otherwise adds |view| | 120 // If |view| is known (in |known_views_|) does nothing. Otherwise adds |view| |
| 129 // to |views|, marks |view| as known and recurses. | 121 // to |views|, marks |view| as known and recurses. |
| 130 void GetUnknownViewsFrom(const ServerView* view, | 122 void GetUnknownViewsFrom(const ServerView* view, |
| 131 std::vector<const ServerView*>* views); | 123 std::vector<const ServerView*>* views); |
| 132 | 124 |
| 133 // Removes |view| and all its descendants from |known_views_|. This does not | 125 // Removes |view| and all its descendants from |known_views_|. This does not |
| 134 // recurse through views that were created by this connection. All views owned | 126 // recurse through views that were created by this connection. All views owned |
| 135 // by this connection are added to |local_views|. | 127 // by this connection are added to |local_views|. |
| 136 void RemoveFromKnown(const ServerView* view, | 128 void RemoveFromKnown(const ServerView* view, |
| 137 std::vector<ServerView*>* local_views); | 129 std::vector<ServerView*>* local_views); |
| 138 | 130 |
| 139 // Removes |view_id| from the set of roots this connection knows about. | 131 // Resets the root of this connection. |
| 140 void RemoveRoot(const ViewId& view_id); | 132 void RemoveRoot(); |
| 141 | 133 |
| 142 void RemoveChildrenAsPartOfEmbed(const ViewId& view_id); | 134 void RemoveChildrenAsPartOfEmbed(const ViewId& view_id); |
| 143 | 135 |
| 144 // Converts View(s) to ViewData(s) for transport. This assumes all the views | 136 // Converts View(s) to ViewData(s) for transport. This assumes all the views |
| 145 // are valid for the client. The parent of views the client is not allowed to | 137 // are valid for the client. The parent of views the client is not allowed to |
| 146 // see are set to NULL (in the returned ViewData(s)). | 138 // see are set to NULL (in the returned ViewData(s)). |
| 147 Array<ViewDataPtr> ViewsToViewDatas( | 139 Array<ViewDataPtr> ViewsToViewDatas( |
| 148 const std::vector<const ServerView*>& views); | 140 const std::vector<const ServerView*>& views); |
| 149 ViewDataPtr ViewToViewData(const ServerView* view); | 141 ViewDataPtr ViewToViewData(const ServerView* view); |
| 150 | 142 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 const Callback<void(bool)>& callback) override; | 183 const Callback<void(bool)>& callback) override; |
| 192 void Embed(const String& url, | 184 void Embed(const String& url, |
| 193 Id view_id, | 185 Id view_id, |
| 194 ServiceProviderPtr service_provider, | 186 ServiceProviderPtr service_provider, |
| 195 const Callback<void(bool)>& callback) override; | 187 const Callback<void(bool)>& callback) override; |
| 196 | 188 |
| 197 // InterfaceImpl: | 189 // InterfaceImpl: |
| 198 void OnConnectionEstablished() override; | 190 void OnConnectionEstablished() override; |
| 199 | 191 |
| 200 // AccessPolicyDelegate: | 192 // AccessPolicyDelegate: |
| 201 const base::hash_set<Id>& GetRootsForAccessPolicy() const override; | 193 bool IsRootForAccessPolicy(const ViewId& id) const override; |
| 202 bool IsViewKnownForAccessPolicy(const ServerView* view) const override; | 194 bool IsViewKnownForAccessPolicy(const ServerView* view) const override; |
| 203 bool IsViewRootOfAnotherConnectionForAccessPolicy( | 195 bool IsViewRootOfAnotherConnectionForAccessPolicy( |
| 204 const ServerView* view) const override; | 196 const ServerView* view) const override; |
| 205 | 197 |
| 206 ConnectionManager* connection_manager_; | 198 ConnectionManager* connection_manager_; |
| 207 | 199 |
| 208 // Id of this connection as assigned by ConnectionManager. | 200 // Id of this connection as assigned by ConnectionManager. |
| 209 const ConnectionSpecificId id_; | 201 const ConnectionSpecificId id_; |
| 210 | 202 |
| 211 // URL this connection was created for. | 203 // URL this connection was created for. |
| 212 const std::string url_; | 204 const std::string url_; |
| 213 | 205 |
| 214 // ID of the connection that created us. If 0 it indicates either we were | 206 // ID of the connection that created us. If 0 it indicates either we were |
| 215 // created by the root, or the connection that created us has been destroyed. | 207 // created by the root, or the connection that created us has been destroyed. |
| 216 ConnectionSpecificId creator_id_; | 208 ConnectionSpecificId creator_id_; |
| 217 | 209 |
| 218 // The URL of the app that embedded the app this connection was created for. | 210 // The URL of the app that embedded the app this connection was created for. |
| 219 const std::string creator_url_; | 211 const std::string creator_url_; |
| 220 | 212 |
| 221 scoped_ptr<AccessPolicy> access_policy_; | 213 scoped_ptr<AccessPolicy> access_policy_; |
| 222 | 214 |
| 223 // The views and views created by this connection. This connection owns these | 215 // The views and views created by this connection. This connection owns these |
| 224 // objects. | 216 // objects. |
| 225 ViewMap view_map_; | 217 ViewMap view_map_; |
| 226 | 218 |
| 227 // The set of views that has been communicated to the client. | 219 // The set of views that has been communicated to the client. |
| 228 ViewIdSet known_views_; | 220 ViewIdSet known_views_; |
| 229 | 221 |
| 230 // Set of root views from other connections. More specifically any time | 222 // The root of this connection. This is a scoped_ptr to reinforce the |
| 231 // Embed() is invoked the id of the view is added to this set for the child | 223 // connection may have no root. A connection has no root if either the root |
| 232 // connection. The connection Embed() was invoked on (the parent) doesn't | 224 // is destroyed or Embed() is invoked on the root. |
| 233 // directly track which connections are attached to which of its views. That | 225 scoped_ptr<ViewId> root_; |
| 234 // information can be found by looking through the |roots_| of all | |
| 235 // connections. | |
| 236 ViewIdSet roots_; | |
| 237 | 226 |
| 238 InterfaceRequest<ServiceProvider> service_provider_; | 227 InterfaceRequest<ServiceProvider> service_provider_; |
| 239 | 228 |
| 240 DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceImpl); | 229 DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceImpl); |
| 241 }; | 230 }; |
| 242 | 231 |
| 243 #if defined(OS_WIN) | 232 #if defined(OS_WIN) |
| 244 #pragma warning(pop) | 233 #pragma warning(pop) |
| 245 #endif | 234 #endif |
| 246 | 235 |
| 247 } // namespace service | 236 } // namespace service |
| 248 } // namespace mojo | 237 } // namespace mojo |
| 249 | 238 |
| 250 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ | 239 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ |
| OLD | NEW |