| 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 if (tab_exists_) return nullptr; | 67 if (tab_exists_) return nullptr; |
| 60 tab_exists_ = true; | 68 tab_exists_ = true; |
| 61 | 69 |
| 62 int id = CreateBlimpContentsId(); | 70 int id = CreateBlimpContentsId(); |
| 63 | 71 |
| 64 std::unique_ptr<BlimpContentsImpl> new_contents = | 72 std::unique_ptr<BlimpContentsImpl> new_contents = |
| 65 base::MakeUnique<BlimpContentsImpl>(id, ime_feature_, navigation_feature_, | 73 base::MakeUnique<BlimpContentsImpl>( |
| 66 tab_control_feature_); | 74 id, blimp_compositor_dependencies_, ime_feature_, navigation_feature_, |
| 75 render_widget_feature_, tab_control_feature_); |
| 67 | 76 |
| 68 // Create an observer entry for the contents. | 77 // Create an observer entry for the contents. |
| 69 std::unique_ptr<BlimpContentsDeletionObserver> observer = | 78 std::unique_ptr<BlimpContentsDeletionObserver> observer = |
| 70 base::MakeUnique<BlimpContentsDeletionObserver>(this, new_contents.get()); | 79 base::MakeUnique<BlimpContentsDeletionObserver>(this, new_contents.get()); |
| 71 observer_map_.insert( | 80 observer_map_.insert( |
| 72 std::pair<int, std::unique_ptr<BlimpContentsDeletionObserver>>( | 81 std::pair<int, std::unique_ptr<BlimpContentsDeletionObserver>>( |
| 73 id, std::move(observer))); | 82 id, std::move(observer))); |
| 74 | 83 |
| 75 // Notifies the engine that we've created a new BlimpContents. | 84 // Notifies the engine that we've created a new BlimpContents. |
| 76 tab_control_feature_->CreateTab(id); | 85 tab_control_feature_->CreateTab(id); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 FROM_HERE, base::Bind(&BlimpContentsManager::EraseObserverFromMap, | 126 FROM_HERE, base::Bind(&BlimpContentsManager::EraseObserverFromMap, |
| 118 this->GetWeakPtr(), id)); | 127 this->GetWeakPtr(), id)); |
| 119 } | 128 } |
| 120 | 129 |
| 121 base::WeakPtr<BlimpContentsManager> BlimpContentsManager::GetWeakPtr() { | 130 base::WeakPtr<BlimpContentsManager> BlimpContentsManager::GetWeakPtr() { |
| 122 return weak_ptr_factory_.GetWeakPtr(); | 131 return weak_ptr_factory_.GetWeakPtr(); |
| 123 } | 132 } |
| 124 | 133 |
| 125 } // namespace client | 134 } // namespace client |
| 126 } // namespace blimp | 135 } // namespace blimp |
| OLD | NEW |