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