| 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_impl.h" | 5 #include "blimp/client/core/contents/blimp_contents_impl.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/supports_user_data.h" | 8 #include "base/supports_user_data.h" |
| 9 #include "blimp/client/core/contents/blimp_contents_view.h" | 9 #include "blimp/client/core/contents/blimp_contents_view.h" |
| 10 #include "blimp/client/core/contents/tab_control_feature.h" | 10 #include "blimp/client/core/contents/tab_control_feature.h" |
| 11 #include "blimp/client/public/contents/blimp_contents_observer.h" | 11 #include "blimp/client/public/contents/blimp_contents_observer.h" |
| 12 #include "ui/gfx/native_widget_types.h" |
| 12 | 13 |
| 13 #if defined(OS_ANDROID) | 14 #if defined(OS_ANDROID) |
| 14 #include "blimp/client/core/contents/android/blimp_contents_impl_android.h" | 15 #include "blimp/client/core/contents/android/blimp_contents_impl_android.h" |
| 15 #endif // OS_ANDROID | 16 #endif // OS_ANDROID |
| 16 | 17 |
| 17 namespace blimp { | 18 namespace blimp { |
| 18 namespace client { | 19 namespace client { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 #if defined(OS_ANDROID) | 23 #if defined(OS_ANDROID) |
| 23 const char kBlimpContentsImplAndroidKey[] = "blimp_contents_impl_android"; | 24 const char kBlimpContentsImplAndroidKey[] = "blimp_contents_impl_android"; |
| 24 #endif // OS_ANDROID | 25 #endif // OS_ANDROID |
| 25 } | 26 } |
| 26 | 27 |
| 27 BlimpContentsImpl::BlimpContentsImpl(int id, | 28 BlimpContentsImpl::BlimpContentsImpl(int id, |
| 29 gfx::NativeWindow window, |
| 28 ImeFeature* ime_feature, | 30 ImeFeature* ime_feature, |
| 29 NavigationFeature* navigation_feature, | 31 NavigationFeature* navigation_feature, |
| 30 TabControlFeature* tab_control_feature) | 32 TabControlFeature* tab_control_feature) |
| 31 : navigation_controller_(this, navigation_feature), | 33 : navigation_controller_(this, navigation_feature), |
| 32 id_(id), | 34 id_(id), |
| 35 window_(window), |
| 33 tab_control_feature_(tab_control_feature) { | 36 tab_control_feature_(tab_control_feature) { |
| 34 blimp_contents_view_ = BlimpContentsView::Create(this); | 37 blimp_contents_view_ = BlimpContentsView::Create(this); |
| 35 } | 38 } |
| 36 | 39 |
| 37 BlimpContentsImpl::~BlimpContentsImpl() { | 40 BlimpContentsImpl::~BlimpContentsImpl() { |
| 38 FOR_EACH_OBSERVER(BlimpContentsObserver, observers_, BlimpContentsDying()); | 41 FOR_EACH_OBSERVER(BlimpContentsObserver, observers_, BlimpContentsDying()); |
| 39 } | 42 } |
| 40 | 43 |
| 41 #if defined(OS_ANDROID) | 44 #if defined(OS_ANDROID) |
| 42 | 45 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 54 } | 57 } |
| 55 return blimp_contents_impl_android; | 58 return blimp_contents_impl_android; |
| 56 } | 59 } |
| 57 | 60 |
| 58 #endif // defined(OS_ANDROID) | 61 #endif // defined(OS_ANDROID) |
| 59 | 62 |
| 60 BlimpNavigationControllerImpl& BlimpContentsImpl::GetNavigationController() { | 63 BlimpNavigationControllerImpl& BlimpContentsImpl::GetNavigationController() { |
| 61 return navigation_controller_; | 64 return navigation_controller_; |
| 62 } | 65 } |
| 63 | 66 |
| 67 gfx::NativeWindow BlimpContentsImpl::GetNativeWindow() { |
| 68 return window_; |
| 69 } |
| 70 |
| 64 void BlimpContentsImpl::AddObserver(BlimpContentsObserver* observer) { | 71 void BlimpContentsImpl::AddObserver(BlimpContentsObserver* observer) { |
| 65 observers_.AddObserver(observer); | 72 observers_.AddObserver(observer); |
| 66 } | 73 } |
| 67 | 74 |
| 68 void BlimpContentsImpl::RemoveObserver(BlimpContentsObserver* observer) { | 75 void BlimpContentsImpl::RemoveObserver(BlimpContentsObserver* observer) { |
| 69 observers_.RemoveObserver(observer); | 76 observers_.RemoveObserver(observer); |
| 70 } | 77 } |
| 71 | 78 |
| 72 gfx::NativeView BlimpContentsImpl::GetNativeView() { | 79 gfx::NativeView BlimpContentsImpl::GetNativeView() { |
| 73 return blimp_contents_view_->GetNativeView(); | 80 return blimp_contents_view_->GetNativeView(); |
| 74 } | 81 } |
| 75 | 82 |
| 76 bool BlimpContentsImpl::HasObserver(BlimpContentsObserver* observer) { | 83 bool BlimpContentsImpl::HasObserver(BlimpContentsObserver* observer) { |
| 77 return observers_.HasObserver(observer); | 84 return observers_.HasObserver(observer); |
| 78 } | 85 } |
| 79 | 86 |
| 80 void BlimpContentsImpl::OnNavigationStateChanged() { | 87 void BlimpContentsImpl::OnNavigationStateChanged() { |
| 81 FOR_EACH_OBSERVER(BlimpContentsObserver, observers_, | 88 FOR_EACH_OBSERVER(BlimpContentsObserver, observers_, |
| 82 OnNavigationStateChanged()); | 89 OnNavigationStateChanged()); |
| 83 } | 90 } |
| 84 | 91 |
| 85 void BlimpContentsImpl::SetSizeAndScale(const gfx::Size& size, | 92 void BlimpContentsImpl::SetSizeAndScale(const gfx::Size& size, |
| 86 float device_pixel_ratio) { | 93 float device_pixel_ratio) { |
| 87 tab_control_feature_->SetSizeAndScale(size, device_pixel_ratio); | 94 tab_control_feature_->SetSizeAndScale(size, device_pixel_ratio); |
| 88 } | 95 } |
| 89 | 96 |
| 97 BlimpContentsView* BlimpContentsImpl::GetBlimpContentsView() { |
| 98 return blimp_contents_view_.get(); |
| 99 } |
| 100 |
| 90 } // namespace client | 101 } // namespace client |
| 91 } // namespace blimp | 102 } // namespace blimp |
| OLD | NEW |