blob: ee6fa797983f05e57e798b77d624b23704574121 [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]271ff5792013-12-04 22:29:31156 virtual blink::WebPlugin* CreatePlugin(
157 blink::WebFrame* frame,
158 const WebPluginInfo& info,
159 const blink::WebPluginParams& params) OVERRIDE;
160
[email protected]180ef242013-11-07 06:50:46161 // blink::WebFrameClient implementation -------------------------------------
162 virtual blink::WebPlugin* createPlugin(
163 blink::WebFrame* frame,
164 const blink::WebPluginParams& params);
165 virtual blink::WebMediaPlayer* createMediaPlayer(
166 blink::WebFrame* frame,
167 const blink::WebURL& url,
168 blink::WebMediaPlayerClient* client);
169 virtual blink::WebApplicationCacheHost* createApplicationCacheHost(
170 blink::WebFrame* frame,
171 blink::WebApplicationCacheHostClient* client);
172 virtual blink::WebWorkerPermissionClientProxy*
173 createWorkerPermissionClientProxy(blink::WebFrame* frame);
174 virtual blink::WebCookieJar* cookieJar(blink::WebFrame* frame);
175 virtual blink::WebServiceWorkerProvider* createServiceWorkerProvider(
176 blink::WebFrame* frame,
177 blink::WebServiceWorkerProviderClient*);
178 virtual void didAccessInitialDocument(blink::WebFrame* frame);
179 virtual blink::WebFrame* createChildFrame(blink::WebFrame* parent,
180 const blink::WebString& name);
181 virtual void didDisownOpener(blink::WebFrame* frame);
182 virtual void frameDetached(blink::WebFrame* frame);
183 virtual void willClose(blink::WebFrame* frame);
184 virtual void didChangeName(blink::WebFrame* frame,
185 const blink::WebString& name);
[email protected]f5b6dd1122013-10-04 02:42:50186 virtual void didMatchCSS(
[email protected]180ef242013-11-07 06:50:46187 blink::WebFrame* frame,
188 const blink::WebVector<blink::WebString>& newly_matching_selectors,
189 const blink::WebVector<blink::WebString>& stopped_matching_selectors);
190 virtual void loadURLExternally(blink::WebFrame* frame,
191 const blink::WebURLRequest& request,
192 blink::WebNavigationPolicy policy);
[email protected]85d85fd2013-06-19 00:57:41193 virtual void loadURLExternally(
[email protected]180ef242013-11-07 06:50:46194 blink::WebFrame* frame,
195 const blink::WebURLRequest& request,
196 blink::WebNavigationPolicy policy,
197 const blink::WebString& suggested_name);
198 virtual blink::WebNavigationPolicy decidePolicyForNavigation(
199 blink::WebFrame* frame,
200 blink::WebDataSource::ExtraData* extra_data,
201 const blink::WebURLRequest& request,
202 blink::WebNavigationType type,
203 blink::WebNavigationPolicy default_policy,
[email protected]f6ae17fc2013-08-19 22:56:17204 bool is_redirect);
205 // DEPRECATED
[email protected]180ef242013-11-07 06:50:46206 virtual blink::WebNavigationPolicy decidePolicyForNavigation(
207 blink::WebFrame* frame,
208 const blink::WebURLRequest& request,
209 blink::WebNavigationType type,
210 blink::WebNavigationPolicy default_policy,
[email protected]255eea092013-06-28 17:19:14211 bool is_redirect);
[email protected]180ef242013-11-07 06:50:46212 virtual void willSendSubmitEvent(blink::WebFrame* frame,
213 const blink::WebFormElement& form);
214 virtual void willSubmitForm(blink::WebFrame* frame,
215 const blink::WebFormElement& form);
216 virtual void didCreateDataSource(blink::WebFrame* frame,
217 blink::WebDataSource* datasource);
218 virtual void didStartProvisionalLoad(blink::WebFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41219 virtual void didReceiveServerRedirectForProvisionalLoad(
[email protected]180ef242013-11-07 06:50:46220 blink::WebFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41221 virtual void didFailProvisionalLoad(
[email protected]180ef242013-11-07 06:50:46222 blink::WebFrame* frame,
223 const blink::WebURLError& error);
224 virtual void didCommitProvisionalLoad(blink::WebFrame* frame,
[email protected]255eea092013-06-28 17:19:14225 bool is_new_navigation);
[email protected]180ef242013-11-07 06:50:46226 virtual void didClearWindowObject(blink::WebFrame* frame);
227 virtual void didCreateDocumentElement(blink::WebFrame* frame);
228 virtual void didReceiveTitle(blink::WebFrame* frame,
229 const blink::WebString& title,
230 blink::WebTextDirection direction);
231 virtual void didChangeIcon(blink::WebFrame* frame,
232 blink::WebIconURL::Type icon_type);
233 virtual void didFinishDocumentLoad(blink::WebFrame* frame);
234 virtual void didHandleOnloadEvents(blink::WebFrame* frame);
235 virtual void didFailLoad(blink::WebFrame* frame,
236 const blink::WebURLError& error);
237 virtual void didFinishLoad(blink::WebFrame* frame);
238 virtual void didNavigateWithinPage(blink::WebFrame* frame,
[email protected]255eea092013-06-28 17:19:14239 bool is_new_navigation);
[email protected]180ef242013-11-07 06:50:46240 virtual void didUpdateCurrentHistoryItem(blink::WebFrame* frame);
241 virtual void willRequestAfterPreconnect(blink::WebFrame* frame,
242 blink::WebURLRequest& request);
[email protected]85d85fd2013-06-19 00:57:41243 virtual void willSendRequest(
[email protected]180ef242013-11-07 06:50:46244 blink::WebFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41245 unsigned identifier,
[email protected]180ef242013-11-07 06:50:46246 blink::WebURLRequest& request,
247 const blink::WebURLResponse& redirect_response);
[email protected]85d85fd2013-06-19 00:57:41248 virtual void didReceiveResponse(
[email protected]180ef242013-11-07 06:50:46249 blink::WebFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41250 unsigned identifier,
[email protected]180ef242013-11-07 06:50:46251 const blink::WebURLResponse& response);
252 virtual void didFinishResourceLoad(blink::WebFrame* frame,
[email protected]255eea092013-06-28 17:19:14253 unsigned identifier);
[email protected]85d85fd2013-06-19 00:57:41254 virtual void didLoadResourceFromMemoryCache(
[email protected]180ef242013-11-07 06:50:46255 blink::WebFrame* frame,
256 const blink::WebURLRequest& request,
257 const blink::WebURLResponse& response);
258 virtual void didDisplayInsecureContent(blink::WebFrame* frame);
259 virtual void didRunInsecureContent(blink::WebFrame* frame,
260 const blink::WebSecurityOrigin& origin,
261 const blink::WebURL& target);
262 virtual void didAbortLoading(blink::WebFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41263 virtual void didExhaustMemoryAvailableForScript(
[email protected]180ef242013-11-07 06:50:46264 blink::WebFrame* frame);
265 virtual void didCreateScriptContext(blink::WebFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41266 v8::Handle<v8::Context> context,
267 int extension_group,
[email protected]255eea092013-06-28 17:19:14268 int world_id);
[email protected]180ef242013-11-07 06:50:46269 virtual void willReleaseScriptContext(blink::WebFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41270 v8::Handle<v8::Context> context,
[email protected]255eea092013-06-28 17:19:14271 int world_id);
[email protected]180ef242013-11-07 06:50:46272 virtual void didFirstVisuallyNonEmptyLayout(blink::WebFrame* frame);
273 virtual void didChangeContentsSize(blink::WebFrame* frame,
274 const blink::WebSize& size);
275 virtual void didChangeScrollOffset(blink::WebFrame* frame);
276 virtual void willInsertBody(blink::WebFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41277 virtual void reportFindInPageMatchCount(int request_id,
278 int count,
[email protected]255eea092013-06-28 17:19:14279 bool final_update);
[email protected]85d85fd2013-06-19 00:57:41280 virtual void reportFindInPageSelection(int request_id,
281 int active_match_ordinal,
[email protected]180ef242013-11-07 06:50:46282 const blink::WebRect& sel);
[email protected]85d85fd2013-06-19 00:57:41283 virtual void requestStorageQuota(
[email protected]180ef242013-11-07 06:50:46284 blink::WebFrame* frame,
285 blink::WebStorageQuotaType type,
[email protected]85d85fd2013-06-19 00:57:41286 unsigned long long requested_size,
[email protected]180ef242013-11-07 06:50:46287 blink::WebStorageQuotaCallbacks* callbacks);
[email protected]85d85fd2013-06-19 00:57:41288 virtual void willOpenSocketStream(
[email protected]180ef242013-11-07 06:50:46289 blink::WebSocketStreamHandle* handle);
[email protected]85d85fd2013-06-19 00:57:41290 virtual void willStartUsingPeerConnectionHandler(
[email protected]180ef242013-11-07 06:50:46291 blink::WebFrame* frame,
292 blink::WebRTCPeerConnectionHandler* handler);
[email protected]85d85fd2013-06-19 00:57:41293 virtual bool willCheckAndDispatchMessageEvent(
[email protected]180ef242013-11-07 06:50:46294 blink::WebFrame* sourceFrame,
295 blink::WebFrame* targetFrame,
296 blink::WebSecurityOrigin targetOrigin,
297 blink::WebDOMMessageEvent event);
298 virtual blink::WebString userAgentOverride(
299 blink::WebFrame* frame,
300 const blink::WebURL& url);
301 virtual blink::WebString doNotTrackValue(blink::WebFrame* frame);
302 virtual bool allowWebGL(blink::WebFrame* frame, bool default_value);
303 virtual void didLoseWebGLContext(blink::WebFrame* frame,
[email protected]255eea092013-06-28 17:19:14304 int arb_robustness_status_code);
[email protected]85d85fd2013-06-19 00:57:41305
[email protected]2f61bdd2013-07-02 18:38:47306 protected:
307 RenderFrameImpl(RenderViewImpl* render_view, int32 routing_id);
308
[email protected]227692c52013-05-31 22:43:04309 private:
[email protected]2e2d9632013-12-03 00:55:26310 friend class RenderFrameObserver;
311
312 // Functions to add and remove observers for this object.
313 void AddObserver(RenderFrameObserver* observer);
314 void RemoveObserver(RenderFrameObserver* observer);
[email protected]1c2052f2013-08-28 08:24:34315
[email protected]227692c52013-05-31 22:43:04316 RenderViewImpl* render_view_;
317 int routing_id_;
[email protected]1c2052f2013-08-28 08:24:34318 bool is_swapped_out_;
319 bool is_detaching_;
[email protected]227692c52013-05-31 22:43:04320
[email protected]7a4e2532013-12-02 21:30:02321#if defined(ENABLE_PLUGINS)
322 typedef std::set<PepperPluginInstanceImpl*> PepperPluginSet;
323 PepperPluginSet active_pepper_instances_;
324
[email protected]7a4e2532013-12-02 21:30:02325 // Current text input composition text. Empty if no composition is in
326 // progress.
[email protected]fcf75d42013-12-03 20:11:26327 base::string16 pepper_composition_text_;
[email protected]7a4e2532013-12-02 21:30:02328#endif
329
[email protected]2e2d9632013-12-03 00:55:26330 // All the registered observers.
331 ObserverList<RenderFrameObserver> observers_;
332
[email protected]227692c52013-05-31 22:43:04333 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl);
334};
335
336} // namespace content
337
[email protected]85d85fd2013-06-19 00:57:41338#endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_