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/core/render_widget/blimp_render_widget_delegate.h" |
| 13 #include "blimp/client/core/render_widget/render_widget_feature.h" |
12 #include "blimp/client/public/contents/blimp_contents.h" | 14 #include "blimp/client/public/contents/blimp_contents.h" |
| 15 #include "ui/gfx/native_widget_types.h" |
13 #include "url/gurl.h" | 16 #include "url/gurl.h" |
14 | 17 |
15 #if defined(OS_ANDROID) | 18 #if defined(OS_ANDROID) |
16 #include "base/android/scoped_java_ref.h" | 19 #include "base/android/scoped_java_ref.h" |
17 #endif // defined(OS_ANDROID) | 20 #endif // defined(OS_ANDROID) |
18 | 21 |
19 namespace blimp { | 22 namespace blimp { |
20 namespace client { | 23 namespace client { |
21 | 24 |
22 #if defined(OS_ANDROID) | 25 #if defined(OS_ANDROID) |
23 class BlimpContentsImplAndroid; | 26 class BlimpContentsImplAndroid; |
24 #endif // defined(OS_ANDROID) | 27 #endif // defined(OS_ANDROID) |
25 | 28 |
26 class BlimpContentsObserver; | 29 class BlimpContentsObserver; |
27 class BlimpNavigationController; | 30 class BlimpNavigationController; |
| 31 class CompositorDepsProvider; |
| 32 class RenderWidgetFeature; |
28 | 33 |
29 class BlimpContentsImpl : public BlimpContents, | 34 // BlimpContentsImpl is the implementation of the core class in |
30 public BlimpNavigationControllerDelegate { | 35 // //blimp/client/core, the BlimpContents. |
| 36 class BlimpContentsImpl |
| 37 : public BlimpContents, |
| 38 public BlimpNavigationControllerDelegate, |
| 39 public BlimpRenderWidgetDelegate, |
| 40 public RenderWidgetFeature::RenderWidgetFeatureDelegate { |
31 public: | 41 public: |
32 explicit BlimpContentsImpl(int id); | 42 BlimpContentsImpl(int id, RenderWidgetFeature* render_widget_feature); |
33 ~BlimpContentsImpl() override; | 43 ~BlimpContentsImpl() override; |
34 | 44 |
35 #if defined(OS_ANDROID) | 45 #if defined(OS_ANDROID) |
36 base::android::ScopedJavaLocalRef<jobject> GetJavaBlimpContentsImpl(); | 46 base::android::ScopedJavaLocalRef<jobject> GetJavaBlimpContentsImpl(); |
37 BlimpContentsImplAndroid* GetBlimpContentsImplAndroid(); | 47 BlimpContentsImplAndroid* GetBlimpContentsImplAndroid(); |
38 #endif // defined(OS_ANDROID) | 48 #endif // defined(OS_ANDROID) |
39 | 49 |
40 // BlimpContents implementation. | 50 // BlimpContents implementation. |
41 BlimpNavigationControllerImpl& GetNavigationController() override; | 51 BlimpNavigationControllerImpl& GetNavigationController() override; |
42 void AddObserver(BlimpContentsObserver* observer) override; | 52 void AddObserver(BlimpContentsObserver* observer) override; |
43 void RemoveObserver(BlimpContentsObserver* observer) override; | 53 void RemoveObserver(BlimpContentsObserver* observer) override; |
| 54 void SetVisible(bool visible) override; |
44 | 55 |
45 // Check if some observer is in the observer list. | 56 // Check if some observer is in the observer list. |
46 bool HasObserver(BlimpContentsObserver* observer); | 57 bool HasObserver(BlimpContentsObserver* observer); |
47 | 58 |
48 // BlimpNavigationControllerDelegate implementation. | 59 // BlimpNavigationControllerDelegate implementation. |
49 void OnNavigationStateChanged() override; | 60 void OnNavigationStateChanged() override; |
50 | 61 |
51 int id() { return id_; } | 62 int id() { return id_; } |
52 | 63 |
| 64 // BlimpRenderWidgetDelegate implementation. |
| 65 void SendWebGestureEvent( |
| 66 BlimpRenderWidget* render_widget, |
| 67 const blink::WebGestureEvent& gesture_event) override; |
| 68 void SendCompositorMessage( |
| 69 BlimpRenderWidget* render_widget, |
| 70 const cc::proto::CompositorMessage& message) override; |
| 71 void CompositorDidCompleteSwapBuffers() override; |
| 72 |
| 73 // RenderWidgetFeatureDelegate implementation. |
| 74 void OnRenderWidgetCreated(int render_widget_id) override; |
| 75 void OnRenderWidgetInitialized(int render_widget_id) override; |
| 76 void OnRenderWidgetDeleted(int render_widget_id) override; |
| 77 void OnCompositorMessageReceived( |
| 78 int render_widget_id, |
| 79 std::unique_ptr<cc::proto::CompositorMessage> message) override; |
| 80 |
| 81 void SetAcceleratedWidget(gfx::AcceleratedWidget widget); |
| 82 |
| 83 void set_did_complete_swap_buffers_callback(base::Closure callback) { |
| 84 did_complete_swap_buffers_ = callback; |
| 85 } |
| 86 |
| 87 // Returns the currently active widget that holds the content for this |
| 88 // BlimpContents. Can be null. |
| 89 BlimpRenderWidget* GetActiveWidget() const; |
| 90 |
| 91 // Returns the widget for the |render_widget_id|. Will return nullptr if |
| 92 // no widget is found. |
| 93 BlimpRenderWidget* GetWidgetForId(int render_widget_id); |
| 94 |
| 95 protected: |
| 96 // virtual for testing. |
| 97 virtual std::unique_ptr<BlimpRenderWidget> CreateBlimpRenderWidget( |
| 98 int32_t render_widget_id, |
| 99 BlimpRenderWidgetDelegate* delegate); |
| 100 |
53 private: | 101 private: |
| 102 // The id is assigned during contents creation. It is used by |
| 103 // BlimpContentsManager to control the life time of the its observer. |
| 104 int id_; |
| 105 |
| 106 // The bridge to the network layer that does the proto/RenderWidget id work. |
| 107 // TODO(mlliu): Should move this to BlimpContentsManager when its ready. |
| 108 RenderWidgetFeature* render_widget_feature_; |
| 109 |
| 110 bool visible_; |
| 111 gfx::AcceleratedWidget window_; |
| 112 |
| 113 base::Closure did_complete_swap_buffers_; |
| 114 |
| 115 // A map of render_widget_ids to the BlimpRenderWidget instance. |
| 116 typedef std::map<int, std::unique_ptr<BlimpRenderWidget>> RenderWidgetMap; |
| 117 RenderWidgetMap render_widgets_; |
| 118 |
| 119 // The |active_widget_| represents the widget from the RenderWidgetMap |
| 120 // that is currently visible. It corresponds to the render widget currently |
| 121 // initialized on the engine. |
| 122 BlimpRenderWidget* active_widget_; |
| 123 |
54 // Handles the back/forward list and loading URLs. | 124 // Handles the back/forward list and loading URLs. |
55 BlimpNavigationControllerImpl navigation_controller_; | 125 BlimpNavigationControllerImpl navigation_controller_; |
56 | 126 |
57 // A list of all the observers of this BlimpContentsImpl. | 127 // A list of all the observers of this BlimpContentsImpl. |
58 base::ObserverList<BlimpContentsObserver> observers_; | 128 base::ObserverList<BlimpContentsObserver> observers_; |
59 | 129 |
60 // The id is assigned during contents creation. It is used by | |
61 // BlimpContentsManager to control the life time of the its observer. | |
62 int id_; | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(BlimpContentsImpl); | 130 DISALLOW_COPY_AND_ASSIGN(BlimpContentsImpl); |
65 }; | 131 }; |
66 | 132 |
67 } // namespace client | 133 } // namespace client |
68 } // namespace blimp | 134 } // namespace blimp |
69 | 135 |
70 #endif // BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_IMPL_H_ | 136 #endif // BLIMP_CLIENT_CORE_CONTENTS_BLIMP_CONTENTS_IMPL_H_ |
OLD | NEW |