| 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/services/public/cpp/geometry/geometry_type_converters.h" | 12 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" |
| 13 #include "mojo/services/public/cpp/view_manager/types.h" | 13 #include "mojo/services/public/cpp/view_manager/types.h" |
| 14 #include "mojo/services/public/cpp/view_manager/view.h" | 14 #include "mojo/services/public/cpp/view_manager/view.h" |
| 15 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 15 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
| 16 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | 16 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" |
| 17 #include "mojo/services/public/interfaces/window_manager/window_manager.mojom.h" | 17 #include "mojo/services/public/interfaces/window_manager/window_manager.mojom.h" |
| 18 | 18 |
| 19 class SkBitmap; | 19 class SkBitmap; |
| 20 | 20 |
| 21 namespace mojo { | 21 namespace mojo { |
| 22 class BitmapUploader; | |
| 23 class ViewManager; | 22 class ViewManager; |
| 24 class ViewManagerDelegate; | 23 class ViewManagerDelegate; |
| 25 class ViewManagerTransaction; | 24 class ViewManagerTransaction; |
| 26 class Shell; | 25 class Shell; |
| 27 | 26 |
| 28 // Manages the connection with the View Manager service. | 27 // Manages the connection with the View Manager service. |
| 29 class ViewManagerClientImpl : public ViewManager, | 28 class ViewManagerClientImpl : public ViewManager, |
| 30 public InterfaceImpl<ViewManagerClient>, | 29 public InterfaceImpl<ViewManagerClient>, |
| 31 public WindowManagerClient { | 30 public WindowManagerClient { |
| 32 public: | 31 public: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 47 void AddChild(Id child_id, Id parent_id); | 46 void AddChild(Id child_id, Id parent_id); |
| 48 void RemoveChild(Id child_id, Id parent_id); | 47 void RemoveChild(Id child_id, Id parent_id); |
| 49 | 48 |
| 50 void Reorder(Id view_id, Id relative_view_id, OrderDirection direction); | 49 void Reorder(Id view_id, Id relative_view_id, OrderDirection direction); |
| 51 | 50 |
| 52 // Returns true if the specified view was created by this connection. | 51 // Returns true if the specified view was created by this connection. |
| 53 bool OwnsView(Id id) const; | 52 bool OwnsView(Id id) const; |
| 54 | 53 |
| 55 void SetBounds(Id view_id, const gfx::Rect& bounds); | 54 void SetBounds(Id view_id, const gfx::Rect& bounds); |
| 56 void SetSurfaceId(Id view_id, SurfaceIdPtr surface_id); | 55 void SetSurfaceId(Id view_id, SurfaceIdPtr surface_id); |
| 57 // TODO(jamesr): Remove once all callers switch from SetContents to | |
| 58 // SetSurfaceId. | |
| 59 void SetViewContents(Id view_id, const SkBitmap& contents); | |
| 60 void SetFocus(Id view_id); | 56 void SetFocus(Id view_id); |
| 61 void SetVisible(Id view_id, bool visible); | 57 void SetVisible(Id view_id, bool visible); |
| 62 | 58 |
| 63 void Embed(const String& url, Id view_id); | 59 void Embed(const String& url, Id view_id); |
| 64 void Embed(const String& url, | 60 void Embed(const String& url, |
| 65 Id view_id, | 61 Id view_id, |
| 66 ServiceProviderPtr service_provider); | 62 ServiceProviderPtr service_provider); |
| 67 | 63 |
| 68 void set_change_acked_callback(const base::Callback<void(void)>& callback) { | 64 void set_change_acked_callback(const base::Callback<void(void)>& callback) { |
| 69 change_acked_callback_ = callback; | 65 change_acked_callback_ = callback; |
| 70 } | 66 } |
| 71 void ClearChangeAckedCallback() { | 67 void ClearChangeAckedCallback() { |
| 72 change_acked_callback_ = base::Callback<void(void)>(); | 68 change_acked_callback_ = base::Callback<void(void)>(); |
| 73 } | 69 } |
| 74 | 70 |
| 75 // Start/stop tracking views. While tracked, they can be retrieved via | 71 // Start/stop tracking views. While tracked, they can be retrieved via |
| 76 // ViewManager::GetViewById. | 72 // ViewManager::GetViewById. |
| 77 void AddView(View* view); | 73 void AddView(View* view); |
| 78 void RemoveView(Id view_id); | 74 void RemoveView(Id view_id); |
| 79 | 75 |
| 76 Shell* shell() { return shell_; } |
| 77 |
| 80 private: | 78 private: |
| 81 friend class RootObserver; | 79 friend class RootObserver; |
| 82 | 80 |
| 83 typedef std::map<Id, View*> IdToViewMap; | 81 typedef std::map<Id, View*> IdToViewMap; |
| 84 | 82 |
| 85 // Overridden from ViewManager: | 83 // Overridden from ViewManager: |
| 86 virtual void SetWindowManagerDelegate( | 84 virtual void SetWindowManagerDelegate( |
| 87 WindowManagerDelegate* delegate) OVERRIDE; | 85 WindowManagerDelegate* delegate) OVERRIDE; |
| 88 virtual void DispatchEvent(View* target, EventPtr event) OVERRIDE; | 86 virtual void DispatchEvent(View* target, EventPtr event) OVERRIDE; |
| 89 virtual const std::string& GetEmbedderURL() const OVERRIDE; | 87 virtual const std::string& GetEmbedderURL() const OVERRIDE; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 virtual void OnFocusChanged(Id old_focused_view_id, | 124 virtual void OnFocusChanged(Id old_focused_view_id, |
| 127 Id new_focused_view_id) OVERRIDE; | 125 Id new_focused_view_id) OVERRIDE; |
| 128 virtual void OnActiveWindowChanged(Id old_focused_window, | 126 virtual void OnActiveWindowChanged(Id old_focused_window, |
| 129 Id new_focused_window) OVERRIDE; | 127 Id new_focused_window) OVERRIDE; |
| 130 | 128 |
| 131 void RemoveRoot(View* root); | 129 void RemoveRoot(View* root); |
| 132 | 130 |
| 133 void OnActionCompleted(bool success); | 131 void OnActionCompleted(bool success); |
| 134 void OnActionCompletedWithErrorCode(ErrorCode code); | 132 void OnActionCompletedWithErrorCode(ErrorCode code); |
| 135 | 133 |
| 134 BitmapUploader* BitmapUploaderForView(Id view_id); |
| 135 |
| 136 base::Callback<void(bool)> ActionCompletedCallback(); | 136 base::Callback<void(bool)> ActionCompletedCallback(); |
| 137 base::Callback<void(ErrorCode)> ActionCompletedCallbackWithErrorCode(); | 137 base::Callback<void(ErrorCode)> ActionCompletedCallbackWithErrorCode(); |
| 138 | 138 |
| 139 bool connected_; | 139 bool connected_; |
| 140 ConnectionSpecificId connection_id_; | 140 ConnectionSpecificId connection_id_; |
| 141 ConnectionSpecificId next_id_; | 141 ConnectionSpecificId next_id_; |
| 142 | 142 |
| 143 std::string creator_url_; | 143 std::string creator_url_; |
| 144 | 144 |
| 145 base::Callback<void(void)> change_acked_callback_; | 145 base::Callback<void(void)> change_acked_callback_; |
| 146 | 146 |
| 147 ViewManagerDelegate* delegate_; | 147 ViewManagerDelegate* delegate_; |
| 148 WindowManagerDelegate* window_manager_delegate_; | 148 WindowManagerDelegate* window_manager_delegate_; |
| 149 | 149 |
| 150 std::vector<View*> roots_; | 150 std::vector<View*> roots_; |
| 151 | 151 |
| 152 IdToViewMap views_; | 152 IdToViewMap views_; |
| 153 | 153 |
| 154 ViewManagerService* service_; | 154 ViewManagerService* service_; |
| 155 | 155 |
| 156 WindowManagerServicePtr window_manager_; | 156 WindowManagerServicePtr window_manager_; |
| 157 | 157 |
| 158 // TODO(jamesr): Remove once all callers switch from SetContents to | 158 // TODO(jamesr): Remove once all callers switch from SetContents to |
| 159 // SetSurfaceId. | 159 // SetSurfaceId. |
| 160 Shell* shell_; | 160 Shell* shell_; |
| 161 scoped_ptr<BitmapUploader> bitmap_uploader_; | |
| 162 | 161 |
| 163 DISALLOW_COPY_AND_ASSIGN(ViewManagerClientImpl); | 162 DISALLOW_COPY_AND_ASSIGN(ViewManagerClientImpl); |
| 164 }; | 163 }; |
| 165 | 164 |
| 166 } // namespace mojo | 165 } // namespace mojo |
| 167 | 166 |
| 168 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ | 167 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ |
| OLD | NEW |