| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_CAST_H_ |
| 6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_CAST_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 8 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 10 #include "content/common/content_export.h" | |
| 11 #include "ui/gfx/native_widget_types.h" | |
| 12 #include "ui/gfx/rect.h" | 9 #include "ui/gfx/rect.h" |
| 13 | 10 |
| 11 struct AccessibilityHostMsg_EventParams; |
| 12 |
| 13 namespace gfx { |
| 14 namespace chromecast { |
| 15 class Surface; |
| 16 } // namespace chromecast |
| 17 } // namespace gfx |
| 18 |
| 14 namespace content { | 19 namespace content { |
| 15 class CrossProcessFrameConnector; | |
| 16 class RenderWidgetHost; | |
| 17 class RenderWidgetHostImpl; | 20 class RenderWidgetHostImpl; |
| 18 | 21 |
| 19 // RenderWidgetHostViewChildFrame implements the view for a RenderWidgetHost | 22 //----------------------------------------------------------------------------- |
| 20 // associated with content being rendered in a separate process from | |
| 21 // content that is embedding it. This is not a platform-specific class; rather, | |
| 22 // the embedding renderer process implements the platform containing the | |
| 23 // widget, and the top-level frame's RenderWidgetHostView will ultimately | |
| 24 // manage all native widget interaction. | |
| 25 // | |
| 26 // See comments in render_widget_host_view.h about this class and its members. | 23 // See comments in render_widget_host_view.h about this class and its members. |
| 27 class CONTENT_EXPORT RenderWidgetHostViewChildFrame | 24 // ----------------------------------------------------------------------------- |
| 28 : public RenderWidgetHostViewBase { | 25 class RenderWidgetHostViewCast : public RenderWidgetHostViewBase { |
| 29 public: | 26 public: |
| 30 explicit RenderWidgetHostViewChildFrame(RenderWidgetHost* widget); | 27 virtual ~RenderWidgetHostViewCast(); |
| 31 virtual ~RenderWidgetHostViewChildFrame(); | |
| 32 | |
| 33 void set_cross_process_frame_connector( | |
| 34 CrossProcessFrameConnector* frame_connector) { | |
| 35 frame_connector_ = frame_connector; | |
| 36 } | |
| 37 | 28 |
| 38 // RenderWidgetHostView implementation. | 29 // RenderWidgetHostView implementation. |
| 39 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; | 30 virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE; |
| 40 virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; | 31 virtual RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE; |
| 41 virtual void SetSize(const gfx::Size& size) OVERRIDE; | 32 virtual void SetSize(const gfx::Size& size) OVERRIDE; |
| 42 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; | 33 virtual void SetBounds(const gfx::Rect& rect) OVERRIDE; |
| 43 virtual void Focus() OVERRIDE; | 34 virtual gfx::NativeView GetNativeView() const OVERRIDE; |
| 35 virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; |
| 36 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; |
| 44 virtual bool HasFocus() const OVERRIDE; | 37 virtual bool HasFocus() const OVERRIDE; |
| 45 virtual bool IsSurfaceAvailableForCopy() const OVERRIDE; | 38 virtual bool IsSurfaceAvailableForCopy() const OVERRIDE; |
| 46 virtual void Show() OVERRIDE; | 39 virtual void Show() OVERRIDE; |
| 47 virtual void Hide() OVERRIDE; | 40 virtual void Hide() OVERRIDE; |
| 48 virtual bool IsShowing() OVERRIDE; | 41 virtual bool IsShowing() OVERRIDE; |
| 49 virtual gfx::Rect GetViewBounds() const OVERRIDE; | 42 virtual gfx::Rect GetViewBounds() const OVERRIDE; |
| 50 virtual gfx::NativeView GetNativeView() const OVERRIDE; | |
| 51 virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE; | |
| 52 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; | |
| 53 virtual void SetBackground(const SkBitmap& background) OVERRIDE; | 43 virtual void SetBackground(const SkBitmap& background) OVERRIDE; |
| 54 virtual gfx::Size GetPhysicalBackingSize() const OVERRIDE; | |
| 55 | 44 |
| 56 // RenderWidgetHostViewPort implementation. | 45 // RenderWidgetHostViewPort implementation. |
| 57 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, | 46 virtual void InitAsPopup(RenderWidgetHostView* parent_host_view, |
| 58 const gfx::Rect& pos) OVERRIDE; | 47 const gfx::Rect& pos) OVERRIDE; |
| 59 virtual void InitAsFullscreen( | 48 virtual void InitAsFullscreen( |
| 60 RenderWidgetHostView* reference_host_view) OVERRIDE; | 49 RenderWidgetHostView* reference_host_view) OVERRIDE; |
| 61 virtual void WasShown() OVERRIDE; | 50 virtual void WasShown() OVERRIDE; |
| 62 virtual void WasHidden() OVERRIDE; | 51 virtual void WasHidden() OVERRIDE; |
| 63 virtual void MovePluginWindows( | 52 virtual void MovePluginWindows( |
| 64 const gfx::Vector2d& scroll_offset, | 53 const gfx::Vector2d& scroll_offset, |
| 65 const std::vector<WebPluginGeometry>& moves) OVERRIDE; | 54 const std::vector<WebPluginGeometry>& moves) OVERRIDE; |
| 55 virtual void Focus() OVERRIDE; |
| 66 virtual void Blur() OVERRIDE; | 56 virtual void Blur() OVERRIDE; |
| 67 virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; | 57 virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; |
| 68 virtual void SetIsLoading(bool is_loading) OVERRIDE; | 58 virtual void SetIsLoading(bool is_loading) OVERRIDE; |
| 69 virtual void TextInputTypeChanged(ui::TextInputType type, | 59 virtual void TextInputTypeChanged(ui::TextInputType type, |
| 70 ui::TextInputMode input_mode, | 60 ui::TextInputMode mode, |
| 71 bool can_compose_inline) OVERRIDE; | 61 bool can_compose_inline) OVERRIDE; |
| 72 virtual void ImeCancelComposition() OVERRIDE; | 62 virtual void ImeCancelComposition() OVERRIDE; |
| 73 #if defined(OS_MACOSX) || defined(USE_AURA) | |
| 74 virtual void ImeCompositionRangeChanged( | |
| 75 const gfx::Range& range, | |
| 76 const std::vector<gfx::Rect>& character_bounds) OVERRIDE; | |
| 77 #endif | |
| 78 virtual void DidUpdateBackingStore( | 63 virtual void DidUpdateBackingStore( |
| 79 const gfx::Rect& scroll_rect, | 64 const gfx::Rect& scroll_rect, |
| 80 const gfx::Vector2d& scroll_delta, | 65 const gfx::Vector2d& scroll_delta, |
| 81 const std::vector<gfx::Rect>& copy_rects, | 66 const std::vector<gfx::Rect>& copy_rects, |
| 82 const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE; | 67 const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE; |
| 83 virtual void RenderProcessGone(base::TerminationStatus status, | 68 virtual void RenderProcessGone(base::TerminationStatus status, |
| 84 int error_code) OVERRIDE; | 69 int error_code) OVERRIDE; |
| 85 virtual void Destroy() OVERRIDE; | 70 virtual void Destroy() OVERRIDE; |
| 86 virtual void SetTooltipText(const base::string16& tooltip_text) OVERRIDE; | 71 virtual void SetTooltipText(const base::string16& tooltip_text) OVERRIDE; |
| 87 virtual void SelectionChanged(const base::string16& text, | |
| 88 size_t offset, | |
| 89 const gfx::Range& range) OVERRIDE; | |
| 90 virtual void SelectionBoundsChanged( | 72 virtual void SelectionBoundsChanged( |
| 91 const ViewHostMsg_SelectionBounds_Params& params) OVERRIDE; | 73 const ViewHostMsg_SelectionBounds_Params& params) OVERRIDE; |
| 92 #if defined(OS_ANDROID) | |
| 93 virtual void SelectionRootBoundsChanged(const gfx::Rect& bounds) OVERRIDE; | |
| 94 #endif | |
| 95 virtual void ScrollOffsetChanged() OVERRIDE; | 74 virtual void ScrollOffsetChanged() OVERRIDE; |
| 96 virtual void CopyFromCompositingSurface( | 75 virtual void CopyFromCompositingSurface( |
| 97 const gfx::Rect& src_subrect, | 76 const gfx::Rect& subrect, |
| 98 const gfx::Size& dst_size, | 77 const gfx::Size& size, |
| 99 const base::Callback<void(bool, const SkBitmap&)>& callback, | 78 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 100 const SkBitmap::Config config) OVERRIDE; | 79 const SkBitmap::Config config) OVERRIDE; |
| 101 virtual void CopyFromCompositingSurfaceToVideoFrame( | 80 virtual void CopyFromCompositingSurfaceToVideoFrame( |
| 102 const gfx::Rect& src_subrect, | 81 const gfx::Rect& src_subrect, |
| 103 const scoped_refptr<media::VideoFrame>& target, | 82 const scoped_refptr<media::VideoFrame>& target, |
| 104 const base::Callback<void(bool)>& callback) OVERRIDE; | 83 const base::Callback<void(bool)>& callback) OVERRIDE; |
| 105 virtual bool CanCopyToVideoFrame() const OVERRIDE; | 84 virtual bool CanCopyToVideoFrame() const OVERRIDE; |
| 106 virtual void OnAcceleratedCompositingStateChange() OVERRIDE; | |
| 107 virtual void AcceleratedSurfaceInitialized(int host_id, | 85 virtual void AcceleratedSurfaceInitialized(int host_id, |
| 108 int route_id) OVERRIDE; | 86 int route_id) OVERRIDE; |
| 87 virtual void OnAcceleratedCompositingStateChange() OVERRIDE; |
| 109 virtual void AcceleratedSurfaceBuffersSwapped( | 88 virtual void AcceleratedSurfaceBuffersSwapped( |
| 110 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | 89 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| 111 int gpu_host_id) OVERRIDE; | 90 int gpu_host_id) OVERRIDE; |
| 112 virtual void AcceleratedSurfacePostSubBuffer( | 91 virtual void AcceleratedSurfacePostSubBuffer( |
| 113 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, | 92 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
| 114 int gpu_host_id) OVERRIDE; | 93 int gpu_host_id) OVERRIDE; |
| 115 virtual void AcceleratedSurfaceSuspend() OVERRIDE; | 94 virtual void AcceleratedSurfaceSuspend() OVERRIDE; |
| 116 virtual void AcceleratedSurfaceRelease() OVERRIDE; | 95 virtual void AcceleratedSurfaceRelease() OVERRIDE; |
| 117 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; | 96 virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE; |
| 118 virtual void OnSwapCompositorFrame( | |
| 119 uint32 output_surface_id, | |
| 120 scoped_ptr<cc::CompositorFrame> frame) OVERRIDE; | |
| 121 virtual void GetScreenInfo(blink::WebScreenInfo* results) OVERRIDE; | |
| 122 virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; | |
| 123 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; | |
| 124 virtual void SetHasHorizontalScrollbar( | 97 virtual void SetHasHorizontalScrollbar( |
| 125 bool has_horizontal_scrollbar) OVERRIDE; | 98 bool has_horizontal_scrollbar) OVERRIDE; |
| 126 virtual void SetScrollOffsetPinning( | 99 virtual void SetScrollOffsetPinning( |
| 127 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; | 100 bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE; |
| 128 #if defined(USE_AURA) | 101 virtual void GetScreenInfo(blink::WebScreenInfo* results) OVERRIDE; |
| 129 virtual void ProcessAckedTouchEvent( | 102 virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE; |
| 130 const TouchEventWithLatencyInfo& touch, | 103 virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE; |
| 131 InputEventAckState ack_result) OVERRIDE; | |
| 132 #endif // defined(USE_AURA) | |
| 133 virtual bool LockMouse() OVERRIDE; | 104 virtual bool LockMouse() OVERRIDE; |
| 134 virtual void UnlockMouse() OVERRIDE; | 105 virtual void UnlockMouse() OVERRIDE; |
| 135 | 106 virtual void OnSwapCompositorFrame( |
| 136 #if defined(OS_MACOSX) | 107 uint32 output_surface_id, |
| 137 // RenderWidgetHostView implementation. | 108 scoped_ptr<cc::CompositorFrame> frame) OVERRIDE; |
| 138 virtual void SetActive(bool active) OVERRIDE; | |
| 139 virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE; | |
| 140 virtual void SetWindowVisibility(bool visible) OVERRIDE; | |
| 141 virtual void WindowFrameChanged() OVERRIDE; | |
| 142 virtual void ShowDefinitionForSelection() OVERRIDE; | |
| 143 virtual bool SupportsSpeech() const OVERRIDE; | |
| 144 virtual void SpeakSelection() OVERRIDE; | |
| 145 virtual bool IsSpeaking() const OVERRIDE; | |
| 146 virtual void StopSpeaking() OVERRIDE; | |
| 147 | |
| 148 // RenderWidgetHostViewPort implementation. | |
| 149 virtual bool PostProcessEventForPluginIme( | |
| 150 const NativeWebKeyboardEvent& event) OVERRIDE; | |
| 151 #endif // defined(OS_MACOSX) | |
| 152 | |
| 153 #if defined(OS_ANDROID) | |
| 154 // RenderWidgetHostViewPort implementation. | |
| 155 virtual void ShowDisambiguationPopup( | |
| 156 const gfx::Rect& target_rect, | |
| 157 const SkBitmap& zoomed_bitmap) OVERRIDE; | |
| 158 #endif // defined(OS_ANDROID) | |
| 159 | |
| 160 #if defined(OS_WIN) | |
| 161 virtual void SetParentNativeViewAccessible( | |
| 162 gfx::NativeViewAccessible accessible_parent) OVERRIDE; | |
| 163 virtual gfx::NativeViewId GetParentForWindowlessPlugin() const OVERRIDE; | |
| 164 #endif | |
| 165 | |
| 166 virtual SkBitmap::Config PreferredReadbackFormat() OVERRIDE; | |
| 167 | 109 |
| 168 protected: | 110 protected: |
| 169 friend class RenderWidgetHostView; | 111 friend class RenderWidgetHostView; |
| 170 | 112 |
| 171 // Members will become private when RenderWidgetHostViewGuest is removed. | 113 // Should construct only via RenderWidgetHostView::CreateViewForWidget. |
| 114 explicit RenderWidgetHostViewCast(RenderWidgetHost* widget); |
| 115 |
| 116 private: |
| 172 // The model object. | 117 // The model object. |
| 173 RenderWidgetHostImpl* host_; | 118 RenderWidgetHostImpl* host_; |
| 174 | 119 |
| 175 // frame_connector_ provides a platform abstraction. Messages | 120 // This is true when we are currently painting and thus should handle extra |
| 176 // sent through it are routed to the embedding renderer process. | 121 // paint requests by expanding the invalid rect rather than actually |
| 177 CrossProcessFrameConnector* frame_connector_; | 122 // painting. |
| 123 bool about_to_validate_and_paint_; |
| 178 | 124 |
| 179 private: | 125 // This is the rectangle which we'll paint. |
| 180 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewChildFrame); | 126 gfx::Rect invalid_rect_; |
| 127 |
| 128 // Whether or not this widget is hidden. |
| 129 bool is_hidden_; |
| 130 |
| 131 // Whether we are currently loading. |
| 132 bool is_loading_; |
| 133 |
| 134 // Is the widget fullscreen? |
| 135 bool is_fullscreen_; |
| 136 |
| 137 // The size that we want the renderer to be. |
| 138 gfx::Size requested_size_; |
| 139 |
| 140 std::vector<ui::LatencyInfo> software_latency_info_; |
| 141 |
| 142 scoped_ptr<gfx::chromecast::Surface> surface_; |
| 143 void Paint(const gfx::Rect&); |
| 181 }; | 144 }; |
| 182 | |
| 183 } // namespace content | 145 } // namespace content |
| 184 | 146 |
| 185 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_ | 147 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_CAST_H_ |
| OLD | NEW |