| 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_IMPL_H_ | 5 #ifndef BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_IMPL_H_ |
| 6 #define BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_IMPL_H_ | 6 #define BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "blimp/client/core/contents/blimp_navigation_controller_delegate.h" | 10 #include "blimp/client/core/contents/blimp_navigation_controller_delegate.h" |
| 11 #include "blimp/client/core/contents/blimp_navigation_controller_impl.h" | 11 #include "blimp/client/core/contents/blimp_navigation_controller_impl.h" |
| 12 #include "blimp/client/public/contents/blimp_contents.h" | 12 #include "blimp/client/public/contents/blimp_contents.h" |
| 13 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 14 #include "ui/gfx/native_widget_types.h" |
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 15 | 16 |
| 16 #if defined(OS_ANDROID) | 17 #if defined(OS_ANDROID) |
| 17 #include "base/android/scoped_java_ref.h" | 18 #include "base/android/scoped_java_ref.h" |
| 18 #endif // defined(OS_ANDROID) | 19 #endif // defined(OS_ANDROID) |
| 19 | 20 |
| 20 namespace blimp { | 21 namespace blimp { |
| 21 namespace client { | 22 namespace client { |
| 22 | 23 |
| 23 #if defined(OS_ANDROID) | 24 #if defined(OS_ANDROID) |
| 24 class BlimpContentsImplAndroid; | 25 class BlimpContentsImplAndroid; |
| 25 #endif // defined(OS_ANDROID) | 26 #endif // defined(OS_ANDROID) |
| 26 | 27 |
| 27 class BlimpContentsObserver; | 28 class BlimpContentsObserver; |
| 28 class BlimpContentsView; | 29 class BlimpContentsView; |
| 29 class BlimpNavigationController; | 30 class BlimpNavigationController; |
| 30 class ImeFeature; | 31 class ImeFeature; |
| 31 class NavigationFeature; | 32 class NavigationFeature; |
| 32 class TabControlFeature; | 33 class TabControlFeature; |
| 33 | 34 |
| 34 class BlimpContentsImpl : public BlimpContents, | 35 class BlimpContentsImpl : public BlimpContents, |
| 35 public BlimpNavigationControllerDelegate { | 36 public BlimpNavigationControllerDelegate { |
| 36 public: | 37 public: |
| 37 // Ownership of the features remains with the caller. | 38 // Ownership of the features remains with the caller. |
| 39 // |window| must be the platform specific window that this will be shown in. |
| 38 explicit BlimpContentsImpl(int id, | 40 explicit BlimpContentsImpl(int id, |
| 41 gfx::NativeWindow window, |
| 39 ImeFeature* ime_feature, | 42 ImeFeature* ime_feature, |
| 40 NavigationFeature* navigation_feature, | 43 NavigationFeature* navigation_feature, |
| 41 TabControlFeature* tab_control_feature); | 44 TabControlFeature* tab_control_feature); |
| 42 ~BlimpContentsImpl() override; | 45 ~BlimpContentsImpl() override; |
| 43 | 46 |
| 44 #if defined(OS_ANDROID) | 47 #if defined(OS_ANDROID) |
| 45 base::android::ScopedJavaLocalRef<jobject> GetJavaObject() override; | 48 base::android::ScopedJavaLocalRef<jobject> GetJavaObject() override; |
| 46 BlimpContentsImplAndroid* GetBlimpContentsImplAndroid(); | 49 BlimpContentsImplAndroid* GetBlimpContentsImplAndroid(); |
| 47 #endif // defined(OS_ANDROID) | 50 #endif // defined(OS_ANDROID) |
| 48 | 51 |
| 49 // BlimpContents implementation. | 52 // BlimpContents implementation. |
| 50 BlimpNavigationControllerImpl& GetNavigationController() override; | 53 BlimpNavigationControllerImpl& GetNavigationController() override; |
| 51 void AddObserver(BlimpContentsObserver* observer) override; | 54 void AddObserver(BlimpContentsObserver* observer) override; |
| 52 void RemoveObserver(BlimpContentsObserver* observer) override; | 55 void RemoveObserver(BlimpContentsObserver* observer) override; |
| 53 gfx::NativeView GetNativeView() override; | 56 gfx::NativeView GetNativeView() override; |
| 54 | 57 |
| 58 // Returns the platform specific window that this BlimpContents is showed in. |
| 59 gfx::NativeWindow GetNativeWindow(); |
| 60 |
| 55 // Check if some observer is in the observer list. | 61 // Check if some observer is in the observer list. |
| 56 bool HasObserver(BlimpContentsObserver* observer); | 62 bool HasObserver(BlimpContentsObserver* observer); |
| 57 | 63 |
| 58 // BlimpNavigationControllerDelegate implementation. | 64 // BlimpNavigationControllerDelegate implementation. |
| 59 void OnNavigationStateChanged() override; | 65 void OnNavigationStateChanged() override; |
| 60 | 66 |
| 61 // Pushes the size and scale information to the engine, which will affect the | 67 // Pushes the size and scale information to the engine, which will affect the |
| 62 // web content display area for all tabs. | 68 // web content display area for all tabs. |
| 63 void SetSizeAndScale(const gfx::Size& size, float device_pixel_ratio); | 69 void SetSizeAndScale(const gfx::Size& size, float device_pixel_ratio); |
| 64 | 70 |
| 65 int id() { return id_; } | 71 int id() { return id_; } |
| 66 | 72 |
| 73 // Returns the BlimpContentsView for this BlimpContentsImpl. |
| 74 BlimpContentsView* GetBlimpContentsView(); |
| 75 |
| 67 private: | 76 private: |
| 68 // Handles the back/forward list and loading URLs. | 77 // Handles the back/forward list and loading URLs. |
| 69 BlimpNavigationControllerImpl navigation_controller_; | 78 BlimpNavigationControllerImpl navigation_controller_; |
| 70 | 79 |
| 71 // A list of all the observers of this BlimpContentsImpl. | 80 // A list of all the observers of this BlimpContentsImpl. |
| 72 base::ObserverList<BlimpContentsObserver> observers_; | 81 base::ObserverList<BlimpContentsObserver> observers_; |
| 73 | 82 |
| 74 // The id is assigned during contents creation. It is used by | 83 // The id is assigned during contents creation. It is used by |
| 75 // BlimpContentsManager to control the life time of the its observer. | 84 // BlimpContentsManager to control the life time of the its observer. |
| 76 int id_; | 85 int id_; |
| 77 | 86 |
| 87 // The platform specific window that this BlimpContents is showed in. |
| 88 gfx::NativeWindow window_; |
| 89 |
| 78 // The tab control feature through which the BlimpContentsImpl is able to | 90 // The tab control feature through which the BlimpContentsImpl is able to |
| 79 // set size and scale. | 91 // set size and scale. |
| 80 // TODO(mlliu): in the long term, we want to put size and scale in a different | 92 // TODO(mlliu): in the long term, we want to put size and scale in a different |
| 81 // feature instead of tab control feature. crbug.com/639154. | 93 // feature instead of tab control feature. crbug.com/639154. |
| 82 TabControlFeature* tab_control_feature_ = nullptr; | 94 TabControlFeature* tab_control_feature_ = nullptr; |
| 83 | 95 |
| 84 // The BlimpContentsView abstracts the platform specific view system details | 96 // The BlimpContentsView abstracts the platform specific view system details |
| 85 // from the BlimpContents. | 97 // from the BlimpContents. |
| 86 std::unique_ptr<BlimpContentsView> blimp_contents_view_; | 98 std::unique_ptr<BlimpContentsView> blimp_contents_view_; |
| 87 | 99 |
| 88 DISALLOW_COPY_AND_ASSIGN(BlimpContentsImpl); | 100 DISALLOW_COPY_AND_ASSIGN(BlimpContentsImpl); |
| 89 }; | 101 }; |
| 90 | 102 |
| 91 } // namespace client | 103 } // namespace client |
| 92 } // namespace blimp | 104 } // namespace blimp |
| 93 | 105 |
| 94 #endif // BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_IMPL_H_ | 106 #endif // BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_IMPL_H_ |
| OLD | NEW |