| 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_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ | 5 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ |
| 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ | 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 12 #include "mojo/services/public/cpp/view_manager/types.h" | 13 #include "mojo/services/public/cpp/view_manager/types.h" |
| 13 #include "mojo/services/public/cpp/view_manager/view.h" | 14 #include "mojo/services/public/cpp/view_manager/view.h" |
| 14 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 15 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
| 15 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | 16 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" |
| 16 #include "mojo/services/public/interfaces/window_manager/window_manager.mojom.h" | 17 #include "mojo/services/public/interfaces/window_manager/window_manager.mojom.h" |
| 17 | 18 |
| 18 namespace mojo { | 19 namespace mojo { |
| 19 class Shell; | 20 class Shell; |
| 20 class ViewManager; | 21 class ViewManager; |
| 21 class ViewManagerDelegate; | 22 class ViewManagerDelegate; |
| 22 class ViewManagerTransaction; | 23 class ViewManagerTransaction; |
| 23 | 24 |
| 24 // Manages the connection with the View Manager service. | 25 // Manages the connection with the View Manager service. |
| 25 class ViewManagerClientImpl : public ViewManager, | 26 class ViewManagerClientImpl : public ViewManager, |
| 26 public InterfaceImpl<ViewManagerClient>, | 27 public ViewManagerClient, |
| 27 public WindowManagerClient { | 28 public WindowManagerClient, |
| 29 public ErrorHandler { |
| 28 public: | 30 public: |
| 29 ViewManagerClientImpl(ViewManagerDelegate* delegate, Shell* shell); | 31 ViewManagerClientImpl(ViewManagerDelegate* delegate, |
| 32 Shell* shell, |
| 33 ScopedMessagePipeHandle handle, |
| 34 bool delete_on_error); |
| 30 ~ViewManagerClientImpl() override; | 35 ~ViewManagerClientImpl() override; |
| 31 | 36 |
| 32 bool connected() const { return connected_; } | 37 bool connected() const { return connected_; } |
| 33 ConnectionSpecificId connection_id() const { return connection_id_; } | 38 ConnectionSpecificId connection_id() const { return connection_id_; } |
| 34 | 39 |
| 35 // API exposed to the view implementations that pushes local changes to the | 40 // API exposed to the view implementations that pushes local changes to the |
| 36 // service. | 41 // service. |
| 37 Id CreateView(); | 42 Id CreateView(); |
| 38 void DestroyView(Id view_id); | 43 void DestroyView(Id view_id); |
| 39 | 44 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 private: | 81 private: |
| 77 friend class RootObserver; | 82 friend class RootObserver; |
| 78 | 83 |
| 79 typedef std::map<Id, View*> IdToViewMap; | 84 typedef std::map<Id, View*> IdToViewMap; |
| 80 | 85 |
| 81 // Overridden from ViewManager: | 86 // Overridden from ViewManager: |
| 82 const std::string& GetEmbedderURL() const override; | 87 const std::string& GetEmbedderURL() const override; |
| 83 const std::vector<View*>& GetRoots() const override; | 88 const std::vector<View*>& GetRoots() const override; |
| 84 View* GetViewById(Id id) override; | 89 View* GetViewById(Id id) override; |
| 85 | 90 |
| 86 // Overridden from InterfaceImpl: | |
| 87 void OnConnectionEstablished() override; | |
| 88 | |
| 89 // Overridden from ViewManagerClient: | 91 // Overridden from ViewManagerClient: |
| 90 void OnEmbed(ConnectionSpecificId connection_id, | 92 void OnEmbed(ConnectionSpecificId connection_id, |
| 91 const String& creator_url, | 93 const String& creator_url, |
| 92 ViewDataPtr root, | 94 ViewDataPtr root, |
| 93 InterfaceRequest<ServiceProvider> parent_services, | 95 InterfaceRequest<ServiceProvider> parent_services, |
| 94 ScopedMessagePipeHandle window_manager_pipe) override; | 96 ScopedMessagePipeHandle window_manager_pipe) override; |
| 95 void OnEmbeddedAppDisconnected(Id view_id) override; | 97 void OnEmbeddedAppDisconnected(Id view_id) override; |
| 96 void OnViewBoundsChanged(Id view_id, | 98 void OnViewBoundsChanged(Id view_id, |
| 97 RectPtr old_bounds, | 99 RectPtr old_bounds, |
| 98 RectPtr new_bounds) override; | 100 RectPtr new_bounds) override; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 113 EventPtr event, | 115 EventPtr event, |
| 114 const Callback<void()>& callback) override; | 116 const Callback<void()>& callback) override; |
| 115 | 117 |
| 116 // Overridden from WindowManagerClient: | 118 // Overridden from WindowManagerClient: |
| 117 void OnCaptureChanged(Id old_capture_view_id, | 119 void OnCaptureChanged(Id old_capture_view_id, |
| 118 Id new_capture_view_id) override; | 120 Id new_capture_view_id) override; |
| 119 void OnFocusChanged(Id old_focused_view_id, Id new_focused_view_id) override; | 121 void OnFocusChanged(Id old_focused_view_id, Id new_focused_view_id) override; |
| 120 void OnActiveWindowChanged(Id old_focused_window, | 122 void OnActiveWindowChanged(Id old_focused_window, |
| 121 Id new_focused_window) override; | 123 Id new_focused_window) override; |
| 122 | 124 |
| 125 // ErrorHandler implementation. |
| 126 void OnConnectionError() override; |
| 127 |
| 123 void RemoveRoot(View* root); | 128 void RemoveRoot(View* root); |
| 124 | 129 |
| 125 void OnActionCompleted(bool success); | 130 void OnActionCompleted(bool success); |
| 126 void OnActionCompletedWithErrorCode(ErrorCode code); | 131 void OnActionCompletedWithErrorCode(ErrorCode code); |
| 127 | 132 |
| 128 base::Callback<void(bool)> ActionCompletedCallback(); | 133 base::Callback<void(bool)> ActionCompletedCallback(); |
| 129 base::Callback<void(ErrorCode)> ActionCompletedCallbackWithErrorCode(); | 134 base::Callback<void(ErrorCode)> ActionCompletedCallbackWithErrorCode(); |
| 130 | 135 |
| 131 bool connected_; | 136 bool connected_; |
| 132 ConnectionSpecificId connection_id_; | 137 ConnectionSpecificId connection_id_; |
| 133 ConnectionSpecificId next_id_; | 138 ConnectionSpecificId next_id_; |
| 134 | 139 |
| 135 std::string creator_url_; | 140 std::string creator_url_; |
| 136 | 141 |
| 137 base::Callback<void(void)> change_acked_callback_; | 142 base::Callback<void(void)> change_acked_callback_; |
| 138 | 143 |
| 139 ViewManagerDelegate* delegate_; | 144 ViewManagerDelegate* delegate_; |
| 140 | 145 |
| 141 std::vector<View*> roots_; | 146 std::vector<View*> roots_; |
| 142 | 147 |
| 143 IdToViewMap views_; | 148 IdToViewMap views_; |
| 144 | 149 |
| 150 WindowManagerPtr window_manager_; |
| 151 |
| 152 Binding<ViewManagerClient> binding_; |
| 145 ViewManagerService* service_; | 153 ViewManagerService* service_; |
| 146 | 154 const bool delete_on_error_; |
| 147 WindowManagerPtr window_manager_; | |
| 148 | 155 |
| 149 DISALLOW_COPY_AND_ASSIGN(ViewManagerClientImpl); | 156 DISALLOW_COPY_AND_ASSIGN(ViewManagerClientImpl); |
| 150 }; | 157 }; |
| 151 | 158 |
| 152 } // namespace mojo | 159 } // namespace mojo |
| 153 | 160 |
| 154 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ | 161 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ |
| OLD | NEW |