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