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_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 26 matching lines...) Expand all Loading... | |
| 66 } | 71 } |
| 67 void ClearChangeAckedCallback() { | 72 void ClearChangeAckedCallback() { |
| 68 change_acked_callback_ = base::Callback<void(void)>(); | 73 change_acked_callback_ = base::Callback<void(void)>(); |
| 69 } | 74 } |
| 70 | 75 |
| 71 // Start/stop tracking views. While tracked, they can be retrieved via | 76 // Start/stop tracking views. While tracked, they can be retrieved via |
| 72 // ViewManager::GetViewById. | 77 // ViewManager::GetViewById. |
| 73 void AddView(View* view); | 78 void AddView(View* view); |
| 74 void RemoveView(Id view_id); | 79 void RemoveView(Id view_id); |
| 75 | 80 |
| 76 void OnConnectionEstablished(); | |
| 77 | |
| 78 private: | 81 private: |
| 79 friend class RootObserver; | 82 friend class RootObserver; |
| 80 | 83 |
| 81 typedef std::map<Id, View*> IdToViewMap; | 84 typedef std::map<Id, View*> IdToViewMap; |
| 82 | 85 |
| 83 // Overridden from ViewManager: | 86 // Overridden from ViewManager: |
| 84 const std::string& GetEmbedderURL() const override; | 87 const std::string& GetEmbedderURL() const override; |
| 85 const std::vector<View*>& GetRoots() const override; | 88 const std::vector<View*>& GetRoots() const override; |
| 86 View* GetViewById(Id id) override; | 89 View* GetViewById(Id id) override; |
| 87 | 90 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 112 EventPtr event, | 115 EventPtr event, |
| 113 const Callback<void()>& callback) override; | 116 const Callback<void()>& callback) override; |
| 114 | 117 |
| 115 // Overridden from WindowManagerClient: | 118 // Overridden from WindowManagerClient: |
| 116 void OnCaptureChanged(Id old_capture_view_id, | 119 void OnCaptureChanged(Id old_capture_view_id, |
| 117 Id new_capture_view_id) override; | 120 Id new_capture_view_id) override; |
| 118 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; |
| 119 void OnActiveWindowChanged(Id old_focused_window, | 122 void OnActiveWindowChanged(Id old_focused_window, |
| 120 Id new_focused_window) override; | 123 Id new_focused_window) override; |
| 121 | 124 |
| 125 // ErrorHandler implementation. | |
| 126 void OnConnectionError() override; | |
| 127 | |
| 122 void RemoveRoot(View* root); | 128 void RemoveRoot(View* root); |
| 123 | 129 |
| 124 void OnActionCompleted(bool success); | 130 void OnActionCompleted(bool success); |
| 125 void OnActionCompletedWithErrorCode(ErrorCode code); | 131 void OnActionCompletedWithErrorCode(ErrorCode code); |
| 126 | 132 |
| 127 base::Callback<void(bool)> ActionCompletedCallback(); | 133 base::Callback<void(bool)> ActionCompletedCallback(); |
| 128 base::Callback<void(ErrorCode)> ActionCompletedCallbackWithErrorCode(); | 134 base::Callback<void(ErrorCode)> ActionCompletedCallbackWithErrorCode(); |
| 129 | 135 |
| 130 bool connected_; | 136 bool connected_; |
| 131 ConnectionSpecificId connection_id_; | 137 ConnectionSpecificId connection_id_; |
| 132 ConnectionSpecificId next_id_; | 138 ConnectionSpecificId next_id_; |
| 133 | 139 |
| 134 std::string creator_url_; | 140 std::string creator_url_; |
| 135 | 141 |
| 136 base::Callback<void(void)> change_acked_callback_; | 142 base::Callback<void(void)> change_acked_callback_; |
| 137 | 143 |
| 138 ViewManagerDelegate* delegate_; | 144 ViewManagerDelegate* delegate_; |
| 139 | 145 |
| 140 std::vector<View*> roots_; | 146 std::vector<View*> roots_; |
| 141 | 147 |
| 142 IdToViewMap views_; | 148 IdToViewMap views_; |
| 143 | 149 |
| 144 ViewManagerService* service_; | 150 ViewManagerService* service_; |
| 145 | 151 |
| 146 WindowManagerPtr window_manager_; | 152 WindowManagerPtr window_manager_; |
| 147 | 153 |
| 154 Binding<ViewManagerClient> binding_; | |
| 155 bool delete_on_error_; | |
|
sky
2014/11/13 00:34:38
const
| |
| 156 | |
| 148 DISALLOW_COPY_AND_ASSIGN(ViewManagerClientImpl); | 157 DISALLOW_COPY_AND_ASSIGN(ViewManagerClientImpl); |
| 149 }; | 158 }; |
| 150 | 159 |
| 151 } // namespace mojo | 160 } // namespace mojo |
| 152 | 161 |
| 153 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ | 162 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ |
| OLD | NEW |