Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / browser / frame_host / render_widget_host_view_child_frame.h
blobad5d8ef01e04ef6f29cbaa12fa72bb14cbb84aa4
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_
6 #define CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "cc/resources/returned_resource.h"
10 #include "cc/surfaces/surface_factory_client.h"
11 #include "cc/surfaces/surface_id_allocator.h"
12 #include "content/browser/compositor/image_transport_factory.h"
13 #include "content/browser/renderer_host/render_widget_host_view_base.h"
14 #include "content/common/content_export.h"
15 #include "content/public/browser/readback_types.h"
16 #include "ui/compositor/compositor.h"
17 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/native_widget_types.h"
20 namespace cc {
21 class SurfaceFactory;
22 enum class SurfaceDrawStatus;
25 namespace content {
26 class CrossProcessFrameConnector;
27 class RenderWidgetHost;
28 class RenderWidgetHostImpl;
29 class RenderWidgetHostViewChildFrameTest;
30 class RenderWidgetHostViewGuestSurfaceTest;
32 // RenderWidgetHostViewChildFrame implements the view for a RenderWidgetHost
33 // associated with content being rendered in a separate process from
34 // content that is embedding it. This is not a platform-specific class; rather,
35 // the embedding renderer process implements the platform containing the
36 // widget, and the top-level frame's RenderWidgetHostView will ultimately
37 // manage all native widget interaction.
39 // See comments in render_widget_host_view.h about this class and its members.
40 class CONTENT_EXPORT RenderWidgetHostViewChildFrame
41 : public RenderWidgetHostViewBase,
42 public cc::SurfaceFactoryClient {
43 public:
44 explicit RenderWidgetHostViewChildFrame(RenderWidgetHost* widget);
45 ~RenderWidgetHostViewChildFrame() override;
47 void set_cross_process_frame_connector(
48 CrossProcessFrameConnector* frame_connector) {
49 frame_connector_ = frame_connector;
52 // RenderWidgetHostView implementation.
53 void InitAsChild(gfx::NativeView parent_view) override;
54 RenderWidgetHost* GetRenderWidgetHost() const override;
55 void SetSize(const gfx::Size& size) override;
56 void SetBounds(const gfx::Rect& rect) override;
57 void Focus() override;
58 bool HasFocus() const override;
59 bool IsSurfaceAvailableForCopy() const override;
60 void Show() override;
61 void Hide() override;
62 bool IsShowing() override;
63 gfx::Rect GetViewBounds() const override;
64 gfx::Vector2dF GetLastScrollOffset() const override;
65 gfx::NativeView GetNativeView() const override;
66 gfx::NativeViewId GetNativeViewId() const override;
67 gfx::NativeViewAccessible GetNativeViewAccessible() override;
68 void SetBackgroundColor(SkColor color) override;
69 gfx::Size GetPhysicalBackingSize() const override;
71 // RenderWidgetHostViewBase implementation.
72 void InitAsPopup(RenderWidgetHostView* parent_host_view,
73 const gfx::Rect& bounds) override;
74 void InitAsFullscreen(RenderWidgetHostView* reference_host_view) override;
75 void MovePluginWindows(const std::vector<WebPluginGeometry>& moves) override;
76 void UpdateCursor(const WebCursor& cursor) override;
77 void SetIsLoading(bool is_loading) override;
78 void TextInputTypeChanged(ui::TextInputType type,
79 ui::TextInputMode input_mode,
80 bool can_compose_inline,
81 int flags) override;
82 void ImeCancelComposition() override;
83 void ImeCompositionRangeChanged(
84 const gfx::Range& range,
85 const std::vector<gfx::Rect>& character_bounds) override;
86 void RenderProcessGone(base::TerminationStatus status,
87 int error_code) override;
88 void Destroy() override;
89 void SetTooltipText(const base::string16& tooltip_text) override;
90 void SelectionChanged(const base::string16& text,
91 size_t offset,
92 const gfx::Range& range) override;
93 void SelectionBoundsChanged(
94 const ViewHostMsg_SelectionBounds_Params& params) override;
95 void CopyFromCompositingSurface(
96 const gfx::Rect& src_subrect,
97 const gfx::Size& dst_size,
98 ReadbackRequestCallback& callback,
99 const SkColorType preferred_color_type) override;
100 void CopyFromCompositingSurfaceToVideoFrame(
101 const gfx::Rect& src_subrect,
102 const scoped_refptr<media::VideoFrame>& target,
103 const base::Callback<void(bool)>& callback) override;
104 bool CanCopyToVideoFrame() const override;
105 bool HasAcceleratedSurface(const gfx::Size& desired_size) override;
106 void OnSwapCompositorFrame(uint32 output_surface_id,
107 scoped_ptr<cc::CompositorFrame> frame) override;
108 void GetScreenInfo(blink::WebScreenInfo* results) override;
109 gfx::Rect GetBoundsInRootWindow() override;
110 gfx::GLSurfaceHandle GetCompositingSurface() override;
111 #if defined(USE_AURA)
112 void ProcessAckedTouchEvent(const TouchEventWithLatencyInfo& touch,
113 InputEventAckState ack_result) override;
114 #endif // defined(USE_AURA)
115 bool LockMouse() override;
116 void UnlockMouse() override;
117 uint32_t GetSurfaceIdNamespace() override;
119 #if defined(OS_MACOSX)
120 // RenderWidgetHostView implementation.
121 void SetActive(bool active) override;
122 void SetWindowVisibility(bool visible) override;
123 void WindowFrameChanged() override;
124 void ShowDefinitionForSelection() override;
125 bool SupportsSpeech() const override;
126 void SpeakSelection() override;
127 bool IsSpeaking() const override;
128 void StopSpeaking() override;
130 // RenderWidgetHostViewBase implementation.
131 bool PostProcessEventForPluginIme(
132 const NativeWebKeyboardEvent& event) override;
133 #endif // defined(OS_MACOSX)
135 // RenderWidgetHostViewBase implementation.
136 #if defined(OS_ANDROID)
137 void LockCompositingSurface() override;
138 void UnlockCompositingSurface() override;
139 #endif // defined(OS_ANDROID)
141 #if defined(OS_WIN)
142 void SetParentNativeViewAccessible(
143 gfx::NativeViewAccessible accessible_parent) override;
144 gfx::NativeViewId GetParentForWindowlessPlugin() const override;
145 #endif
146 BrowserAccessibilityManager* CreateBrowserAccessibilityManager(
147 BrowserAccessibilityDelegate* delegate) override;
149 // cc::SurfaceFactoryClient implementation.
150 void ReturnResources(const cc::ReturnedResourceArray& resources) override;
152 // Declared 'public' instead of 'protected' here to allow derived classes
153 // to Bind() to it.
154 void SurfaceDrawn(uint32 output_surface_id, cc::SurfaceDrawStatus drawn);
156 protected:
157 friend class RenderWidgetHostView;
158 friend class RenderWidgetHostViewChildFrameTest;
159 friend class RenderWidgetHostViewGuestSurfaceTest;
161 // Clears current compositor surface, if one is in use.
162 void ClearCompositorSurfaceIfNecessary();
164 // The last scroll offset of the view.
165 gfx::Vector2dF last_scroll_offset_;
167 // Members will become private when RenderWidgetHostViewGuest is removed.
168 // The model object.
169 RenderWidgetHostImpl* host_;
171 // Flag determining whether we render into a compositing Surface.
172 bool use_surfaces_;
174 // Surface-related state.
175 scoped_ptr<cc::SurfaceIdAllocator> id_allocator_;
176 scoped_ptr<cc::SurfaceFactory> surface_factory_;
177 cc::SurfaceId surface_id_;
178 uint32 next_surface_sequence_;
179 uint32 last_output_surface_id_;
180 gfx::Size current_surface_size_;
181 float current_surface_scale_factor_;
182 uint32 ack_pending_count_;
183 cc::ReturnedResourceArray surface_returned_resources_;
185 // frame_connector_ provides a platform abstraction. Messages
186 // sent through it are routed to the embedding renderer process.
187 CrossProcessFrameConnector* frame_connector_;
189 base::WeakPtr<RenderWidgetHostViewChildFrame> AsWeakPtr() {
190 return weak_factory_.GetWeakPtr();
193 private:
194 base::WeakPtrFactory<RenderWidgetHostViewChildFrame> weak_factory_;
195 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewChildFrame);
198 } // namespace content
200 #endif // CONTENT_BROWSER_FRAME_HOST_RENDER_WIDGET_HOST_VIEW_CHILD_FRAME_H_