| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_MANAGER_H_ | 5 #ifndef BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_MANAGER_H_ |
| 6 #define BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_MANAGER_H_ | 6 #define BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_MANAGER_H_ |
| 7 | 7 |
| 8 #include "blimp/client/core/contents/blimp_contents_impl.h" | 8 #include <map> |
| 9 |
| 10 #include "base/memory/weak_ptr.h" |
| 9 | 11 |
| 10 namespace blimp { | 12 namespace blimp { |
| 11 namespace client { | 13 namespace client { |
| 12 | 14 |
| 15 class BlimpCompositorDependencies; |
| 16 class BlimpContents; |
| 17 class BlimpContentsImpl; |
| 18 class ImeFeature; |
| 19 class NavigationFeature; |
| 20 class RenderWidgetFeature; |
| 13 class TabControlFeature; | 21 class TabControlFeature; |
| 14 | 22 |
| 15 // BlimpContentsManager does the real work of creating BlimpContentsImpl, and | 23 // BlimpContentsManager does the real work of creating BlimpContentsImpl, and |
| 16 // then passes the ownership to the caller. It also owns the observers to | 24 // then passes the ownership to the caller. It also owns the observers to |
| 17 // monitor the life time of the contents it creates. | 25 // monitor the life time of the contents it creates. |
| 18 class BlimpContentsManager { | 26 class BlimpContentsManager { |
| 19 public: | 27 public: |
| 20 explicit BlimpContentsManager(ImeFeature* ime_feature, | 28 explicit BlimpContentsManager( |
| 21 NavigationFeature* nav_feature, | 29 BlimpCompositorDependencies* blimp_compositor_dependencies, |
| 22 TabControlFeature* tab_control_feature); | 30 ImeFeature* ime_feature, |
| 31 NavigationFeature* nav_feature, |
| 32 RenderWidgetFeature* render_widget_feature, |
| 33 TabControlFeature* tab_control_feature); |
| 23 ~BlimpContentsManager(); | 34 ~BlimpContentsManager(); |
| 24 | 35 |
| 25 // Builds a BlimpContentsImpl and notifies the engine. | 36 // Builds a BlimpContentsImpl and notifies the engine. |
| 26 // TODO(mlliu): Currently we want to have a single BlimpContents. If there is | 37 // TODO(mlliu): Currently we want to have a single BlimpContents. If there is |
| 27 // an existing contents, return nullptr (http://crbug.com/642558). | 38 // an existing contents, return nullptr (http://crbug.com/642558). |
| 28 std::unique_ptr<BlimpContentsImpl> CreateBlimpContents(); | 39 std::unique_ptr<BlimpContentsImpl> CreateBlimpContents(); |
| 29 | 40 |
| 30 // The caller can query the contents through its id. | 41 // The caller can query the contents through its id. |
| 31 BlimpContentsImpl* GetBlimpContents(int id); | 42 BlimpContentsImpl* GetBlimpContents(int id); |
| 32 | 43 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 46 // Destroy the observer entry from the observer_map_ when a BlimpContentsImpl | 57 // Destroy the observer entry from the observer_map_ when a BlimpContentsImpl |
| 47 // is destroyed. | 58 // is destroyed. |
| 48 void EraseObserverFromMap(int id); | 59 void EraseObserverFromMap(int id); |
| 49 base::WeakPtr<BlimpContentsManager> GetWeakPtr(); | 60 base::WeakPtr<BlimpContentsManager> GetWeakPtr(); |
| 50 | 61 |
| 51 // BlimpContentsManager owns the BlimpContentsDeletionObserver for the | 62 // BlimpContentsManager owns the BlimpContentsDeletionObserver for the |
| 52 // contents it creates, with the content id being the key to help manage the | 63 // contents it creates, with the content id being the key to help manage the |
| 53 // lifetime of the observers. | 64 // lifetime of the observers. |
| 54 std::map<int, std::unique_ptr<BlimpContentsDeletionObserver>> observer_map_; | 65 std::map<int, std::unique_ptr<BlimpContentsDeletionObserver>> observer_map_; |
| 55 | 66 |
| 67 BlimpCompositorDependencies* blimp_compositor_dependencies_; |
| 56 ImeFeature* ime_feature_; | 68 ImeFeature* ime_feature_; |
| 57 NavigationFeature* navigation_feature_; | 69 NavigationFeature* navigation_feature_; |
| 70 RenderWidgetFeature* render_widget_feature_; |
| 58 TabControlFeature* tab_control_feature_; | 71 TabControlFeature* tab_control_feature_; |
| 59 | 72 |
| 60 // TODO(mlliu): Currently we want to have a single BlimpContents. Remove this | 73 // TODO(mlliu): Currently we want to have a single BlimpContents. Remove this |
| 61 // when it supports multiple tabs (http://crbug.com/642558). | 74 // when it supports multiple tabs (http://crbug.com/642558). |
| 62 bool tab_exists_ = false; | 75 bool tab_exists_ = false; |
| 63 | 76 |
| 64 base::WeakPtrFactory<BlimpContentsManager> weak_ptr_factory_; | 77 base::WeakPtrFactory<BlimpContentsManager> weak_ptr_factory_; |
| 65 | 78 |
| 66 DISALLOW_COPY_AND_ASSIGN(BlimpContentsManager); | 79 DISALLOW_COPY_AND_ASSIGN(BlimpContentsManager); |
| 67 }; | 80 }; |
| 68 | 81 |
| 69 } // namespace client | 82 } // namespace client |
| 70 } // namespace blimp | 83 } // namespace blimp |
| 71 | 84 |
| 72 #endif // BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_MANAGER_H_ | 85 #endif // BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_MANAGER_H_ |
| OLD | NEW |