Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 21 class Rect; | 21 class Rect; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace mojo { | 24 namespace mojo { |
| 25 namespace service { | 25 namespace service { |
| 26 | 26 |
| 27 class AccessPolicy; | 27 class AccessPolicy; |
| 28 class ConnectionManager; | 28 class ConnectionManager; |
| 29 class ServerView; | 29 class ServerView; |
| 30 | 30 |
| 31 // Manages a connection from the client. | 31 // Manages a connection from the client. |
|
msw
2014/11/14 01:42:18
nit: perhaps expand on this comment?
sky
2014/11/14 20:56:03
Done.
| |
| 32 class ViewManagerServiceImpl | 32 class ViewManagerServiceImpl : public ViewManagerService, |
| 33 : public InterfaceImpl<ViewManagerService>, | 33 public AccessPolicyDelegate { |
| 34 public AccessPolicyDelegate { | |
| 35 public: | 34 public: |
| 36 using ViewIdSet = base::hash_set<Id>; | 35 using ViewIdSet = base::hash_set<Id>; |
| 37 | 36 |
| 38 ViewManagerServiceImpl(ConnectionManager* connection_manager, | 37 ViewManagerServiceImpl(ConnectionManager* connection_manager, |
| 39 ConnectionSpecificId creator_id, | 38 ConnectionSpecificId creator_id, |
| 40 const std::string& creator_url, | 39 const std::string& creator_url, |
| 41 const std::string& url, | 40 const std::string& url, |
| 42 const ViewId& root_id); | 41 const ViewId& root_id); |
| 43 ~ViewManagerServiceImpl() override; | 42 ~ViewManagerServiceImpl() override; |
| 44 | 43 |
| 45 // Called after bound. |service_provider| is the ServiceProvider to pass to | 44 // |service_provider| is the ServiceProvider to pass to the client via |
| 46 // the client via OnEmbed(). | 45 // OnEmbed(). |
| 47 void Init(InterfaceRequest<ServiceProvider> service_provider); | 46 void Init(ViewManagerClient* client, |
| 47 InterfaceRequest<ServiceProvider> service_provider); | |
| 48 | 48 |
| 49 ConnectionSpecificId id() const { return id_; } | 49 ConnectionSpecificId id() const { return id_; } |
| 50 ConnectionSpecificId creator_id() const { return creator_id_; } | 50 ConnectionSpecificId creator_id() const { return creator_id_; } |
| 51 const std::string& url() const { return url_; } | 51 const std::string& url() const { return url_; } |
| 52 | 52 |
| 53 ViewManagerClient* client() { return client_; } | |
| 54 | |
| 53 // Returns the View with the specified id. | 55 // Returns the View with the specified id. |
| 54 ServerView* GetView(const ViewId& id) { | 56 ServerView* GetView(const ViewId& id) { |
| 55 return const_cast<ServerView*>( | 57 return const_cast<ServerView*>( |
| 56 const_cast<const ViewManagerServiceImpl*>(this)->GetView(id)); | 58 const_cast<const ViewManagerServiceImpl*>(this)->GetView(id)); |
| 57 } | 59 } |
| 58 const ServerView* GetView(const ViewId& id) const; | 60 const ServerView* GetView(const ViewId& id) const; |
| 59 | 61 |
| 60 // Returns true if this connection's root is |id|. | 62 // Returns true if this connection's root is |id|. |
| 61 bool IsRoot(const ViewId& id) const; | 63 bool IsRoot(const ViewId& id) const; |
| 62 | 64 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 85 void ProcessViewReorder(const ServerView* view, | 87 void ProcessViewReorder(const ServerView* view, |
| 86 const ServerView* relative_view, | 88 const ServerView* relative_view, |
| 87 OrderDirection direction, | 89 OrderDirection direction, |
| 88 bool originated_change); | 90 bool originated_change); |
| 89 void ProcessViewDeleted(const ViewId& view, bool originated_change); | 91 void ProcessViewDeleted(const ViewId& view, bool originated_change); |
| 90 void ProcessWillChangeViewVisibility(const ServerView* view, | 92 void ProcessWillChangeViewVisibility(const ServerView* view, |
| 91 bool originated_change); | 93 bool originated_change); |
| 92 void ProcessViewPropertiesChanged(const ServerView* view, | 94 void ProcessViewPropertiesChanged(const ServerView* view, |
| 93 bool originated_change); | 95 bool originated_change); |
| 94 | 96 |
| 95 // TODO(sky): move this to private section (currently can't because of | |
| 96 // bindings). | |
| 97 // InterfaceImp overrides: | |
| 98 void OnConnectionError() override; | |
| 99 | |
| 100 private: | 97 private: |
| 101 typedef std::map<ConnectionSpecificId, ServerView*> ViewMap; | 98 typedef std::map<ConnectionSpecificId, ServerView*> ViewMap; |
| 102 | 99 |
| 103 bool IsViewKnown(const ServerView* view) const; | 100 bool IsViewKnown(const ServerView* view) const; |
| 104 | 101 |
| 105 // These functions return true if the corresponding mojom function is allowed | 102 // These functions return true if the corresponding mojom function is allowed |
| 106 // for this connection. | 103 // for this connection. |
| 107 bool CanReorderView(const ServerView* view, | 104 bool CanReorderView(const ServerView* view, |
| 108 const ServerView* relative_view, | 105 const ServerView* relative_view, |
| 109 OrderDirection direction) const; | 106 OrderDirection direction) const; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 // URL this connection was created for. | 192 // URL this connection was created for. |
| 196 const std::string url_; | 193 const std::string url_; |
| 197 | 194 |
| 198 // ID of the connection that created us. If 0 it indicates either we were | 195 // ID of the connection that created us. If 0 it indicates either we were |
| 199 // created by the root, or the connection that created us has been destroyed. | 196 // created by the root, or the connection that created us has been destroyed. |
| 200 ConnectionSpecificId creator_id_; | 197 ConnectionSpecificId creator_id_; |
| 201 | 198 |
| 202 // The URL of the app that embedded the app this connection was created for. | 199 // The URL of the app that embedded the app this connection was created for. |
| 203 const std::string creator_url_; | 200 const std::string creator_url_; |
| 204 | 201 |
| 202 ViewManagerClient* client_; | |
| 203 | |
| 205 scoped_ptr<AccessPolicy> access_policy_; | 204 scoped_ptr<AccessPolicy> access_policy_; |
| 206 | 205 |
| 207 // The views created by this connection. This connection owns these objects. | 206 // The views created by this connection. This connection owns these objects. |
| 208 ViewMap view_map_; | 207 ViewMap view_map_; |
| 209 | 208 |
| 210 // The set of views that has been communicated to the client. | 209 // The set of views that has been communicated to the client. |
| 211 ViewIdSet known_views_; | 210 ViewIdSet known_views_; |
| 212 | 211 |
| 213 // The root of this connection. This is a scoped_ptr to reinforce the | 212 // The root of this connection. This is a scoped_ptr to reinforce the |
| 214 // connection may have no root. A connection has no root if either the root | 213 // connection may have no root. A connection has no root if either the root |
| 215 // is destroyed or Embed() is invoked on the root. | 214 // is destroyed or Embed() is invoked on the root. |
| 216 scoped_ptr<ViewId> root_; | 215 scoped_ptr<ViewId> root_; |
| 217 | 216 |
| 218 DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceImpl); | 217 DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceImpl); |
| 219 }; | 218 }; |
| 220 | 219 |
| 221 } // namespace service | 220 } // namespace service |
| 222 } // namespace mojo | 221 } // namespace mojo |
| 223 | 222 |
| 224 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ | 223 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ |
| OLD | NEW |