blob: 2d26bd28ee601dfdf592bd91361f280dd50a117c [file] [log] [blame]
[email protected]227692c52013-05-31 22:43:041// Copyright 2013 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 CONTENT_RENDERER_RENDER_FRAME_IMPL_H_
6#define CONTENT_RENDERER_RENDER_FRAME_IMPL_H_
7
[email protected]7a4e2532013-12-02 21:30:028#include <set>
9#include <vector>
10
[email protected]227692c52013-05-31 22:43:0411#include "base/basictypes.h"
[email protected]7a4e2532013-12-02 21:30:0212#include "base/files/file_path.h"
[email protected]2e2d9632013-12-03 00:55:2613#include "base/observer_list.h"
[email protected]7a4e2532013-12-02 21:30:0214#include "base/process/process_handle.h"
15#include "base/strings/string16.h"
[email protected]227692c52013-05-31 22:43:0416#include "content/public/renderer/render_frame.h"
17#include "ipc/ipc_message.h"
[email protected]85d85fd2013-06-19 00:57:4118#include "third_party/WebKit/public/web/WebDataSource.h"
19#include "third_party/WebKit/public/web/WebFrameClient.h"
[email protected]227692c52013-05-31 22:43:0420
[email protected]7a4e2532013-12-02 21:30:0221class TransportDIB;
22
23namespace blink {
24class WebMouseEvent;
25struct WebCompositionUnderline;
26struct WebCursorInfo;
27}
28
29namespace gfx {
30class Range;
31class Rect;
32}
33
[email protected]227692c52013-05-31 22:43:0434namespace content {
35
[email protected]7a4e2532013-12-02 21:30:0236class PepperPluginInstanceImpl;
37class RendererPpapiHost;
[email protected]2e2d9632013-12-03 00:55:2638class RenderFrameObserver;
[email protected]227692c52013-05-31 22:43:0439class RenderViewImpl;
[email protected]7a4e2532013-12-02 21:30:0240class RenderWidget;
41class RenderWidgetFullscreenPepper;
[email protected]227692c52013-05-31 22:43:0442
[email protected]85d85fd2013-06-19 00:57:4143class CONTENT_EXPORT RenderFrameImpl
44 : public RenderFrame,
[email protected]180ef242013-11-07 06:50:4645 NON_EXPORTED_BASE(public blink::WebFrameClient) {
[email protected]227692c52013-05-31 22:43:0446 public:
[email protected]2f61bdd2013-07-02 18:38:4747 // Creates a new RenderFrame. |render_view| is the RenderView object that this
48 // frame belongs to.
49 static RenderFrameImpl* Create(RenderViewImpl* render_view, int32 routing_id);
50
51 // Used by content_layouttest_support to hook into the creation of
52 // RenderFrameImpls.
53 static void InstallCreateHook(
54 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32));
55
[email protected]227692c52013-05-31 22:43:0456 virtual ~RenderFrameImpl();
57
[email protected]7a4e2532013-12-02 21:30:0258 // TODO(jam): this is a temporary getter until all the code is transitioned
59 // to using RenderFrame instead of RenderView.
60 RenderViewImpl* render_view() { return render_view_; }
61
62 // Returns the RenderWidget associated with this frame.
63 RenderWidget* GetRenderWidget();
64
65#if defined(ENABLE_PLUGINS)
[email protected]271ff5792013-12-04 22:29:3166 // Notification that a PPAPI plugin has been created.
67 void PepperPluginCreated(RendererPpapiHost* host);
68
[email protected]7a4e2532013-12-02 21:30:0269 // Indicates that the given instance has been created.
70 void PepperInstanceCreated(PepperPluginInstanceImpl* instance);
71
72 // Indicates that the given instance is being destroyed. This is called from
73 // the destructor, so it's important that the instance is not dereferenced
74 // from this call.
75 void PepperInstanceDeleted(PepperPluginInstanceImpl* instance);
76
77 // Notifies that |instance| has changed the cursor.
78 // This will update the cursor appearance if it is currently over the plugin
79 // instance.
80 void PepperDidChangeCursor(PepperPluginInstanceImpl* instance,
81 const blink::WebCursorInfo& cursor);
82
83 // Notifies that |instance| has received a mouse event.
84 void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl* instance);
85
86 // Notification that the given plugin is focused or unfocused.
87 void PepperFocusChanged(PepperPluginInstanceImpl* instance, bool focused);
88
89 // Informs the render view that a PPAPI plugin has changed text input status.
90 void PepperTextInputTypeChanged(PepperPluginInstanceImpl* instance);
91 void PepperCaretPositionChanged(PepperPluginInstanceImpl* instance);
92
93 // Cancels current composition.
94 void PepperCancelComposition(PepperPluginInstanceImpl* instance);
95
96 // Informs the render view that a PPAPI plugin has changed selection.
97 void PepperSelectionChanged(PepperPluginInstanceImpl* instance);
98
99 // Creates a fullscreen container for a pepper plugin instance.
100 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
101 PepperPluginInstanceImpl* plugin);
102
[email protected]7a4e2532013-12-02 21:30:02103 bool IsPepperAcceptingCompositionEvents() const;
104
105 // Notification that the given plugin has crashed.
106 void PluginCrashed(const base::FilePath& plugin_path,
107 base::ProcessId plugin_pid);
108
109 // These map to virtual methods on RenderWidget that are used to call out to
110 // RenderView.
111 // TODO(jam): once we get rid of RenderView, RenderFrame will own RenderWidget
112 // and methods would be on a delegate interface.
113 void DidInitiatePaint();
114 void DidFlushPaint();
115 PepperPluginInstanceImpl* GetBitmapForOptimizedPluginPaint(
116 const gfx::Rect& paint_bounds,
117 TransportDIB** dib,
118 gfx::Rect* location,
119 gfx::Rect* clip,
120 float* scale_factor);
121 void PageVisibilityChanged(bool shown);
122 void OnSetFocus(bool enable);
123 void WillHandleMouseEvent(const blink::WebMouseEvent& event);
124
125 // Simulates IME events for testing purpose.
126 void SimulateImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26127 const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02128 const std::vector<blink::WebCompositionUnderline>& underlines,
129 int selection_start,
130 int selection_end);
[email protected]fcf75d42013-12-03 20:11:26131 void SimulateImeConfirmComposition(const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02132 const gfx::Range& replacement_range);
133
134 // TODO(jam): remove these once the IPC handler moves from RenderView to
135 // RenderFrame.
136 void OnImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26137 const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02138 const std::vector<blink::WebCompositionUnderline>& underlines,
139 int selection_start,
140 int selection_end);
141 void OnImeConfirmComposition(
[email protected]fcf75d42013-12-03 20:11:26142 const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02143 const gfx::Range& replacement_range,
144 bool keep_selection);
[email protected]7a4e2532013-12-02 21:30:02145#endif // ENABLE_PLUGINS
146
[email protected]227692c52013-05-31 22:43:04147 // IPC::Sender
148 virtual bool Send(IPC::Message* msg) OVERRIDE;
149
150 // IPC::Listener
151 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
152
[email protected]271ff5792013-12-04 22:29:31153 // RenderFrame implementation:
[email protected]b849847b2013-12-10 21:57:58154 virtual RenderView* GetRenderView() OVERRIDE;
[email protected]60eca4eb2013-12-06 00:02:16155 virtual int GetRoutingID() OVERRIDE;
[email protected]d019e1a382013-12-11 17:52:06156 virtual WebPreferences& GetWebkitPreferences() OVERRIDE;
157 virtual int ShowContextMenu(ContextMenuClient* client,
158 const ContextMenuParams& params) OVERRIDE;
159 virtual void CancelContextMenu(int request_id) OVERRIDE;
[email protected]271ff5792013-12-04 22:29:31160 virtual blink::WebPlugin* CreatePlugin(
161 blink::WebFrame* frame,
162 const WebPluginInfo& info,
163 const blink::WebPluginParams& params) OVERRIDE;
[email protected]d019e1a382013-12-11 17:52:06164 virtual void LoadURLExternally(
165 blink::WebFrame* frame,
166 const blink::WebURLRequest& request,
167 blink::WebNavigationPolicy policy) OVERRIDE;
[email protected]271ff5792013-12-04 22:29:31168
[email protected]180ef242013-11-07 06:50:46169 // blink::WebFrameClient implementation -------------------------------------
170 virtual blink::WebPlugin* createPlugin(
171 blink::WebFrame* frame,
172 const blink::WebPluginParams& params);
173 virtual blink::WebMediaPlayer* createMediaPlayer(
174 blink::WebFrame* frame,
175 const blink::WebURL& url,
176 blink::WebMediaPlayerClient* client);
177 virtual blink::WebApplicationCacheHost* createApplicationCacheHost(
178 blink::WebFrame* frame,
179 blink::WebApplicationCacheHostClient* client);
180 virtual blink::WebWorkerPermissionClientProxy*
181 createWorkerPermissionClientProxy(blink::WebFrame* frame);
182 virtual blink::WebCookieJar* cookieJar(blink::WebFrame* frame);
183 virtual blink::WebServiceWorkerProvider* createServiceWorkerProvider(
184 blink::WebFrame* frame,
185 blink::WebServiceWorkerProviderClient*);
186 virtual void didAccessInitialDocument(blink::WebFrame* frame);
187 virtual blink::WebFrame* createChildFrame(blink::WebFrame* parent,
188 const blink::WebString& name);
189 virtual void didDisownOpener(blink::WebFrame* frame);
190 virtual void frameDetached(blink::WebFrame* frame);
191 virtual void willClose(blink::WebFrame* frame);
192 virtual void didChangeName(blink::WebFrame* frame,
193 const blink::WebString& name);
[email protected]f5b6dd1122013-10-04 02:42:50194 virtual void didMatchCSS(
[email protected]180ef242013-11-07 06:50:46195 blink::WebFrame* frame,
196 const blink::WebVector<blink::WebString>& newly_matching_selectors,
197 const blink::WebVector<blink::WebString>& stopped_matching_selectors);
198 virtual void loadURLExternally(blink::WebFrame* frame,
199 const blink::WebURLRequest& request,
200 blink::WebNavigationPolicy policy);
[email protected]85d85fd2013-06-19 00:57:41201 virtual void loadURLExternally(
[email protected]180ef242013-11-07 06:50:46202 blink::WebFrame* frame,
203 const blink::WebURLRequest& request,
204 blink::WebNavigationPolicy policy,
205 const blink::WebString& suggested_name);
206 virtual blink::WebNavigationPolicy decidePolicyForNavigation(
207 blink::WebFrame* frame,
208 blink::WebDataSource::ExtraData* extra_data,
209 const blink::WebURLRequest& request,
210 blink::WebNavigationType type,
211 blink::WebNavigationPolicy default_policy,
[email protected]f6ae17fc2013-08-19 22:56:17212 bool is_redirect);
213 // DEPRECATED
[email protected]180ef242013-11-07 06:50:46214 virtual blink::WebNavigationPolicy decidePolicyForNavigation(
215 blink::WebFrame* frame,
216 const blink::WebURLRequest& request,
217 blink::WebNavigationType type,
218 blink::WebNavigationPolicy default_policy,
[email protected]255eea092013-06-28 17:19:14219 bool is_redirect);
[email protected]180ef242013-11-07 06:50:46220 virtual void willSendSubmitEvent(blink::WebFrame* frame,
221 const blink::WebFormElement& form);
222 virtual void willSubmitForm(blink::WebFrame* frame,
223 const blink::WebFormElement& form);
224 virtual void didCreateDataSource(blink::WebFrame* frame,
225 blink::WebDataSource* datasource);
226 virtual void didStartProvisionalLoad(blink::WebFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41227 virtual void didReceiveServerRedirectForProvisionalLoad(
[email protected]180ef242013-11-07 06:50:46228 blink::WebFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41229 virtual void didFailProvisionalLoad(
[email protected]180ef242013-11-07 06:50:46230 blink::WebFrame* frame,
231 const blink::WebURLError& error);
232 virtual void didCommitProvisionalLoad(blink::WebFrame* frame,
[email protected]255eea092013-06-28 17:19:14233 bool is_new_navigation);
[email protected]180ef242013-11-07 06:50:46234 virtual void didClearWindowObject(blink::WebFrame* frame);
235 virtual void didCreateDocumentElement(blink::WebFrame* frame);
236 virtual void didReceiveTitle(blink::WebFrame* frame,
237 const blink::WebString& title,
238 blink::WebTextDirection direction);
239 virtual void didChangeIcon(blink::WebFrame* frame,
240 blink::WebIconURL::Type icon_type);
241 virtual void didFinishDocumentLoad(blink::WebFrame* frame);
242 virtual void didHandleOnloadEvents(blink::WebFrame* frame);
243 virtual void didFailLoad(blink::WebFrame* frame,
244 const blink::WebURLError& error);
245 virtual void didFinishLoad(blink::WebFrame* frame);
246 virtual void didNavigateWithinPage(blink::WebFrame* frame,
[email protected]255eea092013-06-28 17:19:14247 bool is_new_navigation);
[email protected]180ef242013-11-07 06:50:46248 virtual void didUpdateCurrentHistoryItem(blink::WebFrame* frame);
249 virtual void willRequestAfterPreconnect(blink::WebFrame* frame,
250 blink::WebURLRequest& request);
[email protected]85d85fd2013-06-19 00:57:41251 virtual void willSendRequest(
[email protected]180ef242013-11-07 06:50:46252 blink::WebFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41253 unsigned identifier,
[email protected]180ef242013-11-07 06:50:46254 blink::WebURLRequest& request,
255 const blink::WebURLResponse& redirect_response);
[email protected]85d85fd2013-06-19 00:57:41256 virtual void didReceiveResponse(
[email protected]180ef242013-11-07 06:50:46257 blink::WebFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41258 unsigned identifier,
[email protected]180ef242013-11-07 06:50:46259 const blink::WebURLResponse& response);
260 virtual void didFinishResourceLoad(blink::WebFrame* frame,
[email protected]255eea092013-06-28 17:19:14261 unsigned identifier);
[email protected]85d85fd2013-06-19 00:57:41262 virtual void didLoadResourceFromMemoryCache(
[email protected]180ef242013-11-07 06:50:46263 blink::WebFrame* frame,
264 const blink::WebURLRequest& request,
265 const blink::WebURLResponse& response);
266 virtual void didDisplayInsecureContent(blink::WebFrame* frame);
267 virtual void didRunInsecureContent(blink::WebFrame* frame,
268 const blink::WebSecurityOrigin& origin,
269 const blink::WebURL& target);
270 virtual void didAbortLoading(blink::WebFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41271 virtual void didExhaustMemoryAvailableForScript(
[email protected]180ef242013-11-07 06:50:46272 blink::WebFrame* frame);
273 virtual void didCreateScriptContext(blink::WebFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41274 v8::Handle<v8::Context> context,
275 int extension_group,
[email protected]255eea092013-06-28 17:19:14276 int world_id);
[email protected]180ef242013-11-07 06:50:46277 virtual void willReleaseScriptContext(blink::WebFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41278 v8::Handle<v8::Context> context,
[email protected]255eea092013-06-28 17:19:14279 int world_id);
[email protected]180ef242013-11-07 06:50:46280 virtual void didFirstVisuallyNonEmptyLayout(blink::WebFrame* frame);
281 virtual void didChangeContentsSize(blink::WebFrame* frame,
282 const blink::WebSize& size);
283 virtual void didChangeScrollOffset(blink::WebFrame* frame);
284 virtual void willInsertBody(blink::WebFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41285 virtual void reportFindInPageMatchCount(int request_id,
286 int count,
[email protected]255eea092013-06-28 17:19:14287 bool final_update);
[email protected]85d85fd2013-06-19 00:57:41288 virtual void reportFindInPageSelection(int request_id,
289 int active_match_ordinal,
[email protected]180ef242013-11-07 06:50:46290 const blink::WebRect& sel);
[email protected]85d85fd2013-06-19 00:57:41291 virtual void requestStorageQuota(
[email protected]180ef242013-11-07 06:50:46292 blink::WebFrame* frame,
293 blink::WebStorageQuotaType type,
[email protected]85d85fd2013-06-19 00:57:41294 unsigned long long requested_size,
[email protected]180ef242013-11-07 06:50:46295 blink::WebStorageQuotaCallbacks* callbacks);
[email protected]85d85fd2013-06-19 00:57:41296 virtual void willOpenSocketStream(
[email protected]180ef242013-11-07 06:50:46297 blink::WebSocketStreamHandle* handle);
[email protected]85d85fd2013-06-19 00:57:41298 virtual void willStartUsingPeerConnectionHandler(
[email protected]180ef242013-11-07 06:50:46299 blink::WebFrame* frame,
300 blink::WebRTCPeerConnectionHandler* handler);
[email protected]85d85fd2013-06-19 00:57:41301 virtual bool willCheckAndDispatchMessageEvent(
[email protected]180ef242013-11-07 06:50:46302 blink::WebFrame* sourceFrame,
303 blink::WebFrame* targetFrame,
304 blink::WebSecurityOrigin targetOrigin,
305 blink::WebDOMMessageEvent event);
306 virtual blink::WebString userAgentOverride(
307 blink::WebFrame* frame,
308 const blink::WebURL& url);
309 virtual blink::WebString doNotTrackValue(blink::WebFrame* frame);
310 virtual bool allowWebGL(blink::WebFrame* frame, bool default_value);
311 virtual void didLoseWebGLContext(blink::WebFrame* frame,
[email protected]255eea092013-06-28 17:19:14312 int arb_robustness_status_code);
[email protected]85d85fd2013-06-19 00:57:41313
[email protected]2f61bdd2013-07-02 18:38:47314 protected:
315 RenderFrameImpl(RenderViewImpl* render_view, int32 routing_id);
316
[email protected]227692c52013-05-31 22:43:04317 private:
[email protected]2e2d9632013-12-03 00:55:26318 friend class RenderFrameObserver;
319
320 // Functions to add and remove observers for this object.
321 void AddObserver(RenderFrameObserver* observer);
322 void RemoveObserver(RenderFrameObserver* observer);
[email protected]1c2052f2013-08-28 08:24:34323
[email protected]227692c52013-05-31 22:43:04324 RenderViewImpl* render_view_;
325 int routing_id_;
[email protected]1c2052f2013-08-28 08:24:34326 bool is_swapped_out_;
327 bool is_detaching_;
[email protected]227692c52013-05-31 22:43:04328
[email protected]7a4e2532013-12-02 21:30:02329#if defined(ENABLE_PLUGINS)
330 typedef std::set<PepperPluginInstanceImpl*> PepperPluginSet;
331 PepperPluginSet active_pepper_instances_;
332
[email protected]7a4e2532013-12-02 21:30:02333 // Current text input composition text. Empty if no composition is in
334 // progress.
[email protected]fcf75d42013-12-03 20:11:26335 base::string16 pepper_composition_text_;
[email protected]7a4e2532013-12-02 21:30:02336#endif
337
[email protected]2e2d9632013-12-03 00:55:26338 // All the registered observers.
339 ObserverList<RenderFrameObserver> observers_;
340
[email protected]227692c52013-05-31 22:43:04341 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl);
342};
343
344} // namespace content
345
[email protected]85d85fd2013-06-19 00:57:41346#endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_