blob: 9cebe76f4c7145e3a5d7c66e2bf20a6c87cabfbb [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 <vector>
9
[email protected]227692c52013-05-31 22:43:0410#include "base/basictypes.h"
[email protected]7a4e2532013-12-02 21:30:0211#include "base/files/file_path.h"
[email protected]a09d53ce2014-01-31 00:46:4212#include "base/gtest_prod_util.h"
13#include "base/id_map.h"
[email protected]abc501e2014-01-27 19:27:2614#include "base/memory/weak_ptr.h"
[email protected]2e2d9632013-12-03 00:55:2615#include "base/observer_list.h"
[email protected]7a4e2532013-12-02 21:30:0216#include "base/process/process_handle.h"
[email protected]87de04b02014-04-08 22:14:4917#include "content/public/common/javascript_message_type.h"
[email protected]65920f332014-03-04 21:14:1818#include "content/public/common/referrer.h"
[email protected]227692c52013-05-31 22:43:0419#include "content/public/renderer/render_frame.h"
[email protected]96307312014-05-04 01:00:1920#include "content/renderer/media/webmediaplayer_delegate.h"
[email protected]5a7100d2014-05-19 01:29:0421#include "content/renderer/render_frame_proxy.h"
[email protected]f3add922013-12-20 23:17:1622#include "content/renderer/renderer_webcookiejar_impl.h"
[email protected]227692c52013-05-31 22:43:0423#include "ipc/ipc_message.h"
[email protected]85d85fd2013-06-19 00:57:4124#include "third_party/WebKit/public/web/WebDataSource.h"
25#include "third_party/WebKit/public/web/WebFrameClient.h"
[email protected]680575542014-04-03 17:12:5226#include "third_party/WebKit/public/web/WebHistoryCommitType.h"
[email protected]4ee64622014-03-21 22:34:1527#include "ui/gfx/range/range.h"
[email protected]227692c52013-05-31 22:43:0428
[email protected]a017938b2014-05-27 21:17:1729#if defined(OS_ANDROID)
30#include "content/renderer/media/android/renderer_media_player_manager.h"
31#endif
32
[email protected]7a4e2532013-12-02 21:30:0233class TransportDIB;
[email protected]bffc8302014-01-23 20:52:1634struct FrameMsg_BuffersSwapped_Params;
35struct FrameMsg_CompositorFrameSwapped_Params;
[email protected]c6bc20332014-02-28 18:30:3936struct FrameMsg_Navigate_Params;
[email protected]7a4e2532013-12-02 21:30:0237
38namespace blink {
[email protected]5ee7f182014-04-25 19:45:2639class WebGeolocationClient;
[email protected]5cdd8fd82014-02-05 20:12:1240class WebInputEvent;
[email protected]7a4e2532013-12-02 21:30:0241class WebMouseEvent;
[email protected]82ce5b92014-03-22 05:15:2642class WebContentDecryptionModule;
[email protected]8538385f2014-04-25 19:45:0443class WebMIDIClient;
[email protected]96307312014-05-04 01:00:1944class WebMediaPlayer;
[email protected]1c048252014-04-11 23:27:3445class WebNotificationPresenter;
[email protected]82ce5b92014-03-22 05:15:2646class WebSecurityOrigin;
[email protected]7a4e2532013-12-02 21:30:0247struct WebCompositionUnderline;
[email protected]a09d53ce2014-01-31 00:46:4248struct WebContextMenuData;
[email protected]7a4e2532013-12-02 21:30:0249struct WebCursorInfo;
50}
51
52namespace gfx {
[email protected]a09d53ce2014-01-31 00:46:4253class Point;
[email protected]7a4e2532013-12-02 21:30:0254class Range;
55class Rect;
56}
57
[email protected]227692c52013-05-31 22:43:0458namespace content {
59
[email protected]bffc8302014-01-23 20:52:1660class ChildFrameCompositingHelper;
[email protected]96307312014-05-04 01:00:1961class MediaStreamClient;
[email protected]2626d142014-04-22 17:24:0262class NotificationProvider;
[email protected]7a4e2532013-12-02 21:30:0263class PepperPluginInstanceImpl;
64class RendererPpapiHost;
[email protected]2e2d9632013-12-03 00:55:2665class RenderFrameObserver;
[email protected]227692c52013-05-31 22:43:0466class RenderViewImpl;
[email protected]7a4e2532013-12-02 21:30:0267class RenderWidget;
68class RenderWidgetFullscreenPepper;
[email protected]a09d53ce2014-01-31 00:46:4269struct CustomContextMenuContext;
[email protected]227692c52013-05-31 22:43:0470
[email protected]a017938b2014-05-27 21:17:1771#if defined(OS_ANDROID)
72class RendererMediaPlayerManager;
73#endif
74
[email protected]85d85fd2013-06-19 00:57:4175class CONTENT_EXPORT RenderFrameImpl
76 : public RenderFrame,
[email protected]96307312014-05-04 01:00:1977 NON_EXPORTED_BASE(public blink::WebFrameClient),
78 NON_EXPORTED_BASE(public WebMediaPlayerDelegate) {
[email protected]227692c52013-05-31 22:43:0479 public:
[email protected]2f61bdd2013-07-02 18:38:4780 // Creates a new RenderFrame. |render_view| is the RenderView object that this
81 // frame belongs to.
[email protected]b70da4c2014-01-06 19:57:0982 // Callers *must* call |SetWebFrame| immediately after creation.
83 // TODO(creis): We should structure this so that |SetWebFrame| isn't needed.
[email protected]2f61bdd2013-07-02 18:38:4784 static RenderFrameImpl* Create(RenderViewImpl* render_view, int32 routing_id);
85
[email protected]5a7100d2014-05-19 01:29:0486 // Returns the RenderFrameImpl for the given routing ID.
87 static RenderFrameImpl* FromRoutingID(int routing_id);
88
[email protected]a5ac6dc2014-01-15 07:02:1489 // Just like RenderFrame::FromWebFrame but returns the implementation.
90 static RenderFrameImpl* FromWebFrame(blink::WebFrame* web_frame);
[email protected]b70da4c2014-01-06 19:57:0991
[email protected]2f61bdd2013-07-02 18:38:4792 // Used by content_layouttest_support to hook into the creation of
93 // RenderFrameImpls.
94 static void InstallCreateHook(
95 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32));
96
[email protected]227692c52013-05-31 22:43:0497 virtual ~RenderFrameImpl();
98
[email protected]b70da4c2014-01-06 19:57:0999 bool is_swapped_out() const {
100 return is_swapped_out_;
101 }
102
[email protected]5a7100d2014-05-19 01:29:04103 // TODO(nasko): This can be removed once we don't have a swapped out state on
104 // RenderFrames. See https://crbug.com/357747.
105 void set_render_frame_proxy(RenderFrameProxy* proxy) {
106 render_frame_proxy_ = proxy;
107 }
108
[email protected]bffc8302014-01-23 20:52:16109 // Out-of-process child frames receive a signal from RenderWidgetCompositor
110 // when a compositor frame has committed.
111 void DidCommitCompositorFrame();
112
[email protected]7a4e2532013-12-02 21:30:02113 // TODO(jam): this is a temporary getter until all the code is transitioned
114 // to using RenderFrame instead of RenderView.
[email protected]abc501e2014-01-27 19:27:26115 RenderViewImpl* render_view() { return render_view_.get(); }
[email protected]7a4e2532013-12-02 21:30:02116
[email protected]f3add922013-12-20 23:17:16117 RendererWebCookieJarImpl* cookie_jar() { return &cookie_jar_; }
118
[email protected]7a4e2532013-12-02 21:30:02119 // Returns the RenderWidget associated with this frame.
120 RenderWidget* GetRenderWidget();
121
[email protected]35b2a972014-04-04 15:50:22122 // This is called right after creation with the WebLocalFrame for this
[email protected]0287e762014-04-11 13:07:58123 // RenderFrame. It must be called before Initialize.
[email protected]35b2a972014-04-04 15:50:22124 void SetWebFrame(blink::WebLocalFrame* web_frame);
[email protected]b70da4c2014-01-06 19:57:09125
[email protected]0287e762014-04-11 13:07:58126 // This method must be called after the frame has been added to the frame
127 // tree. It creates all objects that depend on the frame being at its proper
128 // spot.
129 void Initialize();
130
[email protected]5815cf52014-01-29 17:45:05131 // Notification from RenderView.
132 virtual void OnStop();
133
[email protected]723971b2014-02-12 11:08:25134 // Start/Stop loading notifications.
135 // TODO(nasko): Those are page-level methods at this time and come from
136 // WebViewClient. We should move them to be WebFrameClient calls and put
137 // logic in the browser side to balance starts/stops.
[email protected]e3b10d12014-03-28 16:06:09138 // |to_different_document| will be true unless the load is a fragment
139 // navigation, or triggered by history.pushState/replaceState.
[email protected]6dd5c322014-03-12 07:58:46140 virtual void didStartLoading(bool to_different_document);
141 virtual void didStopLoading();
142 virtual void didChangeLoadProgress(double load_progress);
[email protected]723971b2014-02-12 11:08:25143
[email protected]7a4e2532013-12-02 21:30:02144#if defined(ENABLE_PLUGINS)
[email protected]271ff5792013-12-04 22:29:31145 // Notification that a PPAPI plugin has been created.
146 void PepperPluginCreated(RendererPpapiHost* host);
147
[email protected]7a4e2532013-12-02 21:30:02148 // Notifies that |instance| has changed the cursor.
149 // This will update the cursor appearance if it is currently over the plugin
150 // instance.
151 void PepperDidChangeCursor(PepperPluginInstanceImpl* instance,
152 const blink::WebCursorInfo& cursor);
153
154 // Notifies that |instance| has received a mouse event.
155 void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl* instance);
156
[email protected]7a4e2532013-12-02 21:30:02157 // Informs the render view that a PPAPI plugin has changed text input status.
158 void PepperTextInputTypeChanged(PepperPluginInstanceImpl* instance);
159 void PepperCaretPositionChanged(PepperPluginInstanceImpl* instance);
160
161 // Cancels current composition.
162 void PepperCancelComposition(PepperPluginInstanceImpl* instance);
163
164 // Informs the render view that a PPAPI plugin has changed selection.
165 void PepperSelectionChanged(PepperPluginInstanceImpl* instance);
166
167 // Creates a fullscreen container for a pepper plugin instance.
168 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
169 PepperPluginInstanceImpl* plugin);
170
[email protected]7a4e2532013-12-02 21:30:02171 bool IsPepperAcceptingCompositionEvents() const;
172
173 // Notification that the given plugin has crashed.
174 void PluginCrashed(const base::FilePath& plugin_path,
175 base::ProcessId plugin_pid);
176
[email protected]7a4e2532013-12-02 21:30:02177 // Simulates IME events for testing purpose.
178 void SimulateImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26179 const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02180 const std::vector<blink::WebCompositionUnderline>& underlines,
181 int selection_start,
182 int selection_end);
[email protected]fcf75d42013-12-03 20:11:26183 void SimulateImeConfirmComposition(const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02184 const gfx::Range& replacement_range);
185
186 // TODO(jam): remove these once the IPC handler moves from RenderView to
187 // RenderFrame.
188 void OnImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26189 const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02190 const std::vector<blink::WebCompositionUnderline>& underlines,
191 int selection_start,
192 int selection_end);
193 void OnImeConfirmComposition(
[email protected]fcf75d42013-12-03 20:11:26194 const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02195 const gfx::Range& replacement_range,
196 bool keep_selection);
[email protected]7a4e2532013-12-02 21:30:02197#endif // ENABLE_PLUGINS
198
[email protected]96307312014-05-04 01:00:19199 // Overrides the MediaStreamClient used when creating MediaStream players.
200 // Must be called before any players are created.
201 void SetMediaStreamClientForTesting(MediaStreamClient* media_stream_client);
202
[email protected]227692c52013-05-31 22:43:04203 // IPC::Sender
204 virtual bool Send(IPC::Message* msg) OVERRIDE;
205
206 // IPC::Listener
207 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
208
[email protected]271ff5792013-12-04 22:29:31209 // RenderFrame implementation:
[email protected]b849847b2013-12-10 21:57:58210 virtual RenderView* GetRenderView() OVERRIDE;
[email protected]60eca4eb2013-12-06 00:02:16211 virtual int GetRoutingID() OVERRIDE;
[email protected]a5ac6dc2014-01-15 07:02:14212 virtual blink::WebFrame* GetWebFrame() OVERRIDE;
[email protected]d019e1a382013-12-11 17:52:06213 virtual WebPreferences& GetWebkitPreferences() OVERRIDE;
214 virtual int ShowContextMenu(ContextMenuClient* client,
215 const ContextMenuParams& params) OVERRIDE;
216 virtual void CancelContextMenu(int request_id) OVERRIDE;
[email protected]1a6d0112014-03-10 19:08:41217 virtual blink::WebNode GetContextMenuNode() const OVERRIDE;
[email protected]271ff5792013-12-04 22:29:31218 virtual blink::WebPlugin* CreatePlugin(
219 blink::WebFrame* frame,
220 const WebPluginInfo& info,
221 const blink::WebPluginParams& params) OVERRIDE;
[email protected]35b2a972014-04-04 15:50:22222 virtual void LoadURLExternally(blink::WebLocalFrame* frame,
223 const blink::WebURLRequest& request,
224 blink::WebNavigationPolicy policy) OVERRIDE;
[email protected]db3be76f2014-03-25 02:27:47225 virtual void ExecuteJavaScript(const base::string16& javascript) OVERRIDE;
[email protected]271ff5792013-12-04 22:29:31226
[email protected]96307312014-05-04 01:00:19227 // blink::WebFrameClient implementation:
[email protected]35b2a972014-04-04 15:50:22228 virtual blink::WebPlugin* createPlugin(blink::WebLocalFrame* frame,
229 const blink::WebPluginParams& params);
[email protected]180ef242013-11-07 06:50:46230 virtual blink::WebMediaPlayer* createMediaPlayer(
[email protected]35b2a972014-04-04 15:50:22231 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46232 const blink::WebURL& url,
233 blink::WebMediaPlayerClient* client);
[email protected]82ce5b92014-03-22 05:15:26234 virtual blink::WebContentDecryptionModule* createContentDecryptionModule(
[email protected]35b2a972014-04-04 15:50:22235 blink::WebLocalFrame* frame,
[email protected]82ce5b92014-03-22 05:15:26236 const blink::WebSecurityOrigin& security_origin,
237 const blink::WebString& key_system);
[email protected]180ef242013-11-07 06:50:46238 virtual blink::WebApplicationCacheHost* createApplicationCacheHost(
[email protected]35b2a972014-04-04 15:50:22239 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46240 blink::WebApplicationCacheHostClient* client);
241 virtual blink::WebWorkerPermissionClientProxy*
[email protected]35b2a972014-04-04 15:50:22242 createWorkerPermissionClientProxy(blink::WebLocalFrame* frame);
243 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame);
[email protected]180ef242013-11-07 06:50:46244 virtual blink::WebServiceWorkerProvider* createServiceWorkerProvider(
[email protected]35b2a972014-04-04 15:50:22245 blink::WebLocalFrame* frame);
246 virtual void didAccessInitialDocument(blink::WebLocalFrame* frame);
247 virtual blink::WebFrame* createChildFrame(blink::WebLocalFrame* parent,
248 const blink::WebString& name);
249 virtual void didDisownOpener(blink::WebLocalFrame* frame);
[email protected]180ef242013-11-07 06:50:46250 virtual void frameDetached(blink::WebFrame* frame);
[email protected]9c9343b2014-03-08 02:56:07251 virtual void frameFocused();
[email protected]180ef242013-11-07 06:50:46252 virtual void willClose(blink::WebFrame* frame);
[email protected]35b2a972014-04-04 15:50:22253 virtual void didChangeName(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46254 const blink::WebString& name);
[email protected]f5b6dd1122013-10-04 02:42:50255 virtual void didMatchCSS(
[email protected]35b2a972014-04-04 15:50:22256 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46257 const blink::WebVector<blink::WebString>& newly_matching_selectors,
258 const blink::WebVector<blink::WebString>& stopped_matching_selectors);
[email protected]c31a84802014-04-03 15:55:49259 virtual bool shouldReportDetailedMessageForSource(
260 const blink::WebString& source);
261 virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message,
262 const blink::WebString& source_name,
263 unsigned source_line,
264 const blink::WebString& stack_trace);
[email protected]35b2a972014-04-04 15:50:22265 virtual void loadURLExternally(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46266 const blink::WebURLRequest& request,
[email protected]35b2a972014-04-04 15:50:22267 blink::WebNavigationPolicy policy,
268 const blink::WebString& suggested_name);
[email protected]1a4e9752013-12-31 20:10:58269 // The WebDataSource::ExtraData* is assumed to be a DocumentState* subclass.
[email protected]180ef242013-11-07 06:50:46270 virtual blink::WebNavigationPolicy decidePolicyForNavigation(
[email protected]35b2a972014-04-04 15:50:22271 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46272 blink::WebDataSource::ExtraData* extra_data,
273 const blink::WebURLRequest& request,
274 blink::WebNavigationType type,
275 blink::WebNavigationPolicy default_policy,
[email protected]f6ae17fc2013-08-19 22:56:17276 bool is_redirect);
[email protected]680575542014-04-03 17:12:52277 virtual blink::WebHistoryItem historyItemForNewChildFrame(
278 blink::WebFrame* frame);
[email protected]35b2a972014-04-04 15:50:22279 virtual void willSendSubmitEvent(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46280 const blink::WebFormElement& form);
[email protected]35b2a972014-04-04 15:50:22281 virtual void willSubmitForm(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46282 const blink::WebFormElement& form);
[email protected]35b2a972014-04-04 15:50:22283 virtual void didCreateDataSource(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46284 blink::WebDataSource* datasource);
[email protected]35b2a972014-04-04 15:50:22285 virtual void didStartProvisionalLoad(blink::WebLocalFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41286 virtual void didReceiveServerRedirectForProvisionalLoad(
[email protected]45d877f2014-04-05 07:36:22287 blink::WebLocalFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41288 virtual void didFailProvisionalLoad(
[email protected]45d877f2014-04-05 07:36:22289 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46290 const blink::WebURLError& error);
[email protected]680575542014-04-03 17:12:52291 virtual void didCommitProvisionalLoad(
[email protected]45d877f2014-04-05 07:36:22292 blink::WebLocalFrame* frame,
[email protected]680575542014-04-03 17:12:52293 const blink::WebHistoryItem& item,
294 blink::WebHistoryCommitType commit_type);
[email protected]06181e52014-05-10 11:59:09295 virtual void didClearWindowObject(blink::WebLocalFrame* frame);
[email protected]35b2a972014-04-04 15:50:22296 virtual void didCreateDocumentElement(blink::WebLocalFrame* frame);
297 virtual void didReceiveTitle(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46298 const blink::WebString& title,
299 blink::WebTextDirection direction);
[email protected]35b2a972014-04-04 15:50:22300 virtual void didChangeIcon(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46301 blink::WebIconURL::Type icon_type);
[email protected]35b2a972014-04-04 15:50:22302 virtual void didFinishDocumentLoad(blink::WebLocalFrame* frame);
303 virtual void didHandleOnloadEvents(blink::WebLocalFrame* frame);
304 virtual void didFailLoad(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46305 const blink::WebURLError& error);
[email protected]45d877f2014-04-05 07:36:22306 virtual void didFinishLoad(blink::WebLocalFrame* frame);
307 virtual void didNavigateWithinPage(blink::WebLocalFrame* frame,
[email protected]680575542014-04-03 17:12:52308 const blink::WebHistoryItem& item,
309 blink::WebHistoryCommitType commit_type);
[email protected]35b2a972014-04-04 15:50:22310 virtual void didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame);
[email protected]1c048252014-04-11 23:27:34311 virtual blink::WebNotificationPresenter* notificationPresenter();
[email protected]c3f2c702014-03-19 23:39:48312 virtual void didChangeSelection(bool is_empty_selection);
[email protected]f3c59d62014-04-09 16:33:55313 virtual blink::WebColorChooser* createColorChooser(
[email protected]eb8c216a2014-04-09 19:19:19314 blink::WebColorChooserClient* client,
[email protected]f3c59d62014-04-09 16:33:55315 const blink::WebColor& initial_color,
316 const blink::WebVector<blink::WebColorSuggestion>& suggestions);
[email protected]87de04b02014-04-08 22:14:49317 virtual void runModalAlertDialog(const blink::WebString& message);
318 virtual bool runModalConfirmDialog(const blink::WebString& message);
319 virtual bool runModalPromptDialog(const blink::WebString& message,
320 const blink::WebString& default_value,
321 blink::WebString* actual_value);
322 virtual bool runModalBeforeUnloadDialog(bool is_reload,
323 const blink::WebString& message);
[email protected]12cc5112014-03-03 17:01:10324 virtual void showContextMenu(const blink::WebContextMenuData& data);
[email protected]91070342014-03-07 00:29:02325 virtual void clearContextMenu();
[email protected]35b2a972014-04-04 15:50:22326 virtual void willRequestAfterPreconnect(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46327 blink::WebURLRequest& request);
[email protected]35b2a972014-04-04 15:50:22328 virtual void willSendRequest(blink::WebLocalFrame* frame,
329 unsigned identifier,
330 blink::WebURLRequest& request,
331 const blink::WebURLResponse& redirect_response);
332 virtual void didReceiveResponse(blink::WebLocalFrame* frame,
333 unsigned identifier,
334 const blink::WebURLResponse& response);
335 virtual void didFinishResourceLoad(blink::WebLocalFrame* frame,
[email protected]255eea092013-06-28 17:19:14336 unsigned identifier);
[email protected]85d85fd2013-06-19 00:57:41337 virtual void didLoadResourceFromMemoryCache(
[email protected]35b2a972014-04-04 15:50:22338 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46339 const blink::WebURLRequest& request,
340 const blink::WebURLResponse& response);
[email protected]35b2a972014-04-04 15:50:22341 virtual void didDisplayInsecureContent(blink::WebLocalFrame* frame);
342 virtual void didRunInsecureContent(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46343 const blink::WebSecurityOrigin& origin,
344 const blink::WebURL& target);
[email protected]35b2a972014-04-04 15:50:22345 virtual void didAbortLoading(blink::WebLocalFrame* frame);
346 virtual void didCreateScriptContext(blink::WebLocalFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41347 v8::Handle<v8::Context> context,
348 int extension_group,
[email protected]255eea092013-06-28 17:19:14349 int world_id);
[email protected]35b2a972014-04-04 15:50:22350 virtual void willReleaseScriptContext(blink::WebLocalFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41351 v8::Handle<v8::Context> context,
[email protected]255eea092013-06-28 17:19:14352 int world_id);
[email protected]35b2a972014-04-04 15:50:22353 virtual void didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame);
354 virtual void didChangeContentsSize(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46355 const blink::WebSize& size);
[email protected]35b2a972014-04-04 15:50:22356 virtual void didChangeScrollOffset(blink::WebLocalFrame* frame);
357 virtual void willInsertBody(blink::WebLocalFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41358 virtual void reportFindInPageMatchCount(int request_id,
359 int count,
[email protected]255eea092013-06-28 17:19:14360 bool final_update);
[email protected]85d85fd2013-06-19 00:57:41361 virtual void reportFindInPageSelection(int request_id,
362 int active_match_ordinal,
[email protected]180ef242013-11-07 06:50:46363 const blink::WebRect& sel);
[email protected]35b2a972014-04-04 15:50:22364 virtual void requestStorageQuota(blink::WebLocalFrame* frame,
365 blink::WebStorageQuotaType type,
366 unsigned long long requested_size,
367 blink::WebStorageQuotaCallbacks callbacks);
[email protected]85d85fd2013-06-19 00:57:41368 virtual void willOpenSocketStream(
[email protected]180ef242013-11-07 06:50:46369 blink::WebSocketStreamHandle* handle);
[email protected]5ee7f182014-04-25 19:45:26370 virtual blink::WebGeolocationClient* geolocationClient();
[email protected]85d85fd2013-06-19 00:57:41371 virtual void willStartUsingPeerConnectionHandler(
[email protected]35b2a972014-04-04 15:50:22372 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46373 blink::WebRTCPeerConnectionHandler* handler);
[email protected]bfe45e22014-04-25 16:47:53374 virtual blink::WebUserMediaClient* userMediaClient();
[email protected]8538385f2014-04-25 19:45:04375 virtual blink::WebMIDIClient* webMIDIClient();
[email protected]85d85fd2013-06-19 00:57:41376 virtual bool willCheckAndDispatchMessageEvent(
[email protected]ce5064f2014-05-07 22:49:20377 blink::WebLocalFrame* source_frame,
378 blink::WebFrame* target_frame,
379 blink::WebSecurityOrigin target_origin,
[email protected]180ef242013-11-07 06:50:46380 blink::WebDOMMessageEvent event);
[email protected]35b2a972014-04-04 15:50:22381 virtual blink::WebString userAgentOverride(blink::WebLocalFrame* frame,
382 const blink::WebURL& url);
383 virtual blink::WebString doNotTrackValue(blink::WebLocalFrame* frame);
384 virtual bool allowWebGL(blink::WebLocalFrame* frame, bool default_value);
385 virtual void didLoseWebGLContext(blink::WebLocalFrame* frame,
[email protected]255eea092013-06-28 17:19:14386 int arb_robustness_status_code);
[email protected]5cdd8fd82014-02-05 20:12:12387 virtual void forwardInputEvent(const blink::WebInputEvent* event);
[email protected]9ef43adc2014-02-19 08:02:15388 virtual void initializeChildFrame(const blink::WebRect& frame_rect,
389 float scale_factor);
[email protected]85d85fd2013-06-19 00:57:41390
[email protected]96307312014-05-04 01:00:19391 // WebMediaPlayerDelegate implementation:
392 virtual void DidPlay(blink::WebMediaPlayer* player) OVERRIDE;
393 virtual void DidPause(blink::WebMediaPlayer* player) OVERRIDE;
394 virtual void PlayerGone(blink::WebMediaPlayer* player) OVERRIDE;
395
[email protected]c6bc20332014-02-28 18:30:39396 // TODO(nasko): Make all tests in RenderViewImplTest friends and then move
397 // this back to private member.
398 void OnNavigate(const FrameMsg_Navigate_Params& params);
399
[email protected]2f61bdd2013-07-02 18:38:47400 protected:
401 RenderFrameImpl(RenderViewImpl* render_view, int32 routing_id);
402
[email protected]227692c52013-05-31 22:43:04403 private:
[email protected]2e2d9632013-12-03 00:55:26404 friend class RenderFrameObserver;
[email protected]66bbadaf2014-03-28 16:25:54405 FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest,
406 AccessibilityMessagesQueueWhileSwappedOut);
407 FRIEND_TEST_ALL_PREFIXES(RenderFrameImplTest,
[email protected]a09d53ce2014-01-31 00:46:42408 ShouldUpdateSelectionTextFromContextMenuParams);
[email protected]4ee64622014-03-21 22:34:15409 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
410 OnExtendSelectionAndDelete);
[email protected]66bbadaf2014-03-28 16:25:54411 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ReloadWhileSwappedOut);
412 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SendSwapOutACK);
[email protected]4ee64622014-03-21 22:34:15413 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
414 SetEditableSelectionAndComposition);
[email protected]2e2d9632013-12-03 00:55:26415
[email protected]37567b432014-02-12 01:12:22416 typedef std::map<GURL, double> HostZoomLevels;
417
[email protected]2e2d9632013-12-03 00:55:26418 // Functions to add and remove observers for this object.
419 void AddObserver(RenderFrameObserver* observer);
420 void RemoveObserver(RenderFrameObserver* observer);
[email protected]1c2052f2013-08-28 08:24:34421
[email protected]37567b432014-02-12 01:12:22422 void UpdateURL(blink::WebFrame* frame);
423
[email protected]9c9343b2014-03-08 02:56:07424 // Gets the focused element. If no such element exists then the element will
425 // be NULL.
426 blink::WebElement GetFocusedElement();
427
[email protected]b70da4c2014-01-06 19:57:09428 // IPC message handlers ------------------------------------------------------
429 //
430 // The documentation for these functions should be in
431 // content/common/*_messages.h for the message that the function is handling.
[email protected]f76f32232014-03-11 17:36:17432 void OnBeforeUnload();
[email protected]5a7100d2014-05-19 01:29:04433 void OnSwapOut(int proxy_routing_id);
[email protected]f49722f2014-01-30 17:54:50434 void OnChildFrameProcessGone();
[email protected]bffc8302014-01-23 20:52:16435 void OnBuffersSwapped(const FrameMsg_BuffersSwapped_Params& params);
436 void OnCompositorFrameSwapped(const IPC::Message& message);
[email protected]a09d53ce2014-01-31 00:46:42437 void OnShowContextMenu(const gfx::Point& location);
438 void OnContextMenuClosed(const CustomContextMenuContext& custom_context);
439 void OnCustomContextMenuAction(const CustomContextMenuContext& custom_context,
440 unsigned action);
[email protected]4ee64622014-03-21 22:34:15441 void OnUndo();
442 void OnRedo();
[email protected]9c9343b2014-03-08 02:56:07443 void OnCut();
444 void OnCopy();
445 void OnPaste();
[email protected]4ee64622014-03-21 22:34:15446 void OnPasteAndMatchStyle();
447 void OnDelete();
448 void OnSelectAll();
449 void OnSelectRange(const gfx::Point& start, const gfx::Point& end);
450 void OnUnselect();
[email protected]1f3fc1d2014-04-03 14:50:17451 void OnReplace(const base::string16& text);
452 void OnReplaceMisspelling(const base::string16& text);
[email protected]e31b8ebb2014-03-07 17:59:34453 void OnCSSInsertRequest(const std::string& css);
[email protected]f13ab892014-03-12 06:48:52454 void OnJavaScriptExecuteRequest(const base::string16& javascript,
455 int id,
456 bool notify_result);
[email protected]4ee64622014-03-21 22:34:15457 void OnSetEditableSelectionOffsets(int start, int end);
[email protected]e5e438d62014-03-27 21:47:16458 void OnSetCompositionFromExistingText(
459 int start, int end,
460 const std::vector<blink::WebCompositionUnderline>& underlines);
461 void OnExtendSelectionAndDelete(int before, int after);
[email protected]4fed3702014-04-01 09:08:00462 void OnReload(bool ignore_cache);
[email protected]4ee64622014-03-21 22:34:15463#if defined(OS_MACOSX)
464 void OnCopyToFindPboard();
465#endif
[email protected]9c9343b2014-03-08 02:56:07466
[email protected]65920f332014-03-04 21:14:18467 // Virtual since overridden by WebTestProxy for layout tests.
468 virtual blink::WebNavigationPolicy DecidePolicyForNavigation(
469 RenderFrame* render_frame,
470 blink::WebFrame* frame,
471 blink::WebDataSource::ExtraData* extraData,
472 const blink::WebURLRequest& request,
473 blink::WebNavigationType type,
474 blink::WebNavigationPolicy default_policy,
475 bool is_redirect);
476 void OpenURL(blink::WebFrame* frame,
477 const GURL& url,
478 const Referrer& referrer,
479 blink::WebNavigationPolicy policy);
[email protected]a09d53ce2014-01-31 00:46:42480
[email protected]ef3adfc2014-05-11 00:04:54481 // Update current main frame's encoding and send it to browser window.
482 // Since we want to let users see the right encoding info from menu
483 // before finishing loading, we call the UpdateEncoding in
484 // a) function:DidCommitLoadForFrame. When this function is called,
485 // that means we have got first data. In here we try to get encoding
486 // of page if it has been specified in http header.
487 // b) function:DidReceiveTitle. When this function is called,
488 // that means we have got specified title. Because in most of webpages,
489 // title tags will follow meta tags. In here we try to get encoding of
490 // page if it has been specified in meta tag.
491 // c) function:DidFinishDocumentLoadForFrame. When this function is
492 // called, that means we have got whole html page. In here we should
493 // finally get right encoding of page.
494 void UpdateEncoding(blink::WebFrame* frame,
495 const std::string& encoding_name);
496
[email protected]4ee64622014-03-21 22:34:15497 // Dispatches the current state of selection on the webpage to the browser if
498 // it has changed.
499 // TODO(varunjain): delete this method once we figure out how to keep
500 // selection handles in sync with the webpage.
501 void SyncSelectionIfRequired();
502
[email protected]a09d53ce2014-01-31 00:46:42503 // Returns whether |params.selection_text| should be synchronized to the
504 // browser before bringing up the context menu. Static for testing.
505 static bool ShouldUpdateSelectionTextFromContextMenuParams(
506 const base::string16& selection_text,
507 size_t selection_text_offset,
508 const gfx::Range& selection_range,
509 const ContextMenuParams& params);
[email protected]b70da4c2014-01-06 19:57:09510
[email protected]87de04b02014-04-08 22:14:49511 bool RunJavaScriptMessage(JavaScriptMessageType type,
512 const base::string16& message,
513 const base::string16& default_value,
514 const GURL& frame_url,
515 base::string16* result);
516
[email protected]457736d2014-04-30 15:54:27517 // Loads the appropriate error page for the specified failure into the frame.
518 void LoadNavigationErrorPage(const blink::WebURLRequest& failed_request,
519 const blink::WebURLError& error,
520 bool replace);
521
[email protected]96307312014-05-04 01:00:19522 // Initializes |media_stream_client_|, returning true if successful. Returns
523 // false if it wasn't possible to create a MediaStreamClient (e.g., WebRTC is
524 // disabled) in which case |media_stream_client_| is NULL.
525 bool InitializeMediaStreamClient();
526
527 blink::WebMediaPlayer* CreateWebMediaPlayerForMediaStream(
528 const blink::WebURL& url,
529 blink::WebMediaPlayerClient* client);
530
531#if defined(OS_ANDROID)
532 blink::WebMediaPlayer* CreateAndroidWebMediaPlayer(
533 const blink::WebURL& url,
534 blink::WebMediaPlayerClient* client);
[email protected]a017938b2014-05-27 21:17:17535
536 RendererMediaPlayerManager* GetMediaPlayerManager();
[email protected]96307312014-05-04 01:00:19537#endif
538
[email protected]35b2a972014-04-04 15:50:22539 // Stores the WebLocalFrame we are associated with.
540 blink::WebLocalFrame* frame_;
[email protected]b70da4c2014-01-06 19:57:09541
[email protected]abc501e2014-01-27 19:27:26542 base::WeakPtr<RenderViewImpl> render_view_;
[email protected]227692c52013-05-31 22:43:04543 int routing_id_;
[email protected]1c2052f2013-08-28 08:24:34544 bool is_swapped_out_;
[email protected]5a7100d2014-05-19 01:29:04545 // RenderFrameProxy exists only when is_swapped_out_ is true.
546 // TODO(nasko): This can be removed once we don't have a swapped out state on
547 // RenderFrame. See https://crbug.com/357747.
548 RenderFrameProxy* render_frame_proxy_;
[email protected]1c2052f2013-08-28 08:24:34549 bool is_detaching_;
[email protected]227692c52013-05-31 22:43:04550
[email protected]7a4e2532013-12-02 21:30:02551#if defined(ENABLE_PLUGINS)
[email protected]7a4e2532013-12-02 21:30:02552 // Current text input composition text. Empty if no composition is in
553 // progress.
[email protected]fcf75d42013-12-03 20:11:26554 base::string16 pepper_composition_text_;
[email protected]7a4e2532013-12-02 21:30:02555#endif
556
[email protected]f3add922013-12-20 23:17:16557 RendererWebCookieJarImpl cookie_jar_;
558
[email protected]2e2d9632013-12-03 00:55:26559 // All the registered observers.
560 ObserverList<RenderFrameObserver> observers_;
561
[email protected]bffc8302014-01-23 20:52:16562 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_;
563
[email protected]4ecee352014-03-11 21:12:19564 // The node that the context menu was pressed over.
565 blink::WebNode context_menu_node_;
566
[email protected]a09d53ce2014-01-31 00:46:42567 // External context menu requests we're waiting for. "Internal"
568 // (WebKit-originated) context menu events will have an ID of 0 and will not
569 // be in this map.
570 //
571 // We don't want to add internal ones since some of the "special" page
572 // handlers in the browser process just ignore the context menu requests so
573 // avoid showing context menus, and so this will cause right clicks to leak
574 // entries in this map. Most users of the custom context menu (e.g. Pepper
575 // plugins) are normally only on "regular" pages and the regular pages will
576 // always respond properly to the request, so we don't have to worry so
577 // much about leaks.
578 IDMap<ContextMenuClient, IDMapExternalPointer> pending_context_menus_;
579
[email protected]4ee64622014-03-21 22:34:15580 // The text selection the last time DidChangeSelection got called. May contain
581 // additional characters before and after the selected text, for IMEs. The
582 // portion of this string that is the actual selected text starts at index
583 // |selection_range_.GetMin() - selection_text_offset_| and has length
584 // |selection_range_.length()|.
585 base::string16 selection_text_;
586 // The offset corresponding to the start of |selection_text_| in the document.
587 size_t selection_text_offset_;
588 // Range over the document corresponding to the actual selected text (which
589 // could correspond to a substring of |selection_text_|; see above).
590 gfx::Range selection_range_;
591 // Used to inform didChangeSelection() when it is called in the context
592 // of handling a InputMsg_SelectRange IPC.
593 bool handling_select_range_;
594
[email protected]2626d142014-04-22 17:24:02595 // The next group of objects all implement RenderFrameObserver, so are deleted
596 // along with the RenderFrame automatically. This is why we just store weak
597 // references.
598
599 // Holds a reference to the service which provides desktop notifications.
600 NotificationProvider* notification_provider_;
601
[email protected]96307312014-05-04 01:00:19602 // MediaStreamClient attached to this frame; lazily initialized.
603 MediaStreamClient* media_stream_client_;
604 blink::WebUserMediaClient* web_user_media_client_;
605
[email protected]a017938b2014-05-27 21:17:17606#if defined(OS_ANDROID)
607 // Manages all media players in this render frame for communicating with the
608 // real media player and CDM objects in the browser process. It's okay to use
609 // raw pointers since it's a RenderFrameObserver.
610 RendererMediaPlayerManager* media_player_manager_;
611#endif
612
[email protected]96307312014-05-04 01:00:19613 base::WeakPtrFactory<RenderFrameImpl> weak_factory_;
614
[email protected]227692c52013-05-31 22:43:04615 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl);
616};
617
618} // namespace content
619
[email protected]85d85fd2013-06-19 00:57:41620#endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_