Chromium Code Reviews| 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 "blimp/client/core/contents/blimp_contents_impl.h" |
| 9 | 9 |
| 10 namespace blimp { | 10 namespace blimp { |
| 11 namespace client { | 11 namespace client { |
| 12 | 12 |
| 13 class TabControlFeature; | 13 class TabControlFeature; |
| 14 | 14 |
| 15 // BlimpContentsManager does the real work of creating BlimpContentsImpl, and | 15 // BlimpContentsManager does the real work of creating BlimpContentsImpl, and |
| 16 // then passes the ownership to the caller. It also owns the observers to | 16 // then passes the ownership to the caller. It also owns the observers to |
| 17 // monitor the life time of the contents it creates. | 17 // monitor the life time of the contents it creates. |
| 18 class BlimpContentsManager { | 18 class BlimpContentsManager { |
| 19 public: | 19 public: |
| 20 explicit BlimpContentsManager(ImeFeature* ime_feature, | 20 explicit BlimpContentsManager(ImeFeature* ime_feature, |
| 21 NavigationFeature* nav_feature, | 21 NavigationFeature* nav_feature, |
| 22 TabControlFeature* tab_control_feature); | 22 TabControlFeature* tab_control_feature); |
| 23 ~BlimpContentsManager(); | 23 ~BlimpContentsManager(); |
| 24 | 24 |
| 25 // Builds a BlimpContentsImpl and notifies the engine. | 25 // Builds a BlimpContentsImpl and notifies the engine. |
| 26 // Currently we want to have a single BlimpContents. If there is an existing | |
| 27 // contents, return nullptr. | |
| 26 std::unique_ptr<BlimpContentsImpl> CreateBlimpContents(); | 28 std::unique_ptr<BlimpContentsImpl> CreateBlimpContents(); |
| 27 | 29 |
| 28 // The caller can query the contents through its id. | 30 // The caller can query the contents through its id. |
| 29 BlimpContentsImpl* GetBlimpContents(int id); | 31 BlimpContentsImpl* GetBlimpContents(int id); |
| 30 | 32 |
| 31 private: | 33 private: |
| 32 class BlimpContentsDeletionObserver; | 34 class BlimpContentsDeletionObserver; |
| 33 friend class BlimpContentsDeletionObserver; | 35 friend class BlimpContentsDeletionObserver; |
| 34 | 36 |
| 35 // When creating the BlimpContentsImpl, an id is created for the content. | 37 // When creating the BlimpContentsImpl, an id is created for the content. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 48 | 50 |
| 49 // BlimpContentsManager owns the BlimpContentsDeletionObserver for the | 51 // BlimpContentsManager owns the BlimpContentsDeletionObserver for the |
| 50 // contents it creates, with the content id being the key to help manage the | 52 // contents it creates, with the content id being the key to help manage the |
| 51 // lifetime of the observers. | 53 // lifetime of the observers. |
| 52 std::map<int, std::unique_ptr<BlimpContentsDeletionObserver>> observer_map_; | 54 std::map<int, std::unique_ptr<BlimpContentsDeletionObserver>> observer_map_; |
| 53 | 55 |
| 54 ImeFeature* ime_feature_; | 56 ImeFeature* ime_feature_; |
| 55 NavigationFeature* navigation_feature_; | 57 NavigationFeature* navigation_feature_; |
| 56 TabControlFeature* tab_control_feature_; | 58 TabControlFeature* tab_control_feature_; |
| 57 | 59 |
| 60 // TODO(mlliu): Currently we want to have a single BlimpContents. Remove this | |
| 61 // when it supports multiple tabs. | |
| 62 bool tab_exists_ = false; | |
|
David Trainor- moved to gerrit
2016/08/30 23:31:12
Can we just check the map to see if any entries ex
Menglin
2016/08/31 00:13:02
There can be such case: https://codesearch.chromiu
| |
| 63 | |
| 58 base::WeakPtrFactory<BlimpContentsManager> weak_ptr_factory_; | 64 base::WeakPtrFactory<BlimpContentsManager> weak_ptr_factory_; |
| 59 | 65 |
| 60 DISALLOW_COPY_AND_ASSIGN(BlimpContentsManager); | 66 DISALLOW_COPY_AND_ASSIGN(BlimpContentsManager); |
| 61 }; | 67 }; |
| 62 | 68 |
| 63 } // namespace client | 69 } // namespace client |
| 64 } // namespace blimp | 70 } // namespace blimp |
| 65 | 71 |
| 66 #endif // BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_MANAGER_H_ | 72 #endif // BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_MANAGER_H_ |
| OLD | NEW |