| 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 #include "blimp/client/core/contents/blimp_contents_manager.h" | 5 #include "blimp/client/core/contents/blimp_contents_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h" |
| 11 #include "blimp/client/core/contents/blimp_contents_impl.h" |
| 12 #include "blimp/client/core/contents/navigation_feature.h" |
| 10 #include "blimp/client/core/contents/tab_control_feature.h" | 13 #include "blimp/client/core/contents/tab_control_feature.h" |
| 14 #include "blimp/client/core/render_widget/render_widget_feature.h" |
| 11 #include "blimp/client/public/contents/blimp_contents_observer.h" | 15 #include "blimp/client/public/contents/blimp_contents_observer.h" |
| 12 | 16 |
| 13 namespace { | 17 namespace { |
| 14 const int kDummyTabId = 0; | 18 const int kDummyTabId = 0; |
| 15 } | 19 } |
| 16 | 20 |
| 17 namespace blimp { | 21 namespace blimp { |
| 18 namespace client { | 22 namespace client { |
| 19 | 23 |
| 20 class BlimpContentsManager::BlimpContentsDeletionObserver | 24 class BlimpContentsManager::BlimpContentsDeletionObserver |
| (...skipping 17 matching lines...) Expand all Loading... |
| 38 : BlimpContentsObserver(blimp_contents), | 42 : BlimpContentsObserver(blimp_contents), |
| 39 blimp_contents_manager_(blimp_contents_manager) {} | 43 blimp_contents_manager_(blimp_contents_manager) {} |
| 40 | 44 |
| 41 void BlimpContentsManager::BlimpContentsDeletionObserver:: | 45 void BlimpContentsManager::BlimpContentsDeletionObserver:: |
| 42 OnContentsDestroyed() { | 46 OnContentsDestroyed() { |
| 43 BlimpContents* contents = blimp_contents(); | 47 BlimpContents* contents = blimp_contents(); |
| 44 blimp_contents_manager_->OnContentsDestroyed(contents); | 48 blimp_contents_manager_->OnContentsDestroyed(contents); |
| 45 } | 49 } |
| 46 | 50 |
| 47 BlimpContentsManager::BlimpContentsManager( | 51 BlimpContentsManager::BlimpContentsManager( |
| 52 BlimpCompositorDependencies* blimp_compositor_dependencies, |
| 48 ImeFeature* ime_feature, | 53 ImeFeature* ime_feature, |
| 49 NavigationFeature* nav_feature, | 54 NavigationFeature* nav_feature, |
| 55 RenderWidgetFeature* render_widget_feature, |
| 50 TabControlFeature* tab_control_feature) | 56 TabControlFeature* tab_control_feature) |
| 51 : ime_feature_(ime_feature), | 57 : blimp_compositor_dependencies_(blimp_compositor_dependencies), |
| 58 ime_feature_(ime_feature), |
| 52 navigation_feature_(nav_feature), | 59 navigation_feature_(nav_feature), |
| 60 render_widget_feature_(render_widget_feature), |
| 53 tab_control_feature_(tab_control_feature), | 61 tab_control_feature_(tab_control_feature), |
| 54 weak_ptr_factory_(this) {} | 62 weak_ptr_factory_(this) {} |
| 55 | 63 |
| 56 BlimpContentsManager::~BlimpContentsManager() {} | 64 BlimpContentsManager::~BlimpContentsManager() {} |
| 57 | 65 |
| 58 std::unique_ptr<BlimpContentsImpl> BlimpContentsManager::CreateBlimpContents() { | 66 std::unique_ptr<BlimpContentsImpl> BlimpContentsManager::CreateBlimpContents() { |
| 59 int id = CreateBlimpContentsId(); | 67 int id = CreateBlimpContentsId(); |
| 60 | 68 |
| 61 std::unique_ptr<BlimpContentsImpl> new_contents = | 69 std::unique_ptr<BlimpContentsImpl> new_contents = |
| 62 base::MakeUnique<BlimpContentsImpl>(id, ime_feature_, navigation_feature_, | 70 base::MakeUnique<BlimpContentsImpl>( |
| 63 tab_control_feature_); | 71 id, blimp_compositor_dependencies_, ime_feature_, navigation_feature_, |
| 72 render_widget_feature_, tab_control_feature_); |
| 64 | 73 |
| 65 // Create an observer entry for the contents. | 74 // Create an observer entry for the contents. |
| 66 std::unique_ptr<BlimpContentsDeletionObserver> observer = | 75 std::unique_ptr<BlimpContentsDeletionObserver> observer = |
| 67 base::MakeUnique<BlimpContentsDeletionObserver>(this, new_contents.get()); | 76 base::MakeUnique<BlimpContentsDeletionObserver>(this, new_contents.get()); |
| 68 observer_map_.insert( | 77 observer_map_.insert( |
| 69 std::pair<int, std::unique_ptr<BlimpContentsDeletionObserver>>( | 78 std::pair<int, std::unique_ptr<BlimpContentsDeletionObserver>>( |
| 70 id, std::move(observer))); | 79 id, std::move(observer))); |
| 71 | 80 |
| 72 // Notifies the engine that we've created a new BlimpContents. | 81 // Notifies the engine that we've created a new BlimpContents. |
| 73 tab_control_feature_->CreateTab(id); | 82 tab_control_feature_->CreateTab(id); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 FROM_HERE, base::Bind(&BlimpContentsManager::EraseObserverFromMap, | 120 FROM_HERE, base::Bind(&BlimpContentsManager::EraseObserverFromMap, |
| 112 this->GetWeakPtr(), id)); | 121 this->GetWeakPtr(), id)); |
| 113 } | 122 } |
| 114 | 123 |
| 115 base::WeakPtr<BlimpContentsManager> BlimpContentsManager::GetWeakPtr() { | 124 base::WeakPtr<BlimpContentsManager> BlimpContentsManager::GetWeakPtr() { |
| 116 return weak_ptr_factory_.GetWeakPtr(); | 125 return weak_ptr_factory_.GetWeakPtr(); |
| 117 } | 126 } |
| 118 | 127 |
| 119 } // namespace client | 128 } // namespace client |
| 120 } // namespace blimp | 129 } // namespace blimp |
| OLD | NEW |