| 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/tab_control_feature.h" | 9 #include "blimp/client/core/contents/tab_control_feature.h" |
| 10 #include "blimp/client/public/contents/blimp_contents_observer.h" | 10 #include "blimp/client/public/contents/blimp_contents_observer.h" |
| 11 #include "ui/gfx/native_widget_types.h" |
| 11 | 12 |
| 12 #if defined(OS_ANDROID) | 13 #if defined(OS_ANDROID) |
| 13 #include "blimp/client/core/contents/android/blimp_contents_impl_android.h" | 14 #include "blimp/client/core/contents/android/blimp_contents_impl_android.h" |
| 14 #endif // OS_ANDROID | 15 #endif // OS_ANDROID |
| 15 | 16 |
| 16 namespace blimp { | 17 namespace blimp { |
| 17 namespace client { | 18 namespace client { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 #if defined(OS_ANDROID) | 22 #if defined(OS_ANDROID) |
| 22 const char kBlimpContentsImplAndroidKey[] = "blimp_contents_impl_android"; | 23 const char kBlimpContentsImplAndroidKey[] = "blimp_contents_impl_android"; |
| 23 #endif // OS_ANDROID | 24 #endif // OS_ANDROID |
| 24 } | 25 } |
| 25 | 26 |
| 26 BlimpContentsImpl::BlimpContentsImpl(int id, | 27 BlimpContentsImpl::BlimpContentsImpl(int id, |
| 28 gfx::NativeWindow window, |
| 27 ImeFeature* ime_feature, | 29 ImeFeature* ime_feature, |
| 28 NavigationFeature* navigation_feature, | 30 NavigationFeature* navigation_feature, |
| 29 TabControlFeature* tab_control_feature) | 31 TabControlFeature* tab_control_feature) |
| 30 : navigation_controller_(this, navigation_feature), | 32 : navigation_controller_(this, navigation_feature), |
| 31 id_(id), | 33 id_(id), |
| 34 window_(window), |
| 32 tab_control_feature_(tab_control_feature) {} | 35 tab_control_feature_(tab_control_feature) {} |
| 33 | 36 |
| 34 BlimpContentsImpl::~BlimpContentsImpl() { | 37 BlimpContentsImpl::~BlimpContentsImpl() { |
| 35 FOR_EACH_OBSERVER(BlimpContentsObserver, observers_, BlimpContentsDying()); | 38 FOR_EACH_OBSERVER(BlimpContentsObserver, observers_, BlimpContentsDying()); |
| 36 } | 39 } |
| 37 | 40 |
| 38 #if defined(OS_ANDROID) | 41 #if defined(OS_ANDROID) |
| 39 | 42 |
| 40 base::android::ScopedJavaLocalRef<jobject> BlimpContentsImpl::GetJavaObject() { | 43 base::android::ScopedJavaLocalRef<jobject> BlimpContentsImpl::GetJavaObject() { |
| 41 return GetBlimpContentsImplAndroid()->GetJavaObject(); | 44 return GetBlimpContentsImplAndroid()->GetJavaObject(); |
| 42 } | 45 } |
| 43 | 46 |
| 44 BlimpContentsImplAndroid* BlimpContentsImpl::GetBlimpContentsImplAndroid() { | 47 BlimpContentsImplAndroid* BlimpContentsImpl::GetBlimpContentsImplAndroid() { |
| 45 BlimpContentsImplAndroid* blimp_contents_impl_android = | 48 BlimpContentsImplAndroid* blimp_contents_impl_android = |
| 46 static_cast<BlimpContentsImplAndroid*>( | 49 static_cast<BlimpContentsImplAndroid*>( |
| 47 GetUserData(kBlimpContentsImplAndroidKey)); | 50 GetUserData(kBlimpContentsImplAndroidKey)); |
| 48 if (!blimp_contents_impl_android) { | 51 if (!blimp_contents_impl_android) { |
| 49 blimp_contents_impl_android = new BlimpContentsImplAndroid(this); | 52 blimp_contents_impl_android = new BlimpContentsImplAndroid(this); |
| 50 SetUserData(kBlimpContentsImplAndroidKey, blimp_contents_impl_android); | 53 SetUserData(kBlimpContentsImplAndroidKey, blimp_contents_impl_android); |
| 51 } | 54 } |
| 52 return blimp_contents_impl_android; | 55 return blimp_contents_impl_android; |
| 53 } | 56 } |
| 54 | 57 |
| 55 #endif // defined(OS_ANDROID) | 58 #endif // defined(OS_ANDROID) |
| 56 | 59 |
| 57 BlimpNavigationControllerImpl& BlimpContentsImpl::GetNavigationController() { | 60 BlimpNavigationControllerImpl& BlimpContentsImpl::GetNavigationController() { |
| 58 return navigation_controller_; | 61 return navigation_controller_; |
| 59 } | 62 } |
| 60 | 63 |
| 64 gfx::NativeWindow BlimpContentsImpl::GetNativeWindow() { |
| 65 return window_; |
| 66 } |
| 67 |
| 61 void BlimpContentsImpl::AddObserver(BlimpContentsObserver* observer) { | 68 void BlimpContentsImpl::AddObserver(BlimpContentsObserver* observer) { |
| 62 observers_.AddObserver(observer); | 69 observers_.AddObserver(observer); |
| 63 } | 70 } |
| 64 | 71 |
| 65 void BlimpContentsImpl::RemoveObserver(BlimpContentsObserver* observer) { | 72 void BlimpContentsImpl::RemoveObserver(BlimpContentsObserver* observer) { |
| 66 observers_.RemoveObserver(observer); | 73 observers_.RemoveObserver(observer); |
| 67 } | 74 } |
| 68 | 75 |
| 69 bool BlimpContentsImpl::HasObserver(BlimpContentsObserver* observer) { | 76 bool BlimpContentsImpl::HasObserver(BlimpContentsObserver* observer) { |
| 70 return observers_.HasObserver(observer); | 77 return observers_.HasObserver(observer); |
| 71 } | 78 } |
| 72 | 79 |
| 73 void BlimpContentsImpl::OnNavigationStateChanged() { | 80 void BlimpContentsImpl::OnNavigationStateChanged() { |
| 74 FOR_EACH_OBSERVER(BlimpContentsObserver, observers_, | 81 FOR_EACH_OBSERVER(BlimpContentsObserver, observers_, |
| 75 OnNavigationStateChanged()); | 82 OnNavigationStateChanged()); |
| 76 } | 83 } |
| 77 | 84 |
| 78 void BlimpContentsImpl::SetSizeAndScale(const gfx::Size& size, | 85 void BlimpContentsImpl::SetSizeAndScale(const gfx::Size& size, |
| 79 float device_pixel_ratio) { | 86 float device_pixel_ratio) { |
| 80 tab_control_feature_->SetSizeAndScale(size, device_pixel_ratio); | 87 tab_control_feature_->SetSizeAndScale(size, device_pixel_ratio); |
| 81 } | 88 } |
| 82 | 89 |
| 83 } // namespace client | 90 } // namespace client |
| 84 } // namespace blimp | 91 } // namespace blimp |
| OLD | NEW |