blob: 5fca735a83f6f8e994616e0873b4f9b498506675 [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]c52a1412014-06-25 06:09:2517#include "content/common/mojo/service_registry_impl.h"
[email protected]87de04b02014-04-08 22:14:4918#include "content/public/common/javascript_message_type.h"
[email protected]65920f332014-03-04 21:14:1819#include "content/public/common/referrer.h"
[email protected]227692c52013-05-31 22:43:0420#include "content/public/renderer/render_frame.h"
[email protected]96307312014-05-04 01:00:1921#include "content/renderer/media/webmediaplayer_delegate.h"
[email protected]5a7100d2014-05-19 01:29:0422#include "content/renderer/render_frame_proxy.h"
[email protected]f3add922013-12-20 23:17:1623#include "content/renderer/renderer_webcookiejar_impl.h"
[email protected]227692c52013-05-31 22:43:0424#include "ipc/ipc_message.h"
[email protected]85d85fd2013-06-19 00:57:4125#include "third_party/WebKit/public/web/WebDataSource.h"
26#include "third_party/WebKit/public/web/WebFrameClient.h"
[email protected]680575542014-04-03 17:12:5227#include "third_party/WebKit/public/web/WebHistoryCommitType.h"
[email protected]4ee64622014-03-21 22:34:1528#include "ui/gfx/range/range.h"
[email protected]227692c52013-05-31 22:43:0429
[email protected]a017938b2014-05-27 21:17:1730#if defined(OS_ANDROID)
31#include "content/renderer/media/android/renderer_media_player_manager.h"
32#endif
33
[email protected]7a4e2532013-12-02 21:30:0234class TransportDIB;
[email protected]c6bc20332014-02-28 18:30:3935struct FrameMsg_Navigate_Params;
[email protected]7a4e2532013-12-02 21:30:0236
37namespace blink {
[email protected]5ee7f182014-04-25 19:45:2638class WebGeolocationClient;
[email protected]5cdd8fd82014-02-05 20:12:1239class WebInputEvent;
[email protected]7a4e2532013-12-02 21:30:0240class WebMouseEvent;
[email protected]82ce5b92014-03-22 05:15:2641class WebContentDecryptionModule;
[email protected]96307312014-05-04 01:00:1942class WebMediaPlayer;
[email protected]1c048252014-04-11 23:27:3443class WebNotificationPresenter;
[email protected]45920862014-07-02 12:53:0244class WebPushClient;
[email protected]82ce5b92014-03-22 05:15:2645class WebSecurityOrigin;
[email protected]7a4e2532013-12-02 21:30:0246struct WebCompositionUnderline;
[email protected]a09d53ce2014-01-31 00:46:4247struct WebContextMenuData;
[email protected]7a4e2532013-12-02 21:30:0248struct WebCursorInfo;
49}
50
51namespace gfx {
[email protected]a09d53ce2014-01-31 00:46:4252class Point;
[email protected]7a4e2532013-12-02 21:30:0253class Range;
54class Rect;
55}
56
[email protected]227692c52013-05-31 22:43:0457namespace content {
58
[email protected]bffc8302014-01-23 20:52:1659class ChildFrameCompositingHelper;
[email protected]8eae0802014-06-02 21:35:5560class GeolocationDispatcher;
[email protected]ae2477e2014-05-27 23:47:0861class MediaStreamRendererFactory;
[email protected]52d3e172014-06-16 16:57:0262class MidiDispatcher;
[email protected]2626d142014-04-22 17:24:0263class NotificationProvider;
[email protected]7a4e2532013-12-02 21:30:0264class PepperPluginInstanceImpl;
[email protected]45920862014-07-02 12:53:0265class PushMessagingDispatcher;
[email protected]4b556cf2014-06-10 23:21:5366class RendererCdmManager;
67class RendererMediaPlayerManager;
[email protected]7a4e2532013-12-02 21:30:0268class RendererPpapiHost;
[email protected]2e2d9632013-12-03 00:55:2669class RenderFrameObserver;
[email protected]227692c52013-05-31 22:43:0470class RenderViewImpl;
[email protected]7a4e2532013-12-02 21:30:0271class RenderWidget;
72class RenderWidgetFullscreenPepper;
[email protected]cf78eda2014-06-13 16:57:4173class ScreenOrientationDispatcher;
[email protected]a09d53ce2014-01-31 00:46:4274struct CustomContextMenuContext;
[email protected]227692c52013-05-31 22:43:0475
[email protected]85d85fd2013-06-19 00:57:4176class CONTENT_EXPORT RenderFrameImpl
77 : public RenderFrame,
[email protected]96307312014-05-04 01:00:1978 NON_EXPORTED_BASE(public blink::WebFrameClient),
79 NON_EXPORTED_BASE(public WebMediaPlayerDelegate) {
[email protected]227692c52013-05-31 22:43:0480 public:
[email protected]2f61bdd2013-07-02 18:38:4781 // Creates a new RenderFrame. |render_view| is the RenderView object that this
82 // frame belongs to.
[email protected]b70da4c2014-01-06 19:57:0983 // Callers *must* call |SetWebFrame| immediately after creation.
84 // TODO(creis): We should structure this so that |SetWebFrame| isn't needed.
[email protected]2f61bdd2013-07-02 18:38:4785 static RenderFrameImpl* Create(RenderViewImpl* render_view, int32 routing_id);
86
[email protected]5a7100d2014-05-19 01:29:0487 // Returns the RenderFrameImpl for the given routing ID.
88 static RenderFrameImpl* FromRoutingID(int routing_id);
89
[email protected]a5ac6dc2014-01-15 07:02:1490 // Just like RenderFrame::FromWebFrame but returns the implementation.
91 static RenderFrameImpl* FromWebFrame(blink::WebFrame* web_frame);
[email protected]b70da4c2014-01-06 19:57:0992
[email protected]2f61bdd2013-07-02 18:38:4793 // Used by content_layouttest_support to hook into the creation of
94 // RenderFrameImpls.
95 static void InstallCreateHook(
96 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32));
97
[email protected]227692c52013-05-31 22:43:0498 virtual ~RenderFrameImpl();
99
[email protected]b70da4c2014-01-06 19:57:09100 bool is_swapped_out() const {
101 return is_swapped_out_;
102 }
103
[email protected]5a7100d2014-05-19 01:29:04104 // TODO(nasko): This can be removed once we don't have a swapped out state on
105 // RenderFrames. See https://crbug.com/357747.
106 void set_render_frame_proxy(RenderFrameProxy* proxy) {
107 render_frame_proxy_ = proxy;
108 }
109
[email protected]bffc8302014-01-23 20:52:16110 // Out-of-process child frames receive a signal from RenderWidgetCompositor
111 // when a compositor frame has committed.
112 void DidCommitCompositorFrame();
113
[email protected]7a4e2532013-12-02 21:30:02114 // TODO(jam): this is a temporary getter until all the code is transitioned
115 // to using RenderFrame instead of RenderView.
[email protected]abc501e2014-01-27 19:27:26116 RenderViewImpl* render_view() { return render_view_.get(); }
[email protected]7a4e2532013-12-02 21:30:02117
[email protected]f3add922013-12-20 23:17:16118 RendererWebCookieJarImpl* cookie_jar() { return &cookie_jar_; }
119
[email protected]7a4e2532013-12-02 21:30:02120 // Returns the RenderWidget associated with this frame.
121 RenderWidget* GetRenderWidget();
122
[email protected]35b2a972014-04-04 15:50:22123 // This is called right after creation with the WebLocalFrame for this
[email protected]0287e762014-04-11 13:07:58124 // RenderFrame. It must be called before Initialize.
[email protected]35b2a972014-04-04 15:50:22125 void SetWebFrame(blink::WebLocalFrame* web_frame);
[email protected]b70da4c2014-01-06 19:57:09126
[email protected]0287e762014-04-11 13:07:58127 // This method must be called after the frame has been added to the frame
128 // tree. It creates all objects that depend on the frame being at its proper
129 // spot.
130 void Initialize();
131
[email protected]5815cf52014-01-29 17:45:05132 // Notification from RenderView.
133 virtual void OnStop();
134
[email protected]de3c5d82014-05-28 22:12:59135 // Notifications from RenderWidget.
136 void WasHidden();
137 void WasShown();
138
[email protected]723971b2014-02-12 11:08:25139 // Start/Stop loading notifications.
140 // TODO(nasko): Those are page-level methods at this time and come from
141 // WebViewClient. We should move them to be WebFrameClient calls and put
142 // logic in the browser side to balance starts/stops.
[email protected]e3b10d12014-03-28 16:06:09143 // |to_different_document| will be true unless the load is a fragment
144 // navigation, or triggered by history.pushState/replaceState.
[email protected]6dd5c322014-03-12 07:58:46145 virtual void didStartLoading(bool to_different_document);
146 virtual void didStopLoading();
147 virtual void didChangeLoadProgress(double load_progress);
[email protected]723971b2014-02-12 11:08:25148
[email protected]7a4e2532013-12-02 21:30:02149#if defined(ENABLE_PLUGINS)
[email protected]271ff5792013-12-04 22:29:31150 // Notification that a PPAPI plugin has been created.
151 void PepperPluginCreated(RendererPpapiHost* host);
152
[email protected]7a4e2532013-12-02 21:30:02153 // Notifies that |instance| has changed the cursor.
154 // This will update the cursor appearance if it is currently over the plugin
155 // instance.
156 void PepperDidChangeCursor(PepperPluginInstanceImpl* instance,
157 const blink::WebCursorInfo& cursor);
158
159 // Notifies that |instance| has received a mouse event.
160 void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl* instance);
161
[email protected]7a4e2532013-12-02 21:30:02162 // Informs the render view that a PPAPI plugin has changed text input status.
163 void PepperTextInputTypeChanged(PepperPluginInstanceImpl* instance);
164 void PepperCaretPositionChanged(PepperPluginInstanceImpl* instance);
165
166 // Cancels current composition.
167 void PepperCancelComposition(PepperPluginInstanceImpl* instance);
168
169 // Informs the render view that a PPAPI plugin has changed selection.
170 void PepperSelectionChanged(PepperPluginInstanceImpl* instance);
171
172 // Creates a fullscreen container for a pepper plugin instance.
173 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
174 PepperPluginInstanceImpl* plugin);
175
[email protected]7a4e2532013-12-02 21:30:02176 bool IsPepperAcceptingCompositionEvents() const;
177
178 // Notification that the given plugin has crashed.
179 void PluginCrashed(const base::FilePath& plugin_path,
180 base::ProcessId plugin_pid);
181
[email protected]7a4e2532013-12-02 21:30:02182 // Simulates IME events for testing purpose.
183 void SimulateImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26184 const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02185 const std::vector<blink::WebCompositionUnderline>& underlines,
186 int selection_start,
187 int selection_end);
[email protected]fcf75d42013-12-03 20:11:26188 void SimulateImeConfirmComposition(const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02189 const gfx::Range& replacement_range);
190
191 // TODO(jam): remove these once the IPC handler moves from RenderView to
192 // RenderFrame.
193 void OnImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26194 const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02195 const std::vector<blink::WebCompositionUnderline>& underlines,
196 int selection_start,
197 int selection_end);
198 void OnImeConfirmComposition(
[email protected]fcf75d42013-12-03 20:11:26199 const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02200 const gfx::Range& replacement_range,
201 bool keep_selection);
[email protected]7a4e2532013-12-02 21:30:02202#endif // ENABLE_PLUGINS
203
[email protected]227692c52013-05-31 22:43:04204 // IPC::Sender
205 virtual bool Send(IPC::Message* msg) OVERRIDE;
206
207 // IPC::Listener
208 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
209
[email protected]271ff5792013-12-04 22:29:31210 // RenderFrame implementation:
[email protected]b849847b2013-12-10 21:57:58211 virtual RenderView* GetRenderView() OVERRIDE;
[email protected]60eca4eb2013-12-06 00:02:16212 virtual int GetRoutingID() OVERRIDE;
[email protected]a5ac6dc2014-01-15 07:02:14213 virtual blink::WebFrame* GetWebFrame() OVERRIDE;
[email protected]d019e1a382013-12-11 17:52:06214 virtual WebPreferences& GetWebkitPreferences() OVERRIDE;
215 virtual int ShowContextMenu(ContextMenuClient* client,
216 const ContextMenuParams& params) OVERRIDE;
217 virtual void CancelContextMenu(int request_id) OVERRIDE;
[email protected]1a6d0112014-03-10 19:08:41218 virtual blink::WebNode GetContextMenuNode() const OVERRIDE;
[email protected]271ff5792013-12-04 22:29:31219 virtual blink::WebPlugin* CreatePlugin(
220 blink::WebFrame* frame,
221 const WebPluginInfo& info,
222 const blink::WebPluginParams& params) OVERRIDE;
[email protected]35b2a972014-04-04 15:50:22223 virtual void LoadURLExternally(blink::WebLocalFrame* frame,
224 const blink::WebURLRequest& request,
225 blink::WebNavigationPolicy policy) OVERRIDE;
[email protected]db3be76f2014-03-25 02:27:47226 virtual void ExecuteJavaScript(const base::string16& javascript) OVERRIDE;
[email protected]291abdb2014-06-05 14:19:11227 virtual bool IsHidden() OVERRIDE;
[email protected]c52a1412014-06-25 06:09:25228 virtual ServiceRegistry* GetServiceRegistry() OVERRIDE;
[email protected]271ff5792013-12-04 22:29:31229
[email protected]96307312014-05-04 01:00:19230 // blink::WebFrameClient implementation:
[email protected]35b2a972014-04-04 15:50:22231 virtual blink::WebPlugin* createPlugin(blink::WebLocalFrame* frame,
232 const blink::WebPluginParams& params);
[email protected]180ef242013-11-07 06:50:46233 virtual blink::WebMediaPlayer* createMediaPlayer(
[email protected]35b2a972014-04-04 15:50:22234 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46235 const blink::WebURL& url,
236 blink::WebMediaPlayerClient* client);
[email protected]82ce5b92014-03-22 05:15:26237 virtual blink::WebContentDecryptionModule* createContentDecryptionModule(
[email protected]35b2a972014-04-04 15:50:22238 blink::WebLocalFrame* frame,
[email protected]82ce5b92014-03-22 05:15:26239 const blink::WebSecurityOrigin& security_origin,
240 const blink::WebString& key_system);
[email protected]180ef242013-11-07 06:50:46241 virtual blink::WebApplicationCacheHost* createApplicationCacheHost(
[email protected]35b2a972014-04-04 15:50:22242 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46243 blink::WebApplicationCacheHostClient* client);
244 virtual blink::WebWorkerPermissionClientProxy*
[email protected]35b2a972014-04-04 15:50:22245 createWorkerPermissionClientProxy(blink::WebLocalFrame* frame);
246 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame);
[email protected]180ef242013-11-07 06:50:46247 virtual blink::WebServiceWorkerProvider* createServiceWorkerProvider(
[email protected]35b2a972014-04-04 15:50:22248 blink::WebLocalFrame* frame);
249 virtual void didAccessInitialDocument(blink::WebLocalFrame* frame);
250 virtual blink::WebFrame* createChildFrame(blink::WebLocalFrame* parent,
251 const blink::WebString& name);
252 virtual void didDisownOpener(blink::WebLocalFrame* frame);
[email protected]180ef242013-11-07 06:50:46253 virtual void frameDetached(blink::WebFrame* frame);
[email protected]9c9343b2014-03-08 02:56:07254 virtual void frameFocused();
[email protected]180ef242013-11-07 06:50:46255 virtual void willClose(blink::WebFrame* frame);
[email protected]35b2a972014-04-04 15:50:22256 virtual void didChangeName(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46257 const blink::WebString& name);
[email protected]f5b6dd1122013-10-04 02:42:50258 virtual void didMatchCSS(
[email protected]35b2a972014-04-04 15:50:22259 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46260 const blink::WebVector<blink::WebString>& newly_matching_selectors,
261 const blink::WebVector<blink::WebString>& stopped_matching_selectors);
[email protected]c31a84802014-04-03 15:55:49262 virtual bool shouldReportDetailedMessageForSource(
263 const blink::WebString& source);
264 virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message,
265 const blink::WebString& source_name,
266 unsigned source_line,
267 const blink::WebString& stack_trace);
[email protected]35b2a972014-04-04 15:50:22268 virtual void loadURLExternally(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46269 const blink::WebURLRequest& request,
[email protected]35b2a972014-04-04 15:50:22270 blink::WebNavigationPolicy policy,
271 const blink::WebString& suggested_name);
[email protected]1a4e9752013-12-31 20:10:58272 // The WebDataSource::ExtraData* is assumed to be a DocumentState* subclass.
[email protected]180ef242013-11-07 06:50:46273 virtual blink::WebNavigationPolicy decidePolicyForNavigation(
[email protected]35b2a972014-04-04 15:50:22274 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46275 blink::WebDataSource::ExtraData* extra_data,
276 const blink::WebURLRequest& request,
277 blink::WebNavigationType type,
278 blink::WebNavigationPolicy default_policy,
[email protected]f6ae17fc2013-08-19 22:56:17279 bool is_redirect);
[email protected]680575542014-04-03 17:12:52280 virtual blink::WebHistoryItem historyItemForNewChildFrame(
281 blink::WebFrame* frame);
[email protected]35b2a972014-04-04 15:50:22282 virtual void willSendSubmitEvent(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46283 const blink::WebFormElement& form);
[email protected]35b2a972014-04-04 15:50:22284 virtual void willSubmitForm(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46285 const blink::WebFormElement& form);
[email protected]35b2a972014-04-04 15:50:22286 virtual void didCreateDataSource(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46287 blink::WebDataSource* datasource);
[email protected]35b2a972014-04-04 15:50:22288 virtual void didStartProvisionalLoad(blink::WebLocalFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41289 virtual void didReceiveServerRedirectForProvisionalLoad(
[email protected]45d877f2014-04-05 07:36:22290 blink::WebLocalFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41291 virtual void didFailProvisionalLoad(
[email protected]45d877f2014-04-05 07:36:22292 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46293 const blink::WebURLError& error);
[email protected]680575542014-04-03 17:12:52294 virtual void didCommitProvisionalLoad(
[email protected]45d877f2014-04-05 07:36:22295 blink::WebLocalFrame* frame,
[email protected]680575542014-04-03 17:12:52296 const blink::WebHistoryItem& item,
297 blink::WebHistoryCommitType commit_type);
[email protected]06181e52014-05-10 11:59:09298 virtual void didClearWindowObject(blink::WebLocalFrame* frame);
[email protected]35b2a972014-04-04 15:50:22299 virtual void didCreateDocumentElement(blink::WebLocalFrame* frame);
300 virtual void didReceiveTitle(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46301 const blink::WebString& title,
302 blink::WebTextDirection direction);
[email protected]35b2a972014-04-04 15:50:22303 virtual void didChangeIcon(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46304 blink::WebIconURL::Type icon_type);
[email protected]35b2a972014-04-04 15:50:22305 virtual void didFinishDocumentLoad(blink::WebLocalFrame* frame);
306 virtual void didHandleOnloadEvents(blink::WebLocalFrame* frame);
307 virtual void didFailLoad(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46308 const blink::WebURLError& error);
[email protected]45d877f2014-04-05 07:36:22309 virtual void didFinishLoad(blink::WebLocalFrame* frame);
310 virtual void didNavigateWithinPage(blink::WebLocalFrame* frame,
[email protected]680575542014-04-03 17:12:52311 const blink::WebHistoryItem& item,
312 blink::WebHistoryCommitType commit_type);
[email protected]35b2a972014-04-04 15:50:22313 virtual void didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame);
[email protected]e7104762014-06-20 19:17:25314 virtual void didChangeBrandColor();
[email protected]1c048252014-04-11 23:27:34315 virtual blink::WebNotificationPresenter* notificationPresenter();
[email protected]c3f2c702014-03-19 23:39:48316 virtual void didChangeSelection(bool is_empty_selection);
[email protected]f3c59d62014-04-09 16:33:55317 virtual blink::WebColorChooser* createColorChooser(
[email protected]eb8c216a2014-04-09 19:19:19318 blink::WebColorChooserClient* client,
[email protected]f3c59d62014-04-09 16:33:55319 const blink::WebColor& initial_color,
320 const blink::WebVector<blink::WebColorSuggestion>& suggestions);
[email protected]87de04b02014-04-08 22:14:49321 virtual void runModalAlertDialog(const blink::WebString& message);
322 virtual bool runModalConfirmDialog(const blink::WebString& message);
323 virtual bool runModalPromptDialog(const blink::WebString& message,
324 const blink::WebString& default_value,
325 blink::WebString* actual_value);
326 virtual bool runModalBeforeUnloadDialog(bool is_reload,
327 const blink::WebString& message);
[email protected]12cc5112014-03-03 17:01:10328 virtual void showContextMenu(const blink::WebContextMenuData& data);
[email protected]91070342014-03-07 00:29:02329 virtual void clearContextMenu();
[email protected]35b2a972014-04-04 15:50:22330 virtual void willRequestAfterPreconnect(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46331 blink::WebURLRequest& request);
[email protected]35b2a972014-04-04 15:50:22332 virtual void willSendRequest(blink::WebLocalFrame* frame,
333 unsigned identifier,
334 blink::WebURLRequest& request,
335 const blink::WebURLResponse& redirect_response);
336 virtual void didReceiveResponse(blink::WebLocalFrame* frame,
337 unsigned identifier,
338 const blink::WebURLResponse& response);
339 virtual void didFinishResourceLoad(blink::WebLocalFrame* frame,
[email protected]255eea092013-06-28 17:19:14340 unsigned identifier);
[email protected]85d85fd2013-06-19 00:57:41341 virtual void didLoadResourceFromMemoryCache(
[email protected]35b2a972014-04-04 15:50:22342 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46343 const blink::WebURLRequest& request,
344 const blink::WebURLResponse& response);
[email protected]35b2a972014-04-04 15:50:22345 virtual void didDisplayInsecureContent(blink::WebLocalFrame* frame);
346 virtual void didRunInsecureContent(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46347 const blink::WebSecurityOrigin& origin,
348 const blink::WebURL& target);
[email protected]35b2a972014-04-04 15:50:22349 virtual void didAbortLoading(blink::WebLocalFrame* frame);
350 virtual void didCreateScriptContext(blink::WebLocalFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41351 v8::Handle<v8::Context> context,
352 int extension_group,
[email protected]255eea092013-06-28 17:19:14353 int world_id);
[email protected]35b2a972014-04-04 15:50:22354 virtual void willReleaseScriptContext(blink::WebLocalFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41355 v8::Handle<v8::Context> context,
[email protected]255eea092013-06-28 17:19:14356 int world_id);
[email protected]35b2a972014-04-04 15:50:22357 virtual void didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame);
[email protected]35b2a972014-04-04 15:50:22358 virtual void didChangeScrollOffset(blink::WebLocalFrame* frame);
359 virtual void willInsertBody(blink::WebLocalFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41360 virtual void reportFindInPageMatchCount(int request_id,
361 int count,
[email protected]255eea092013-06-28 17:19:14362 bool final_update);
[email protected]85d85fd2013-06-19 00:57:41363 virtual void reportFindInPageSelection(int request_id,
364 int active_match_ordinal,
[email protected]180ef242013-11-07 06:50:46365 const blink::WebRect& sel);
[email protected]35b2a972014-04-04 15:50:22366 virtual void requestStorageQuota(blink::WebLocalFrame* frame,
367 blink::WebStorageQuotaType type,
368 unsigned long long requested_size,
369 blink::WebStorageQuotaCallbacks callbacks);
[email protected]85d85fd2013-06-19 00:57:41370 virtual void willOpenSocketStream(
[email protected]180ef242013-11-07 06:50:46371 blink::WebSocketStreamHandle* handle);
[email protected]a14903e02014-06-02 07:35:12372 virtual void willOpenWebSocket(blink::WebSocketHandle* handle);
[email protected]5ee7f182014-04-25 19:45:26373 virtual blink::WebGeolocationClient* geolocationClient();
[email protected]45920862014-07-02 12:53:02374 virtual blink::WebPushClient* pushClient();
[email protected]85d85fd2013-06-19 00:57:41375 virtual void willStartUsingPeerConnectionHandler(
[email protected]35b2a972014-04-04 15:50:22376 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46377 blink::WebRTCPeerConnectionHandler* handler);
[email protected]bfe45e22014-04-25 16:47:53378 virtual blink::WebUserMediaClient* userMediaClient();
[email protected]8538385f2014-04-25 19:45:04379 virtual blink::WebMIDIClient* webMIDIClient();
[email protected]85d85fd2013-06-19 00:57:41380 virtual bool willCheckAndDispatchMessageEvent(
[email protected]ce5064f2014-05-07 22:49:20381 blink::WebLocalFrame* source_frame,
382 blink::WebFrame* target_frame,
383 blink::WebSecurityOrigin target_origin,
[email protected]180ef242013-11-07 06:50:46384 blink::WebDOMMessageEvent event);
[email protected]35b2a972014-04-04 15:50:22385 virtual blink::WebString userAgentOverride(blink::WebLocalFrame* frame,
386 const blink::WebURL& url);
387 virtual blink::WebString doNotTrackValue(blink::WebLocalFrame* frame);
388 virtual bool allowWebGL(blink::WebLocalFrame* frame, bool default_value);
389 virtual void didLoseWebGLContext(blink::WebLocalFrame* frame,
[email protected]255eea092013-06-28 17:19:14390 int arb_robustness_status_code);
[email protected]5cdd8fd82014-02-05 20:12:12391 virtual void forwardInputEvent(const blink::WebInputEvent* event);
[email protected]9ef43adc2014-02-19 08:02:15392 virtual void initializeChildFrame(const blink::WebRect& frame_rect,
393 float scale_factor);
[email protected]cf78eda2014-06-13 16:57:41394 virtual blink::WebScreenOrientationClient* webScreenOrientationClient();
[email protected]85d85fd2013-06-19 00:57:41395
[email protected]96307312014-05-04 01:00:19396 // WebMediaPlayerDelegate implementation:
397 virtual void DidPlay(blink::WebMediaPlayer* player) OVERRIDE;
398 virtual void DidPause(blink::WebMediaPlayer* player) OVERRIDE;
399 virtual void PlayerGone(blink::WebMediaPlayer* player) OVERRIDE;
400
[email protected]c6bc20332014-02-28 18:30:39401 // TODO(nasko): Make all tests in RenderViewImplTest friends and then move
402 // this back to private member.
403 void OnNavigate(const FrameMsg_Navigate_Params& params);
404
[email protected]c52a1412014-06-25 06:09:25405 // Binds this render frame's service registry to a handle to the remote
406 // service registry.
407 void BindServiceRegistry(
408 mojo::ScopedMessagePipeHandle service_provider_handle);
409
[email protected]2f61bdd2013-07-02 18:38:47410 protected:
411 RenderFrameImpl(RenderViewImpl* render_view, int32 routing_id);
412
[email protected]227692c52013-05-31 22:43:04413 private:
[email protected]2e2d9632013-12-03 00:55:26414 friend class RenderFrameObserver;
[email protected]66bbadaf2014-03-28 16:25:54415 FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest,
416 AccessibilityMessagesQueueWhileSwappedOut);
[email protected]ae2477e2014-05-27 23:47:08417 FRIEND_TEST_ALL_PREFIXES(RenderFrameImplTest,
[email protected]a09d53ce2014-01-31 00:46:42418 ShouldUpdateSelectionTextFromContextMenuParams);
[email protected]4ee64622014-03-21 22:34:15419 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
420 OnExtendSelectionAndDelete);
[email protected]66bbadaf2014-03-28 16:25:54421 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ReloadWhileSwappedOut);
422 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SendSwapOutACK);
[email protected]4ee64622014-03-21 22:34:15423 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
424 SetEditableSelectionAndComposition);
[email protected]2e2d9632013-12-03 00:55:26425
[email protected]37567b432014-02-12 01:12:22426 typedef std::map<GURL, double> HostZoomLevels;
427
[email protected]2e2d9632013-12-03 00:55:26428 // Functions to add and remove observers for this object.
429 void AddObserver(RenderFrameObserver* observer);
430 void RemoveObserver(RenderFrameObserver* observer);
[email protected]1c2052f2013-08-28 08:24:34431
[email protected]37567b432014-02-12 01:12:22432 void UpdateURL(blink::WebFrame* frame);
433
[email protected]9c9343b2014-03-08 02:56:07434 // Gets the focused element. If no such element exists then the element will
435 // be NULL.
436 blink::WebElement GetFocusedElement();
437
[email protected]b70da4c2014-01-06 19:57:09438 // IPC message handlers ------------------------------------------------------
439 //
440 // The documentation for these functions should be in
441 // content/common/*_messages.h for the message that the function is handling.
[email protected]f76f32232014-03-11 17:36:17442 void OnBeforeUnload();
[email protected]5a7100d2014-05-19 01:29:04443 void OnSwapOut(int proxy_routing_id);
[email protected]a09d53ce2014-01-31 00:46:42444 void OnShowContextMenu(const gfx::Point& location);
445 void OnContextMenuClosed(const CustomContextMenuContext& custom_context);
446 void OnCustomContextMenuAction(const CustomContextMenuContext& custom_context,
447 unsigned action);
[email protected]4ee64622014-03-21 22:34:15448 void OnUndo();
449 void OnRedo();
[email protected]9c9343b2014-03-08 02:56:07450 void OnCut();
451 void OnCopy();
452 void OnPaste();
[email protected]4ee64622014-03-21 22:34:15453 void OnPasteAndMatchStyle();
454 void OnDelete();
455 void OnSelectAll();
456 void OnSelectRange(const gfx::Point& start, const gfx::Point& end);
457 void OnUnselect();
[email protected]1f3fc1d2014-04-03 14:50:17458 void OnReplace(const base::string16& text);
459 void OnReplaceMisspelling(const base::string16& text);
[email protected]e31b8ebb2014-03-07 17:59:34460 void OnCSSInsertRequest(const std::string& css);
[email protected]f13ab892014-03-12 06:48:52461 void OnJavaScriptExecuteRequest(const base::string16& javascript,
462 int id,
463 bool notify_result);
[email protected]4ee64622014-03-21 22:34:15464 void OnSetEditableSelectionOffsets(int start, int end);
[email protected]e5e438d62014-03-27 21:47:16465 void OnSetCompositionFromExistingText(
466 int start, int end,
467 const std::vector<blink::WebCompositionUnderline>& underlines);
468 void OnExtendSelectionAndDelete(int before, int after);
[email protected]4fed3702014-04-01 09:08:00469 void OnReload(bool ignore_cache);
[email protected]96bb6132014-06-16 17:22:19470 void OnTextSurroundingSelectionRequest(size_t max_length);
[email protected]2e531f72014-06-20 23:23:39471 void OnAddStyleSheetByURL(const std::string& url);
[email protected]4ee64622014-03-21 22:34:15472#if defined(OS_MACOSX)
473 void OnCopyToFindPboard();
474#endif
[email protected]9c9343b2014-03-08 02:56:07475
[email protected]65920f332014-03-04 21:14:18476 // Virtual since overridden by WebTestProxy for layout tests.
477 virtual blink::WebNavigationPolicy DecidePolicyForNavigation(
478 RenderFrame* render_frame,
479 blink::WebFrame* frame,
480 blink::WebDataSource::ExtraData* extraData,
481 const blink::WebURLRequest& request,
482 blink::WebNavigationType type,
483 blink::WebNavigationPolicy default_policy,
484 bool is_redirect);
485 void OpenURL(blink::WebFrame* frame,
486 const GURL& url,
487 const Referrer& referrer,
488 blink::WebNavigationPolicy policy);
[email protected]a09d53ce2014-01-31 00:46:42489
[email protected]ef3adfc2014-05-11 00:04:54490 // Update current main frame's encoding and send it to browser window.
491 // Since we want to let users see the right encoding info from menu
492 // before finishing loading, we call the UpdateEncoding in
493 // a) function:DidCommitLoadForFrame. When this function is called,
494 // that means we have got first data. In here we try to get encoding
495 // of page if it has been specified in http header.
496 // b) function:DidReceiveTitle. When this function is called,
497 // that means we have got specified title. Because in most of webpages,
498 // title tags will follow meta tags. In here we try to get encoding of
499 // page if it has been specified in meta tag.
500 // c) function:DidFinishDocumentLoadForFrame. When this function is
501 // called, that means we have got whole html page. In here we should
502 // finally get right encoding of page.
503 void UpdateEncoding(blink::WebFrame* frame,
504 const std::string& encoding_name);
505
[email protected]4ee64622014-03-21 22:34:15506 // Dispatches the current state of selection on the webpage to the browser if
507 // it has changed.
508 // TODO(varunjain): delete this method once we figure out how to keep
509 // selection handles in sync with the webpage.
510 void SyncSelectionIfRequired();
511
[email protected]a09d53ce2014-01-31 00:46:42512 // Returns whether |params.selection_text| should be synchronized to the
513 // browser before bringing up the context menu. Static for testing.
514 static bool ShouldUpdateSelectionTextFromContextMenuParams(
515 const base::string16& selection_text,
516 size_t selection_text_offset,
517 const gfx::Range& selection_range,
518 const ContextMenuParams& params);
[email protected]b70da4c2014-01-06 19:57:09519
[email protected]87de04b02014-04-08 22:14:49520 bool RunJavaScriptMessage(JavaScriptMessageType type,
521 const base::string16& message,
522 const base::string16& default_value,
523 const GURL& frame_url,
524 base::string16* result);
525
[email protected]457736d2014-04-30 15:54:27526 // Loads the appropriate error page for the specified failure into the frame.
527 void LoadNavigationErrorPage(const blink::WebURLRequest& failed_request,
528 const blink::WebURLError& error,
529 bool replace);
530
[email protected]ae2477e2014-05-27 23:47:08531 // Initializes |web_user_media_client_|, returning true if successful. Returns
[email protected]96307312014-05-04 01:00:19532 // false if it wasn't possible to create a MediaStreamClient (e.g., WebRTC is
[email protected]ae2477e2014-05-27 23:47:08533 // disabled) in which case |web_user_media_client_| is NULL.
534 bool InitializeUserMediaClient();
[email protected]96307312014-05-04 01:00:19535
536 blink::WebMediaPlayer* CreateWebMediaPlayerForMediaStream(
537 const blink::WebURL& url,
538 blink::WebMediaPlayerClient* client);
539
[email protected]ae2477e2014-05-27 23:47:08540 // Creates a factory object used for creating audio and video renderers.
541 // The method is virtual so that layouttests can override it.
542 virtual scoped_ptr<MediaStreamRendererFactory> CreateRendererFactory();
543
[email protected]f3a95312014-06-12 16:46:58544 // Returns the URL being loaded by the |frame_|'s request.
545 GURL GetLoadingUrl() const;
546
[email protected]96307312014-05-04 01:00:19547#if defined(OS_ANDROID)
[email protected]65f3d1aa2014-05-29 01:57:00548 blink::WebMediaPlayer* CreateAndroidWebMediaPlayer(
[email protected]96307312014-05-04 01:00:19549 const blink::WebURL& url,
550 blink::WebMediaPlayerClient* client);
[email protected]a017938b2014-05-27 21:17:17551
[email protected]65f3d1aa2014-05-29 01:57:00552 RendererMediaPlayerManager* GetMediaPlayerManager();
[email protected]4b556cf2014-06-10 23:21:53553#endif
554
555#if defined(ENABLE_BROWSER_CDMS)
[email protected]65f3d1aa2014-05-29 01:57:00556 RendererCdmManager* GetCdmManager();
[email protected]96307312014-05-04 01:00:19557#endif
558
[email protected]35b2a972014-04-04 15:50:22559 // Stores the WebLocalFrame we are associated with.
560 blink::WebLocalFrame* frame_;
[email protected]b70da4c2014-01-06 19:57:09561
[email protected]abc501e2014-01-27 19:27:26562 base::WeakPtr<RenderViewImpl> render_view_;
[email protected]227692c52013-05-31 22:43:04563 int routing_id_;
[email protected]1c2052f2013-08-28 08:24:34564 bool is_swapped_out_;
[email protected]5a7100d2014-05-19 01:29:04565 // RenderFrameProxy exists only when is_swapped_out_ is true.
566 // TODO(nasko): This can be removed once we don't have a swapped out state on
567 // RenderFrame. See https://crbug.com/357747.
568 RenderFrameProxy* render_frame_proxy_;
[email protected]1c2052f2013-08-28 08:24:34569 bool is_detaching_;
[email protected]227692c52013-05-31 22:43:04570
[email protected]7a4e2532013-12-02 21:30:02571#if defined(ENABLE_PLUGINS)
[email protected]7a4e2532013-12-02 21:30:02572 // Current text input composition text. Empty if no composition is in
573 // progress.
[email protected]fcf75d42013-12-03 20:11:26574 base::string16 pepper_composition_text_;
[email protected]7a4e2532013-12-02 21:30:02575#endif
576
[email protected]f3add922013-12-20 23:17:16577 RendererWebCookieJarImpl cookie_jar_;
578
[email protected]2e2d9632013-12-03 00:55:26579 // All the registered observers.
580 ObserverList<RenderFrameObserver> observers_;
581
[email protected]bffc8302014-01-23 20:52:16582 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_;
583
[email protected]4ecee352014-03-11 21:12:19584 // The node that the context menu was pressed over.
585 blink::WebNode context_menu_node_;
586
[email protected]a09d53ce2014-01-31 00:46:42587 // External context menu requests we're waiting for. "Internal"
588 // (WebKit-originated) context menu events will have an ID of 0 and will not
589 // be in this map.
590 //
591 // We don't want to add internal ones since some of the "special" page
592 // handlers in the browser process just ignore the context menu requests so
593 // avoid showing context menus, and so this will cause right clicks to leak
594 // entries in this map. Most users of the custom context menu (e.g. Pepper
595 // plugins) are normally only on "regular" pages and the regular pages will
596 // always respond properly to the request, so we don't have to worry so
597 // much about leaks.
598 IDMap<ContextMenuClient, IDMapExternalPointer> pending_context_menus_;
599
[email protected]4ee64622014-03-21 22:34:15600 // The text selection the last time DidChangeSelection got called. May contain
601 // additional characters before and after the selected text, for IMEs. The
602 // portion of this string that is the actual selected text starts at index
603 // |selection_range_.GetMin() - selection_text_offset_| and has length
604 // |selection_range_.length()|.
605 base::string16 selection_text_;
606 // The offset corresponding to the start of |selection_text_| in the document.
607 size_t selection_text_offset_;
608 // Range over the document corresponding to the actual selected text (which
609 // could correspond to a substring of |selection_text_|; see above).
610 gfx::Range selection_range_;
611 // Used to inform didChangeSelection() when it is called in the context
612 // of handling a InputMsg_SelectRange IPC.
613 bool handling_select_range_;
614
[email protected]2626d142014-04-22 17:24:02615 // The next group of objects all implement RenderFrameObserver, so are deleted
616 // along with the RenderFrame automatically. This is why we just store weak
617 // references.
618
619 // Holds a reference to the service which provides desktop notifications.
620 NotificationProvider* notification_provider_;
621
[email protected]96307312014-05-04 01:00:19622 blink::WebUserMediaClient* web_user_media_client_;
623
[email protected]52d3e172014-06-16 16:57:02624 // MidiClient attached to this frame; lazily initialized.
625 MidiDispatcher* midi_dispatcher_;
626
[email protected]a017938b2014-05-27 21:17:17627#if defined(OS_ANDROID)
[email protected]4b556cf2014-06-10 23:21:53628 // Manages all media players in this render frame for communicating with the
629 // real media player in the browser process. It's okay to use a raw pointer
630 // since it's a RenderFrameObserver.
[email protected]a017938b2014-05-27 21:17:17631 RendererMediaPlayerManager* media_player_manager_;
[email protected]4b556cf2014-06-10 23:21:53632#endif
633
634#if defined(ENABLE_BROWSER_CDMS)
635 // Manage all CDMs in this render frame for communicating with the real CDM in
636 // the browser process. It's okay to use a raw pointer since it's a
637 // RenderFrameObserver.
[email protected]65f3d1aa2014-05-29 01:57:00638 RendererCdmManager* cdm_manager_;
[email protected]a017938b2014-05-27 21:17:17639#endif
640
[email protected]45920862014-07-02 12:53:02641 // The geolocation dispatcher attached to this frame, lazily initialized.
[email protected]8eae0802014-06-02 21:35:55642 GeolocationDispatcher* geolocation_dispatcher_;
643
[email protected]45920862014-07-02 12:53:02644 // The push messaging dispatcher attached to this frame, lazily initialized.
645 PushMessagingDispatcher* push_messaging_dispatcher_;
646
[email protected]c52a1412014-06-25 06:09:25647 ServiceRegistryImpl service_registry_;
648
[email protected]45920862014-07-02 12:53:02649 // The screen orientation dispatcher attached to the frame, lazily
650 // initialized.
[email protected]cf78eda2014-06-13 16:57:41651 ScreenOrientationDispatcher* screen_orientation_dispatcher_;
652
[email protected]96307312014-05-04 01:00:19653 base::WeakPtrFactory<RenderFrameImpl> weak_factory_;
654
[email protected]227692c52013-05-31 22:43:04655 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl);
656};
657
658} // namespace content
659
[email protected]85d85fd2013-06-19 00:57:41660#endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_