blob: 554799d252ab6e479680262d05356c5fbd3a3235 [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]95640212014-07-26 18:14:3017#include "content/common/accessibility_mode_enums.h"
[email protected]c52a1412014-06-25 06:09:2518#include "content/common/mojo/service_registry_impl.h"
[email protected]87de04b02014-04-08 22:14:4919#include "content/public/common/javascript_message_type.h"
[email protected]65920f332014-03-04 21:14:1820#include "content/public/common/referrer.h"
[email protected]227692c52013-05-31 22:43:0421#include "content/public/renderer/render_frame.h"
[email protected]96307312014-05-04 01:00:1922#include "content/renderer/media/webmediaplayer_delegate.h"
[email protected]5a7100d2014-05-19 01:29:0423#include "content/renderer/render_frame_proxy.h"
[email protected]f3add922013-12-20 23:17:1624#include "content/renderer/renderer_webcookiejar_impl.h"
[email protected]227692c52013-05-31 22:43:0425#include "ipc/ipc_message.h"
[email protected]95640212014-07-26 18:14:3026#include "third_party/WebKit/public/web/WebAXObject.h"
[email protected]85d85fd2013-06-19 00:57:4127#include "third_party/WebKit/public/web/WebDataSource.h"
28#include "third_party/WebKit/public/web/WebFrameClient.h"
[email protected]680575542014-04-03 17:12:5229#include "third_party/WebKit/public/web/WebHistoryCommitType.h"
[email protected]4ee64622014-03-21 22:34:1530#include "ui/gfx/range/range.h"
[email protected]227692c52013-05-31 22:43:0431
[email protected]a017938b2014-05-27 21:17:1732#if defined(OS_ANDROID)
33#include "content/renderer/media/android/renderer_media_player_manager.h"
34#endif
35
[email protected]7a4e2532013-12-02 21:30:0236class TransportDIB;
[email protected]c6bc20332014-02-28 18:30:3937struct FrameMsg_Navigate_Params;
[email protected]7a4e2532013-12-02 21:30:0238
39namespace blink {
[email protected]5ee7f182014-04-25 19:45:2640class WebGeolocationClient;
[email protected]5cdd8fd82014-02-05 20:12:1241class WebInputEvent;
[email protected]7a4e2532013-12-02 21:30:0242class WebMouseEvent;
[email protected]82ce5b92014-03-22 05:15:2643class WebContentDecryptionModule;
[email protected]96307312014-05-04 01:00:1944class WebMediaPlayer;
[email protected]1c048252014-04-11 23:27:3445class WebNotificationPresenter;
[email protected]45920862014-07-02 12:53:0246class WebPushClient;
[email protected]82ce5b92014-03-22 05:15:2647class WebSecurityOrigin;
[email protected]7a4e2532013-12-02 21:30:0248struct WebCompositionUnderline;
[email protected]a09d53ce2014-01-31 00:46:4249struct WebContextMenuData;
[email protected]7a4e2532013-12-02 21:30:0250struct WebCursorInfo;
51}
52
53namespace gfx {
[email protected]a09d53ce2014-01-31 00:46:4254class Point;
[email protected]7a4e2532013-12-02 21:30:0255class Range;
56class Rect;
57}
58
[email protected]227692c52013-05-31 22:43:0459namespace content {
60
[email protected]bffc8302014-01-23 20:52:1661class ChildFrameCompositingHelper;
[email protected]8eae0802014-06-02 21:35:5562class GeolocationDispatcher;
[email protected]977db4a42014-07-17 08:04:3263class MediaStreamDispatcher;
64class MediaStreamImpl;
[email protected]ae2477e2014-05-27 23:47:0865class MediaStreamRendererFactory;
[email protected]52d3e172014-06-16 16:57:0266class MidiDispatcher;
[email protected]4459599e2014-07-29 22:40:0967class NotificationPermissionDispatcher;
[email protected]2626d142014-04-22 17:24:0268class NotificationProvider;
[email protected]7a4e2532013-12-02 21:30:0269class PepperPluginInstanceImpl;
[email protected]45920862014-07-02 12:53:0270class PushMessagingDispatcher;
[email protected]95640212014-07-26 18:14:3071class RendererAccessibility;
[email protected]4b556cf2014-06-10 23:21:5372class RendererCdmManager;
73class RendererMediaPlayerManager;
[email protected]7a4e2532013-12-02 21:30:0274class RendererPpapiHost;
[email protected]2e2d9632013-12-03 00:55:2675class RenderFrameObserver;
[email protected]227692c52013-05-31 22:43:0476class RenderViewImpl;
[email protected]7a4e2532013-12-02 21:30:0277class RenderWidget;
78class RenderWidgetFullscreenPepper;
[email protected]cf78eda2014-06-13 16:57:4179class ScreenOrientationDispatcher;
[email protected]a09d53ce2014-01-31 00:46:4280struct CustomContextMenuContext;
[email protected]227692c52013-05-31 22:43:0481
[email protected]85d85fd2013-06-19 00:57:4182class CONTENT_EXPORT RenderFrameImpl
83 : public RenderFrame,
[email protected]96307312014-05-04 01:00:1984 NON_EXPORTED_BASE(public blink::WebFrameClient),
85 NON_EXPORTED_BASE(public WebMediaPlayerDelegate) {
[email protected]227692c52013-05-31 22:43:0486 public:
[email protected]2f61bdd2013-07-02 18:38:4787 // Creates a new RenderFrame. |render_view| is the RenderView object that this
88 // frame belongs to.
[email protected]b70da4c2014-01-06 19:57:0989 // Callers *must* call |SetWebFrame| immediately after creation.
90 // TODO(creis): We should structure this so that |SetWebFrame| isn't needed.
[email protected]2f61bdd2013-07-02 18:38:4791 static RenderFrameImpl* Create(RenderViewImpl* render_view, int32 routing_id);
92
[email protected]5a7100d2014-05-19 01:29:0493 // Returns the RenderFrameImpl for the given routing ID.
94 static RenderFrameImpl* FromRoutingID(int routing_id);
95
[email protected]a5ac6dc2014-01-15 07:02:1496 // Just like RenderFrame::FromWebFrame but returns the implementation.
97 static RenderFrameImpl* FromWebFrame(blink::WebFrame* web_frame);
[email protected]b70da4c2014-01-06 19:57:0998
[email protected]2f61bdd2013-07-02 18:38:4799 // Used by content_layouttest_support to hook into the creation of
100 // RenderFrameImpls.
101 static void InstallCreateHook(
102 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32));
103
[email protected]227692c52013-05-31 22:43:04104 virtual ~RenderFrameImpl();
105
[email protected]b70da4c2014-01-06 19:57:09106 bool is_swapped_out() const {
107 return is_swapped_out_;
108 }
109
[email protected]5a7100d2014-05-19 01:29:04110 // TODO(nasko): This can be removed once we don't have a swapped out state on
111 // RenderFrames. See https://crbug.com/357747.
112 void set_render_frame_proxy(RenderFrameProxy* proxy) {
113 render_frame_proxy_ = proxy;
114 }
115
[email protected]bffc8302014-01-23 20:52:16116 // Out-of-process child frames receive a signal from RenderWidgetCompositor
117 // when a compositor frame has committed.
118 void DidCommitCompositorFrame();
119
[email protected]7a4e2532013-12-02 21:30:02120 // TODO(jam): this is a temporary getter until all the code is transitioned
121 // to using RenderFrame instead of RenderView.
[email protected]abc501e2014-01-27 19:27:26122 RenderViewImpl* render_view() { return render_view_.get(); }
[email protected]7a4e2532013-12-02 21:30:02123
[email protected]f3add922013-12-20 23:17:16124 RendererWebCookieJarImpl* cookie_jar() { return &cookie_jar_; }
125
[email protected]7a4e2532013-12-02 21:30:02126 // Returns the RenderWidget associated with this frame.
127 RenderWidget* GetRenderWidget();
128
[email protected]35b2a972014-04-04 15:50:22129 // This is called right after creation with the WebLocalFrame for this
[email protected]0287e762014-04-11 13:07:58130 // RenderFrame. It must be called before Initialize.
[email protected]35b2a972014-04-04 15:50:22131 void SetWebFrame(blink::WebLocalFrame* web_frame);
[email protected]b70da4c2014-01-06 19:57:09132
[email protected]0287e762014-04-11 13:07:58133 // This method must be called after the frame has been added to the frame
134 // tree. It creates all objects that depend on the frame being at its proper
135 // spot.
136 void Initialize();
137
[email protected]5815cf52014-01-29 17:45:05138 // Notification from RenderView.
139 virtual void OnStop();
140
[email protected]de3c5d82014-05-28 22:12:59141 // Notifications from RenderWidget.
142 void WasHidden();
143 void WasShown();
144
[email protected]723971b2014-02-12 11:08:25145 // Start/Stop loading notifications.
146 // TODO(nasko): Those are page-level methods at this time and come from
147 // WebViewClient. We should move them to be WebFrameClient calls and put
148 // logic in the browser side to balance starts/stops.
[email protected]e3b10d12014-03-28 16:06:09149 // |to_different_document| will be true unless the load is a fragment
150 // navigation, or triggered by history.pushState/replaceState.
[email protected]6dd5c322014-03-12 07:58:46151 virtual void didStartLoading(bool to_different_document);
152 virtual void didStopLoading();
153 virtual void didChangeLoadProgress(double load_progress);
[email protected]723971b2014-02-12 11:08:25154
[email protected]95640212014-07-26 18:14:30155 AccessibilityMode accessibility_mode() {
156 return accessibility_mode_;
157 }
158
159 RendererAccessibility* renderer_accessibility() {
160 return renderer_accessibility_;
161 }
162
163 void HandleWebAccessibilityEvent(const blink::WebAXObject& obj,
164 blink::WebAXEvent event);
165
166 // TODO(dmazzoni): the only reason this is here is to plumb it through to
167 // RendererAccessibility. It should be part of RenderFrameObserver, once
168 // blink has a separate accessibility tree per frame.
169 void FocusedNodeChanged(const blink::WebNode& node);
170
[email protected]7a4e2532013-12-02 21:30:02171#if defined(ENABLE_PLUGINS)
[email protected]271ff5792013-12-04 22:29:31172 // Notification that a PPAPI plugin has been created.
173 void PepperPluginCreated(RendererPpapiHost* host);
174
[email protected]7a4e2532013-12-02 21:30:02175 // Notifies that |instance| has changed the cursor.
176 // This will update the cursor appearance if it is currently over the plugin
177 // instance.
178 void PepperDidChangeCursor(PepperPluginInstanceImpl* instance,
179 const blink::WebCursorInfo& cursor);
180
181 // Notifies that |instance| has received a mouse event.
182 void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl* instance);
183
[email protected]7a4e2532013-12-02 21:30:02184 // Informs the render view that a PPAPI plugin has changed text input status.
185 void PepperTextInputTypeChanged(PepperPluginInstanceImpl* instance);
186 void PepperCaretPositionChanged(PepperPluginInstanceImpl* instance);
187
188 // Cancels current composition.
189 void PepperCancelComposition(PepperPluginInstanceImpl* instance);
190
191 // Informs the render view that a PPAPI plugin has changed selection.
192 void PepperSelectionChanged(PepperPluginInstanceImpl* instance);
193
194 // Creates a fullscreen container for a pepper plugin instance.
195 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
196 PepperPluginInstanceImpl* plugin);
197
[email protected]7a4e2532013-12-02 21:30:02198 bool IsPepperAcceptingCompositionEvents() const;
199
200 // Notification that the given plugin has crashed.
201 void PluginCrashed(const base::FilePath& plugin_path,
202 base::ProcessId plugin_pid);
203
[email protected]7a4e2532013-12-02 21:30:02204 // Simulates IME events for testing purpose.
205 void SimulateImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26206 const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02207 const std::vector<blink::WebCompositionUnderline>& underlines,
208 int selection_start,
209 int selection_end);
[email protected]fcf75d42013-12-03 20:11:26210 void SimulateImeConfirmComposition(const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02211 const gfx::Range& replacement_range);
212
213 // TODO(jam): remove these once the IPC handler moves from RenderView to
214 // RenderFrame.
215 void OnImeSetComposition(
[email protected]fcf75d42013-12-03 20:11:26216 const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02217 const std::vector<blink::WebCompositionUnderline>& underlines,
218 int selection_start,
219 int selection_end);
220 void OnImeConfirmComposition(
[email protected]fcf75d42013-12-03 20:11:26221 const base::string16& text,
[email protected]7a4e2532013-12-02 21:30:02222 const gfx::Range& replacement_range,
223 bool keep_selection);
[email protected]7a4e2532013-12-02 21:30:02224#endif // ENABLE_PLUGINS
225
[email protected]977db4a42014-07-17 08:04:32226 // May return NULL in some cases, especially if userMediaClient() returns
227 // NULL.
228 MediaStreamDispatcher* GetMediaStreamDispatcher();
229
[email protected]227692c52013-05-31 22:43:04230 // IPC::Sender
231 virtual bool Send(IPC::Message* msg) OVERRIDE;
232
233 // IPC::Listener
234 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
235
[email protected]271ff5792013-12-04 22:29:31236 // RenderFrame implementation:
[email protected]b849847b2013-12-10 21:57:58237 virtual RenderView* GetRenderView() OVERRIDE;
[email protected]60eca4eb2013-12-06 00:02:16238 virtual int GetRoutingID() OVERRIDE;
[email protected]a5ac6dc2014-01-15 07:02:14239 virtual blink::WebFrame* GetWebFrame() OVERRIDE;
[email protected]d019e1a382013-12-11 17:52:06240 virtual WebPreferences& GetWebkitPreferences() OVERRIDE;
241 virtual int ShowContextMenu(ContextMenuClient* client,
242 const ContextMenuParams& params) OVERRIDE;
243 virtual void CancelContextMenu(int request_id) OVERRIDE;
[email protected]1a6d0112014-03-10 19:08:41244 virtual blink::WebNode GetContextMenuNode() const OVERRIDE;
[email protected]271ff5792013-12-04 22:29:31245 virtual blink::WebPlugin* CreatePlugin(
246 blink::WebFrame* frame,
247 const WebPluginInfo& info,
248 const blink::WebPluginParams& params) OVERRIDE;
[email protected]35b2a972014-04-04 15:50:22249 virtual void LoadURLExternally(blink::WebLocalFrame* frame,
250 const blink::WebURLRequest& request,
251 blink::WebNavigationPolicy policy) OVERRIDE;
[email protected]db3be76f2014-03-25 02:27:47252 virtual void ExecuteJavaScript(const base::string16& javascript) OVERRIDE;
[email protected]291abdb2014-06-05 14:19:11253 virtual bool IsHidden() OVERRIDE;
[email protected]c52a1412014-06-25 06:09:25254 virtual ServiceRegistry* GetServiceRegistry() OVERRIDE;
[email protected]59e94c162014-07-23 06:27:08255 virtual bool IsFTPDirectoryListing() OVERRIDE;
[email protected]271ff5792013-12-04 22:29:31256
[email protected]96307312014-05-04 01:00:19257 // blink::WebFrameClient implementation:
[email protected]35b2a972014-04-04 15:50:22258 virtual blink::WebPlugin* createPlugin(blink::WebLocalFrame* frame,
259 const blink::WebPluginParams& params);
[email protected]180ef242013-11-07 06:50:46260 virtual blink::WebMediaPlayer* createMediaPlayer(
[email protected]35b2a972014-04-04 15:50:22261 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46262 const blink::WebURL& url,
263 blink::WebMediaPlayerClient* client);
[email protected]82ce5b92014-03-22 05:15:26264 virtual blink::WebContentDecryptionModule* createContentDecryptionModule(
[email protected]35b2a972014-04-04 15:50:22265 blink::WebLocalFrame* frame,
[email protected]82ce5b92014-03-22 05:15:26266 const blink::WebSecurityOrigin& security_origin,
267 const blink::WebString& key_system);
[email protected]180ef242013-11-07 06:50:46268 virtual blink::WebApplicationCacheHost* createApplicationCacheHost(
[email protected]35b2a972014-04-04 15:50:22269 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46270 blink::WebApplicationCacheHostClient* client);
271 virtual blink::WebWorkerPermissionClientProxy*
[email protected]35b2a972014-04-04 15:50:22272 createWorkerPermissionClientProxy(blink::WebLocalFrame* frame);
273 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame);
[email protected]180ef242013-11-07 06:50:46274 virtual blink::WebServiceWorkerProvider* createServiceWorkerProvider(
[email protected]35b2a972014-04-04 15:50:22275 blink::WebLocalFrame* frame);
276 virtual void didAccessInitialDocument(blink::WebLocalFrame* frame);
277 virtual blink::WebFrame* createChildFrame(blink::WebLocalFrame* parent,
278 const blink::WebString& name);
279 virtual void didDisownOpener(blink::WebLocalFrame* frame);
[email protected]180ef242013-11-07 06:50:46280 virtual void frameDetached(blink::WebFrame* frame);
[email protected]9c9343b2014-03-08 02:56:07281 virtual void frameFocused();
[email protected]180ef242013-11-07 06:50:46282 virtual void willClose(blink::WebFrame* frame);
[email protected]35b2a972014-04-04 15:50:22283 virtual void didChangeName(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46284 const blink::WebString& name);
[email protected]f5b6dd1122013-10-04 02:42:50285 virtual void didMatchCSS(
[email protected]35b2a972014-04-04 15:50:22286 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46287 const blink::WebVector<blink::WebString>& newly_matching_selectors,
288 const blink::WebVector<blink::WebString>& stopped_matching_selectors);
[email protected]c31a84802014-04-03 15:55:49289 virtual bool shouldReportDetailedMessageForSource(
290 const blink::WebString& source);
291 virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message,
292 const blink::WebString& source_name,
293 unsigned source_line,
294 const blink::WebString& stack_trace);
[email protected]35b2a972014-04-04 15:50:22295 virtual void loadURLExternally(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46296 const blink::WebURLRequest& request,
[email protected]35b2a972014-04-04 15:50:22297 blink::WebNavigationPolicy policy,
298 const blink::WebString& suggested_name);
[email protected]1a4e9752013-12-31 20:10:58299 // The WebDataSource::ExtraData* is assumed to be a DocumentState* subclass.
[email protected]180ef242013-11-07 06:50:46300 virtual blink::WebNavigationPolicy decidePolicyForNavigation(
[email protected]35b2a972014-04-04 15:50:22301 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46302 blink::WebDataSource::ExtraData* extra_data,
303 const blink::WebURLRequest& request,
304 blink::WebNavigationType type,
305 blink::WebNavigationPolicy default_policy,
[email protected]f6ae17fc2013-08-19 22:56:17306 bool is_redirect);
[email protected]680575542014-04-03 17:12:52307 virtual blink::WebHistoryItem historyItemForNewChildFrame(
308 blink::WebFrame* frame);
[email protected]35b2a972014-04-04 15:50:22309 virtual void willSendSubmitEvent(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46310 const blink::WebFormElement& form);
[email protected]35b2a972014-04-04 15:50:22311 virtual void willSubmitForm(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46312 const blink::WebFormElement& form);
[email protected]35b2a972014-04-04 15:50:22313 virtual void didCreateDataSource(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46314 blink::WebDataSource* datasource);
[email protected]35b2a972014-04-04 15:50:22315 virtual void didStartProvisionalLoad(blink::WebLocalFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41316 virtual void didReceiveServerRedirectForProvisionalLoad(
[email protected]45d877f2014-04-05 07:36:22317 blink::WebLocalFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41318 virtual void didFailProvisionalLoad(
[email protected]45d877f2014-04-05 07:36:22319 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46320 const blink::WebURLError& error);
[email protected]680575542014-04-03 17:12:52321 virtual void didCommitProvisionalLoad(
[email protected]45d877f2014-04-05 07:36:22322 blink::WebLocalFrame* frame,
[email protected]680575542014-04-03 17:12:52323 const blink::WebHistoryItem& item,
324 blink::WebHistoryCommitType commit_type);
[email protected]06181e52014-05-10 11:59:09325 virtual void didClearWindowObject(blink::WebLocalFrame* frame);
[email protected]35b2a972014-04-04 15:50:22326 virtual void didCreateDocumentElement(blink::WebLocalFrame* frame);
327 virtual void didReceiveTitle(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46328 const blink::WebString& title,
329 blink::WebTextDirection direction);
[email protected]35b2a972014-04-04 15:50:22330 virtual void didChangeIcon(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46331 blink::WebIconURL::Type icon_type);
[email protected]35b2a972014-04-04 15:50:22332 virtual void didFinishDocumentLoad(blink::WebLocalFrame* frame);
333 virtual void didHandleOnloadEvents(blink::WebLocalFrame* frame);
334 virtual void didFailLoad(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46335 const blink::WebURLError& error);
[email protected]45d877f2014-04-05 07:36:22336 virtual void didFinishLoad(blink::WebLocalFrame* frame);
337 virtual void didNavigateWithinPage(blink::WebLocalFrame* frame,
[email protected]680575542014-04-03 17:12:52338 const blink::WebHistoryItem& item,
339 blink::WebHistoryCommitType commit_type);
[email protected]35b2a972014-04-04 15:50:22340 virtual void didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame);
[email protected]37b64c52014-07-11 21:14:05341 virtual void didChangeThemeColor();
[email protected]4459599e2014-07-29 22:40:09342 virtual void requestNotificationPermission(
343 const blink::WebSecurityOrigin& origin,
344 blink::WebNotificationPermissionCallback* callback);
[email protected]1c048252014-04-11 23:27:34345 virtual blink::WebNotificationPresenter* notificationPresenter();
[email protected]c3f2c702014-03-19 23:39:48346 virtual void didChangeSelection(bool is_empty_selection);
[email protected]f3c59d62014-04-09 16:33:55347 virtual blink::WebColorChooser* createColorChooser(
[email protected]eb8c216a2014-04-09 19:19:19348 blink::WebColorChooserClient* client,
[email protected]f3c59d62014-04-09 16:33:55349 const blink::WebColor& initial_color,
350 const blink::WebVector<blink::WebColorSuggestion>& suggestions);
[email protected]87de04b02014-04-08 22:14:49351 virtual void runModalAlertDialog(const blink::WebString& message);
352 virtual bool runModalConfirmDialog(const blink::WebString& message);
353 virtual bool runModalPromptDialog(const blink::WebString& message,
354 const blink::WebString& default_value,
355 blink::WebString* actual_value);
356 virtual bool runModalBeforeUnloadDialog(bool is_reload,
357 const blink::WebString& message);
[email protected]12cc5112014-03-03 17:01:10358 virtual void showContextMenu(const blink::WebContextMenuData& data);
[email protected]91070342014-03-07 00:29:02359 virtual void clearContextMenu();
[email protected]35b2a972014-04-04 15:50:22360 virtual void willSendRequest(blink::WebLocalFrame* frame,
361 unsigned identifier,
362 blink::WebURLRequest& request,
363 const blink::WebURLResponse& redirect_response);
364 virtual void didReceiveResponse(blink::WebLocalFrame* frame,
365 unsigned identifier,
366 const blink::WebURLResponse& response);
367 virtual void didFinishResourceLoad(blink::WebLocalFrame* frame,
[email protected]255eea092013-06-28 17:19:14368 unsigned identifier);
[email protected]85d85fd2013-06-19 00:57:41369 virtual void didLoadResourceFromMemoryCache(
[email protected]35b2a972014-04-04 15:50:22370 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46371 const blink::WebURLRequest& request,
372 const blink::WebURLResponse& response);
[email protected]35b2a972014-04-04 15:50:22373 virtual void didDisplayInsecureContent(blink::WebLocalFrame* frame);
374 virtual void didRunInsecureContent(blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46375 const blink::WebSecurityOrigin& origin,
376 const blink::WebURL& target);
[email protected]5d749572014-07-17 09:43:40377 virtual void didDetectXSS(blink::WebLocalFrame* frame,
378 const blink::WebURL& url,
379 bool blocked_entire_page);
[email protected]35b2a972014-04-04 15:50:22380 virtual void didAbortLoading(blink::WebLocalFrame* frame);
381 virtual void didCreateScriptContext(blink::WebLocalFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41382 v8::Handle<v8::Context> context,
383 int extension_group,
[email protected]255eea092013-06-28 17:19:14384 int world_id);
[email protected]35b2a972014-04-04 15:50:22385 virtual void willReleaseScriptContext(blink::WebLocalFrame* frame,
[email protected]85d85fd2013-06-19 00:57:41386 v8::Handle<v8::Context> context,
[email protected]255eea092013-06-28 17:19:14387 int world_id);
[email protected]35b2a972014-04-04 15:50:22388 virtual void didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame);
[email protected]35b2a972014-04-04 15:50:22389 virtual void didChangeScrollOffset(blink::WebLocalFrame* frame);
390 virtual void willInsertBody(blink::WebLocalFrame* frame);
[email protected]85d85fd2013-06-19 00:57:41391 virtual void reportFindInPageMatchCount(int request_id,
392 int count,
[email protected]255eea092013-06-28 17:19:14393 bool final_update);
[email protected]85d85fd2013-06-19 00:57:41394 virtual void reportFindInPageSelection(int request_id,
395 int active_match_ordinal,
[email protected]180ef242013-11-07 06:50:46396 const blink::WebRect& sel);
[email protected]35b2a972014-04-04 15:50:22397 virtual void requestStorageQuota(blink::WebLocalFrame* frame,
398 blink::WebStorageQuotaType type,
399 unsigned long long requested_size,
400 blink::WebStorageQuotaCallbacks callbacks);
[email protected]85d85fd2013-06-19 00:57:41401 virtual void willOpenSocketStream(
[email protected]180ef242013-11-07 06:50:46402 blink::WebSocketStreamHandle* handle);
[email protected]a14903e02014-06-02 07:35:12403 virtual void willOpenWebSocket(blink::WebSocketHandle* handle);
[email protected]5ee7f182014-04-25 19:45:26404 virtual blink::WebGeolocationClient* geolocationClient();
[email protected]45920862014-07-02 12:53:02405 virtual blink::WebPushClient* pushClient();
[email protected]85d85fd2013-06-19 00:57:41406 virtual void willStartUsingPeerConnectionHandler(
[email protected]35b2a972014-04-04 15:50:22407 blink::WebLocalFrame* frame,
[email protected]180ef242013-11-07 06:50:46408 blink::WebRTCPeerConnectionHandler* handler);
[email protected]bfe45e22014-04-25 16:47:53409 virtual blink::WebUserMediaClient* userMediaClient();
[email protected]8538385f2014-04-25 19:45:04410 virtual blink::WebMIDIClient* webMIDIClient();
[email protected]85d85fd2013-06-19 00:57:41411 virtual bool willCheckAndDispatchMessageEvent(
[email protected]ce5064f2014-05-07 22:49:20412 blink::WebLocalFrame* source_frame,
413 blink::WebFrame* target_frame,
414 blink::WebSecurityOrigin target_origin,
[email protected]180ef242013-11-07 06:50:46415 blink::WebDOMMessageEvent event);
[email protected]35b2a972014-04-04 15:50:22416 virtual blink::WebString userAgentOverride(blink::WebLocalFrame* frame,
417 const blink::WebURL& url);
418 virtual blink::WebString doNotTrackValue(blink::WebLocalFrame* frame);
419 virtual bool allowWebGL(blink::WebLocalFrame* frame, bool default_value);
420 virtual void didLoseWebGLContext(blink::WebLocalFrame* frame,
[email protected]255eea092013-06-28 17:19:14421 int arb_robustness_status_code);
[email protected]5cdd8fd82014-02-05 20:12:12422 virtual void forwardInputEvent(const blink::WebInputEvent* event);
[email protected]9ef43adc2014-02-19 08:02:15423 virtual void initializeChildFrame(const blink::WebRect& frame_rect,
424 float scale_factor);
[email protected]cf78eda2014-06-13 16:57:41425 virtual blink::WebScreenOrientationClient* webScreenOrientationClient();
[email protected]85d85fd2013-06-19 00:57:41426
[email protected]96307312014-05-04 01:00:19427 // WebMediaPlayerDelegate implementation:
428 virtual void DidPlay(blink::WebMediaPlayer* player) OVERRIDE;
429 virtual void DidPause(blink::WebMediaPlayer* player) OVERRIDE;
430 virtual void PlayerGone(blink::WebMediaPlayer* player) OVERRIDE;
431
[email protected]c6bc20332014-02-28 18:30:39432 // TODO(nasko): Make all tests in RenderViewImplTest friends and then move
433 // this back to private member.
434 void OnNavigate(const FrameMsg_Navigate_Params& params);
435
[email protected]c52a1412014-06-25 06:09:25436 // Binds this render frame's service registry to a handle to the remote
437 // service registry.
438 void BindServiceRegistry(
439 mojo::ScopedMessagePipeHandle service_provider_handle);
440
[email protected]2f61bdd2013-07-02 18:38:47441 protected:
442 RenderFrameImpl(RenderViewImpl* render_view, int32 routing_id);
443
[email protected]227692c52013-05-31 22:43:04444 private:
[email protected]2e2d9632013-12-03 00:55:26445 friend class RenderFrameObserver;
[email protected]95640212014-07-26 18:14:30446 friend class RendererAccessibilityTest;
[email protected]66bbadaf2014-03-28 16:25:54447 FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest,
448 AccessibilityMessagesQueueWhileSwappedOut);
[email protected]ae2477e2014-05-27 23:47:08449 FRIEND_TEST_ALL_PREFIXES(RenderFrameImplTest,
[email protected]a09d53ce2014-01-31 00:46:42450 ShouldUpdateSelectionTextFromContextMenuParams);
[email protected]4ee64622014-03-21 22:34:15451 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
452 OnExtendSelectionAndDelete);
[email protected]66bbadaf2014-03-28 16:25:54453 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ReloadWhileSwappedOut);
454 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SendSwapOutACK);
[email protected]4ee64622014-03-21 22:34:15455 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
456 SetEditableSelectionAndComposition);
[email protected]95640212014-07-26 18:14:30457 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
458 OnSetAccessibilityMode);
[email protected]2e2d9632013-12-03 00:55:26459
[email protected]37567b432014-02-12 01:12:22460 typedef std::map<GURL, double> HostZoomLevels;
461
[email protected]2e2d9632013-12-03 00:55:26462 // Functions to add and remove observers for this object.
463 void AddObserver(RenderFrameObserver* observer);
464 void RemoveObserver(RenderFrameObserver* observer);
[email protected]1c2052f2013-08-28 08:24:34465
[email protected]37567b432014-02-12 01:12:22466 void UpdateURL(blink::WebFrame* frame);
467
[email protected]9c9343b2014-03-08 02:56:07468 // Gets the focused element. If no such element exists then the element will
469 // be NULL.
470 blink::WebElement GetFocusedElement();
471
[email protected]b70da4c2014-01-06 19:57:09472 // IPC message handlers ------------------------------------------------------
473 //
474 // The documentation for these functions should be in
475 // content/common/*_messages.h for the message that the function is handling.
[email protected]f76f32232014-03-11 17:36:17476 void OnBeforeUnload();
[email protected]5a7100d2014-05-19 01:29:04477 void OnSwapOut(int proxy_routing_id);
[email protected]a09d53ce2014-01-31 00:46:42478 void OnShowContextMenu(const gfx::Point& location);
479 void OnContextMenuClosed(const CustomContextMenuContext& custom_context);
480 void OnCustomContextMenuAction(const CustomContextMenuContext& custom_context,
481 unsigned action);
[email protected]4ee64622014-03-21 22:34:15482 void OnUndo();
483 void OnRedo();
[email protected]9c9343b2014-03-08 02:56:07484 void OnCut();
485 void OnCopy();
486 void OnPaste();
[email protected]4ee64622014-03-21 22:34:15487 void OnPasteAndMatchStyle();
488 void OnDelete();
489 void OnSelectAll();
490 void OnSelectRange(const gfx::Point& start, const gfx::Point& end);
491 void OnUnselect();
[email protected]1f3fc1d2014-04-03 14:50:17492 void OnReplace(const base::string16& text);
493 void OnReplaceMisspelling(const base::string16& text);
[email protected]e31b8ebb2014-03-07 17:59:34494 void OnCSSInsertRequest(const std::string& css);
[email protected]f13ab892014-03-12 06:48:52495 void OnJavaScriptExecuteRequest(const base::string16& javascript,
496 int id,
497 bool notify_result);
[email protected]4ee64622014-03-21 22:34:15498 void OnSetEditableSelectionOffsets(int start, int end);
[email protected]e5e438d62014-03-27 21:47:16499 void OnSetCompositionFromExistingText(
500 int start, int end,
501 const std::vector<blink::WebCompositionUnderline>& underlines);
502 void OnExtendSelectionAndDelete(int before, int after);
[email protected]4fed3702014-04-01 09:08:00503 void OnReload(bool ignore_cache);
[email protected]96bb6132014-06-16 17:22:19504 void OnTextSurroundingSelectionRequest(size_t max_length);
[email protected]2e531f72014-06-20 23:23:39505 void OnAddStyleSheetByURL(const std::string& url);
[email protected]95640212014-07-26 18:14:30506 void OnSetAccessibilityMode(AccessibilityMode new_mode);
[email protected]4ee64622014-03-21 22:34:15507#if defined(OS_MACOSX)
508 void OnCopyToFindPboard();
509#endif
[email protected]9c9343b2014-03-08 02:56:07510
[email protected]65920f332014-03-04 21:14:18511 // Virtual since overridden by WebTestProxy for layout tests.
512 virtual blink::WebNavigationPolicy DecidePolicyForNavigation(
513 RenderFrame* render_frame,
514 blink::WebFrame* frame,
515 blink::WebDataSource::ExtraData* extraData,
516 const blink::WebURLRequest& request,
517 blink::WebNavigationType type,
518 blink::WebNavigationPolicy default_policy,
519 bool is_redirect);
520 void OpenURL(blink::WebFrame* frame,
521 const GURL& url,
522 const Referrer& referrer,
523 blink::WebNavigationPolicy policy);
[email protected]a09d53ce2014-01-31 00:46:42524
[email protected]ef3adfc2014-05-11 00:04:54525 // Update current main frame's encoding and send it to browser window.
526 // Since we want to let users see the right encoding info from menu
527 // before finishing loading, we call the UpdateEncoding in
528 // a) function:DidCommitLoadForFrame. When this function is called,
529 // that means we have got first data. In here we try to get encoding
530 // of page if it has been specified in http header.
531 // b) function:DidReceiveTitle. When this function is called,
532 // that means we have got specified title. Because in most of webpages,
533 // title tags will follow meta tags. In here we try to get encoding of
534 // page if it has been specified in meta tag.
535 // c) function:DidFinishDocumentLoadForFrame. When this function is
536 // called, that means we have got whole html page. In here we should
537 // finally get right encoding of page.
538 void UpdateEncoding(blink::WebFrame* frame,
539 const std::string& encoding_name);
540
[email protected]4ee64622014-03-21 22:34:15541 // Dispatches the current state of selection on the webpage to the browser if
542 // it has changed.
543 // TODO(varunjain): delete this method once we figure out how to keep
544 // selection handles in sync with the webpage.
545 void SyncSelectionIfRequired();
546
[email protected]a09d53ce2014-01-31 00:46:42547 // Returns whether |params.selection_text| should be synchronized to the
548 // browser before bringing up the context menu. Static for testing.
549 static bool ShouldUpdateSelectionTextFromContextMenuParams(
550 const base::string16& selection_text,
551 size_t selection_text_offset,
552 const gfx::Range& selection_range,
553 const ContextMenuParams& params);
[email protected]b70da4c2014-01-06 19:57:09554
[email protected]87de04b02014-04-08 22:14:49555 bool RunJavaScriptMessage(JavaScriptMessageType type,
556 const base::string16& message,
557 const base::string16& default_value,
558 const GURL& frame_url,
559 base::string16* result);
560
[email protected]457736d2014-04-30 15:54:27561 // Loads the appropriate error page for the specified failure into the frame.
562 void LoadNavigationErrorPage(const blink::WebURLRequest& failed_request,
563 const blink::WebURLError& error,
564 bool replace);
565
[email protected]977db4a42014-07-17 08:04:32566 // Initializes |web_user_media_client_|. If this fails, because it wasn't
567 // possible to create a MediaStreamClient (e.g., WebRTC is disabled), then
568 // |web_user_media_client_| will remain NULL.
569 void InitializeUserMediaClient();
[email protected]96307312014-05-04 01:00:19570
571 blink::WebMediaPlayer* CreateWebMediaPlayerForMediaStream(
572 const blink::WebURL& url,
573 blink::WebMediaPlayerClient* client);
574
[email protected]ae2477e2014-05-27 23:47:08575 // Creates a factory object used for creating audio and video renderers.
576 // The method is virtual so that layouttests can override it.
577 virtual scoped_ptr<MediaStreamRendererFactory> CreateRendererFactory();
578
[email protected]f3a95312014-06-12 16:46:58579 // Returns the URL being loaded by the |frame_|'s request.
580 GURL GetLoadingUrl() const;
581
[email protected]96307312014-05-04 01:00:19582#if defined(OS_ANDROID)
[email protected]65f3d1aa2014-05-29 01:57:00583 blink::WebMediaPlayer* CreateAndroidWebMediaPlayer(
[email protected]96307312014-05-04 01:00:19584 const blink::WebURL& url,
585 blink::WebMediaPlayerClient* client);
[email protected]a017938b2014-05-27 21:17:17586
[email protected]65f3d1aa2014-05-29 01:57:00587 RendererMediaPlayerManager* GetMediaPlayerManager();
[email protected]4b556cf2014-06-10 23:21:53588#endif
589
590#if defined(ENABLE_BROWSER_CDMS)
[email protected]65f3d1aa2014-05-29 01:57:00591 RendererCdmManager* GetCdmManager();
[email protected]96307312014-05-04 01:00:19592#endif
593
[email protected]35b2a972014-04-04 15:50:22594 // Stores the WebLocalFrame we are associated with.
595 blink::WebLocalFrame* frame_;
[email protected]b70da4c2014-01-06 19:57:09596
[email protected]abc501e2014-01-27 19:27:26597 base::WeakPtr<RenderViewImpl> render_view_;
[email protected]227692c52013-05-31 22:43:04598 int routing_id_;
[email protected]1c2052f2013-08-28 08:24:34599 bool is_swapped_out_;
[email protected]5a7100d2014-05-19 01:29:04600 // RenderFrameProxy exists only when is_swapped_out_ is true.
601 // TODO(nasko): This can be removed once we don't have a swapped out state on
602 // RenderFrame. See https://crbug.com/357747.
603 RenderFrameProxy* render_frame_proxy_;
[email protected]1c2052f2013-08-28 08:24:34604 bool is_detaching_;
[email protected]227692c52013-05-31 22:43:04605
[email protected]7a4e2532013-12-02 21:30:02606#if defined(ENABLE_PLUGINS)
[email protected]7a4e2532013-12-02 21:30:02607 // Current text input composition text. Empty if no composition is in
608 // progress.
[email protected]fcf75d42013-12-03 20:11:26609 base::string16 pepper_composition_text_;
[email protected]7a4e2532013-12-02 21:30:02610#endif
611
[email protected]f3add922013-12-20 23:17:16612 RendererWebCookieJarImpl cookie_jar_;
613
[email protected]2e2d9632013-12-03 00:55:26614 // All the registered observers.
615 ObserverList<RenderFrameObserver> observers_;
616
[email protected]bffc8302014-01-23 20:52:16617 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_;
618
[email protected]4ecee352014-03-11 21:12:19619 // The node that the context menu was pressed over.
620 blink::WebNode context_menu_node_;
621
[email protected]a09d53ce2014-01-31 00:46:42622 // External context menu requests we're waiting for. "Internal"
623 // (WebKit-originated) context menu events will have an ID of 0 and will not
624 // be in this map.
625 //
626 // We don't want to add internal ones since some of the "special" page
627 // handlers in the browser process just ignore the context menu requests so
628 // avoid showing context menus, and so this will cause right clicks to leak
629 // entries in this map. Most users of the custom context menu (e.g. Pepper
630 // plugins) are normally only on "regular" pages and the regular pages will
631 // always respond properly to the request, so we don't have to worry so
632 // much about leaks.
633 IDMap<ContextMenuClient, IDMapExternalPointer> pending_context_menus_;
634
[email protected]4ee64622014-03-21 22:34:15635 // The text selection the last time DidChangeSelection got called. May contain
636 // additional characters before and after the selected text, for IMEs. The
637 // portion of this string that is the actual selected text starts at index
638 // |selection_range_.GetMin() - selection_text_offset_| and has length
639 // |selection_range_.length()|.
640 base::string16 selection_text_;
641 // The offset corresponding to the start of |selection_text_| in the document.
642 size_t selection_text_offset_;
643 // Range over the document corresponding to the actual selected text (which
644 // could correspond to a substring of |selection_text_|; see above).
645 gfx::Range selection_range_;
646 // Used to inform didChangeSelection() when it is called in the context
647 // of handling a InputMsg_SelectRange IPC.
648 bool handling_select_range_;
649
[email protected]2626d142014-04-22 17:24:02650 // The next group of objects all implement RenderFrameObserver, so are deleted
651 // along with the RenderFrame automatically. This is why we just store weak
652 // references.
653
[email protected]4459599e2014-07-29 22:40:09654 // Dispatches permission requests for Web Notifications.
655 NotificationPermissionDispatcher* notification_permission_dispatcher_;
656
[email protected]2626d142014-04-22 17:24:02657 // Holds a reference to the service which provides desktop notifications.
[email protected]4459599e2014-07-29 22:40:09658 // TODO(peter) Remove this once Web Notifications are routed through Platform.
[email protected]2626d142014-04-22 17:24:02659 NotificationProvider* notification_provider_;
660
[email protected]977db4a42014-07-17 08:04:32661 // Destroyed via the RenderFrameObserver::OnDestruct() mechanism.
662 MediaStreamImpl* web_user_media_client_;
[email protected]96307312014-05-04 01:00:19663
[email protected]52d3e172014-06-16 16:57:02664 // MidiClient attached to this frame; lazily initialized.
665 MidiDispatcher* midi_dispatcher_;
666
[email protected]a017938b2014-05-27 21:17:17667#if defined(OS_ANDROID)
[email protected]4b556cf2014-06-10 23:21:53668 // Manages all media players in this render frame for communicating with the
669 // real media player in the browser process. It's okay to use a raw pointer
670 // since it's a RenderFrameObserver.
[email protected]a017938b2014-05-27 21:17:17671 RendererMediaPlayerManager* media_player_manager_;
[email protected]4b556cf2014-06-10 23:21:53672#endif
673
674#if defined(ENABLE_BROWSER_CDMS)
675 // Manage all CDMs in this render frame for communicating with the real CDM in
676 // the browser process. It's okay to use a raw pointer since it's a
677 // RenderFrameObserver.
[email protected]65f3d1aa2014-05-29 01:57:00678 RendererCdmManager* cdm_manager_;
[email protected]a017938b2014-05-27 21:17:17679#endif
680
[email protected]a6e21c372014-07-12 02:27:21681#if defined(VIDEO_HOLE)
682 // Whether or not this RenderFrameImpl contains a media player. Used to
683 // register as an observer for video-hole-specific events.
684 bool contains_media_player_;
685#endif
686
[email protected]45920862014-07-02 12:53:02687 // The geolocation dispatcher attached to this frame, lazily initialized.
[email protected]8eae0802014-06-02 21:35:55688 GeolocationDispatcher* geolocation_dispatcher_;
689
[email protected]45920862014-07-02 12:53:02690 // The push messaging dispatcher attached to this frame, lazily initialized.
691 PushMessagingDispatcher* push_messaging_dispatcher_;
692
[email protected]c52a1412014-06-25 06:09:25693 ServiceRegistryImpl service_registry_;
694
[email protected]45920862014-07-02 12:53:02695 // The screen orientation dispatcher attached to the frame, lazily
696 // initialized.
[email protected]cf78eda2014-06-13 16:57:41697 ScreenOrientationDispatcher* screen_orientation_dispatcher_;
698
[email protected]95640212014-07-26 18:14:30699 // The current accessibility mode.
700 AccessibilityMode accessibility_mode_;
701
702 // Only valid if |accessibility_mode_| is anything other than
703 // AccessibilityModeOff.
704 RendererAccessibility* renderer_accessibility_;
705
[email protected]96307312014-05-04 01:00:19706 base::WeakPtrFactory<RenderFrameImpl> weak_factory_;
707
[email protected]227692c52013-05-31 22:43:04708 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl);
709};
710
711} // namespace content
712
[email protected]85d85fd2013-06-19 00:57:41713#endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_