1 // 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.
5 #ifndef CONTENT_RENDERER_RENDER_FRAME_IMPL_H_
6 #define CONTENT_RENDERER_RENDER_FRAME_IMPL_H_
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/id_map.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "base/observer_list.h"
17 #include "base/process/process_handle.h"
18 #include "content/common/accessibility_mode_enums.h"
19 #include "content/common/frame_message_enums.h"
20 #include "content/common/mojo/service_registry_impl.h"
21 #include "content/public/common/javascript_message_type.h"
22 #include "content/public/common/referrer.h"
23 #include "content/public/renderer/render_frame.h"
24 #include "content/renderer/render_frame_proxy.h"
25 #include "content/renderer/renderer_webcookiejar_impl.h"
26 #include "ipc/ipc_message.h"
27 #include "media/blink/webmediaplayer_delegate.h"
28 #include "third_party/WebKit/public/web/WebAXObject.h"
29 #include "third_party/WebKit/public/web/WebDataSource.h"
30 #include "third_party/WebKit/public/web/WebFrameClient.h"
31 #include "third_party/WebKit/public/web/WebHistoryCommitType.h"
32 #include "third_party/WebKit/public/web/WebTransitionElementData.h"
33 #include "ui/gfx/range/range.h"
35 #if defined(ENABLE_PLUGINS)
36 #include "content/renderer/pepper/plugin_power_saver_helper.h"
39 #if defined(OS_ANDROID)
40 #include "content/renderer/media/android/renderer_media_player_manager.h"
45 struct FrameHostMsg_AddNavigationTransitionData_Params
;
46 struct FrameMsg_NewFrame_WidgetParams
;
47 struct FrameMsg_TextTrackSettings_Params
;
50 class WebGeolocationClient
;
52 class WebContentDecryptionModule
;
54 class WebPresentationClient
;
56 class WebSecurityOrigin
;
57 struct WebCompositionUnderline
;
58 struct WebContextMenuData
;
60 struct WebTransitionElementData
;
71 class MediaPermission
;
72 class WebEncryptedMediaClientImpl
;
77 class ChildFrameCompositingHelper
;
78 class CompositorDependencies
;
81 class ExternalPopupMenu
;
82 class GeolocationDispatcher
;
83 class ManifestManager
;
84 class MediaStreamDispatcher
;
85 class MediaStreamRendererFactory
;
86 class MediaPermissionDispatcher
;
88 class NavigationState
;
89 class NotificationPermissionDispatcher
;
91 class PepperPluginInstanceImpl
;
92 class PermissionDispatcher
;
93 class PresentationDispatcher
;
94 class PushMessagingDispatcher
;
95 class RenderCdmFactory
;
96 class RendererAccessibility
;
97 class RendererCdmManager
;
98 class RendererMediaPlayerManager
;
99 class RendererPpapiHost
;
100 class RenderFrameObserver
;
101 class RenderViewImpl
;
103 class RenderWidgetFullscreenPepper
;
104 class ScreenOrientationDispatcher
;
105 class UserMediaClientImpl
;
106 enum class SandboxFlags
;
107 struct CommonNavigationParams
;
108 struct CustomContextMenuContext
;
109 struct FrameReplicationState
;
110 struct NavigationParams
;
111 struct RequestNavigationParams
;
112 struct ResourceResponseHead
;
113 struct StartNavigationParams
;
115 class CONTENT_EXPORT RenderFrameImpl
116 : public RenderFrame
,
117 NON_EXPORTED_BASE(public blink::WebFrameClient
),
118 NON_EXPORTED_BASE(public media::WebMediaPlayerDelegate
) {
120 // Creates a new RenderFrame. |render_view| is the RenderView object that this
122 // Callers *must* call |SetWebFrame| immediately after creation.
123 // Note: This is called only when RenderFrame is created by Blink through
125 // TODO(creis): We should structure this so that |SetWebFrame| isn't needed.
126 static RenderFrameImpl
* Create(RenderViewImpl
* render_view
, int32 routing_id
);
128 // Creates a new RenderFrame with |routing_id| as a child of the RenderFrame
129 // identified by |parent_routing_id| or as the top-level frame if the latter
130 // is MSG_ROUTING_NONE. If |proxy_routing_id| is MSG_ROUTING_NONE, it creates
131 // the Blink WebLocalFrame and inserts it in the proper place in the frame
132 // tree. Otherwise, the frame is semi-orphaned until it commits, at which
133 // point it replaces the proxy identified by |proxy_routing_id|.
134 // Note: This is called only when RenderFrame is being created in response to
135 // IPC message from the browser process. All other frame creation is driven
136 // through Blink and Create.
137 static void CreateFrame(int routing_id
,
138 int parent_routing_id
,
139 int proxy_routing_id
,
140 const FrameReplicationState
& replicated_state
,
141 CompositorDependencies
* compositor_deps
,
142 const FrameMsg_NewFrame_WidgetParams
& params
);
144 // Returns the RenderFrameImpl for the given routing ID.
145 static RenderFrameImpl
* FromRoutingID(int routing_id
);
147 // Just like RenderFrame::FromWebFrame but returns the implementation.
148 static RenderFrameImpl
* FromWebFrame(blink::WebFrame
* web_frame
);
150 // Used by content_layouttest_support to hook into the creation of
152 using CreateRenderFrameImplFunction
= RenderFrameImpl
* (*)(RenderViewImpl
*,
154 static void InstallCreateHook(
155 CreateRenderFrameImplFunction create_render_frame_impl
);
157 static content::SandboxFlags
WebToContentSandboxFlags(
158 blink::WebSandboxFlags flags
);
160 static blink::WebSandboxFlags
ContentToWebSandboxFlags(
161 content::SandboxFlags flags
);
163 virtual ~RenderFrameImpl();
165 bool is_swapped_out() const {
166 return is_swapped_out_
;
169 // TODO(nasko): This can be removed once we don't have a swapped out state on
170 // RenderFrames. See https://crbug.com/357747.
171 void set_render_frame_proxy(RenderFrameProxy
* proxy
) {
172 render_frame_proxy_
= proxy
;
175 // Out-of-process child frames receive a signal from RenderWidgetCompositor
176 // when a compositor frame has committed.
177 void DidCommitCompositorFrame();
179 // TODO(jam): this is a temporary getter until all the code is transitioned
180 // to using RenderFrame instead of RenderView.
181 RenderViewImpl
* render_view() { return render_view_
.get(); }
183 RendererWebCookieJarImpl
* cookie_jar() { return &cookie_jar_
; }
185 // Returns the RenderWidget associated with this frame.
186 RenderWidget
* GetRenderWidget();
188 DevToolsAgent
* devtools_agent() { return devtools_agent_
; }
190 // This is called right after creation with the WebLocalFrame for this
191 // RenderFrame. It must be called before Initialize.
192 void SetWebFrame(blink::WebLocalFrame
* web_frame
);
194 // This method must be called after the frame has been added to the frame
195 // tree. It creates all objects that depend on the frame being at its proper
199 // Notifications from RenderWidget.
202 void WidgetWillClose();
204 // Start/Stop loading notifications.
205 // TODO(nasko): Those are page-level methods at this time and come from
206 // WebViewClient. We should move them to be WebFrameClient calls and put
207 // logic in the browser side to balance starts/stops.
208 // |to_different_document| will be true unless the load is a fragment
209 // navigation, or triggered by history.pushState/replaceState.
210 virtual void didStartLoading(bool to_different_document
);
211 virtual void didStopLoading();
212 virtual void didChangeLoadProgress(double load_progress
);
214 AccessibilityMode
accessibility_mode() {
215 return accessibility_mode_
;
218 RendererAccessibility
* renderer_accessibility() {
219 return renderer_accessibility_
;
222 void HandleWebAccessibilityEvent(const blink::WebAXObject
& obj
,
223 blink::WebAXEvent event
);
225 // The focused node changed to |node|. If focus was lost from this frame,
226 // |node| will be null.
227 void FocusedNodeChanged(const blink::WebNode
& node
);
229 // TODO(dmazzoni): the only reason this is here is to plumb it through to
230 // RendererAccessibility. It should use the RenderFrameObserver method, once
231 // blink has a separate accessibility tree per frame.
232 void FocusedNodeChangedForAccessibility(const blink::WebNode
& node
);
234 #if defined(ENABLE_PLUGINS)
235 // Notification that a PPAPI plugin has been created.
236 void PepperPluginCreated(RendererPpapiHost
* host
);
238 // Notifies that |instance| has changed the cursor.
239 // This will update the cursor appearance if it is currently over the plugin
241 void PepperDidChangeCursor(PepperPluginInstanceImpl
* instance
,
242 const blink::WebCursorInfo
& cursor
);
244 // Notifies that |instance| has received a mouse event.
245 void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl
* instance
);
247 // Informs the render view that a PPAPI plugin has changed text input status.
248 void PepperTextInputTypeChanged(PepperPluginInstanceImpl
* instance
);
249 void PepperCaretPositionChanged(PepperPluginInstanceImpl
* instance
);
251 // Cancels current composition.
252 void PepperCancelComposition(PepperPluginInstanceImpl
* instance
);
254 // Informs the render view that a PPAPI plugin has changed selection.
255 void PepperSelectionChanged(PepperPluginInstanceImpl
* instance
);
257 // Creates a fullscreen container for a pepper plugin instance.
258 RenderWidgetFullscreenPepper
* CreatePepperFullscreenContainer(
259 PepperPluginInstanceImpl
* plugin
);
261 bool IsPepperAcceptingCompositionEvents() const;
263 // Notification that the given plugin has crashed.
264 void PluginCrashed(const base::FilePath
& plugin_path
,
265 base::ProcessId plugin_pid
);
267 // Simulates IME events for testing purpose.
268 void SimulateImeSetComposition(
269 const base::string16
& text
,
270 const std::vector
<blink::WebCompositionUnderline
>& underlines
,
273 void SimulateImeConfirmComposition(const base::string16
& text
,
274 const gfx::Range
& replacement_range
);
276 // TODO(jam): remove these once the IPC handler moves from RenderView to
278 void OnImeSetComposition(
279 const base::string16
& text
,
280 const std::vector
<blink::WebCompositionUnderline
>& underlines
,
283 void OnImeConfirmComposition(const base::string16
& text
,
284 const gfx::Range
& replacement_range
,
285 bool keep_selection
);
286 #endif // defined(ENABLE_PLUGINS)
288 // May return NULL in some cases, especially if userMediaClient() returns
290 MediaStreamDispatcher
* GetMediaStreamDispatcher();
292 #if defined(OS_MACOSX) || defined(OS_ANDROID)
293 void DidHideExternalPopupMenu();
297 bool Send(IPC::Message
* msg
) override
;
300 bool OnMessageReceived(const IPC::Message
& msg
) override
;
302 // RenderFrame implementation:
303 RenderView
* GetRenderView() override
;
304 int GetRoutingID() override
;
305 blink::WebLocalFrame
* GetWebFrame() override
;
306 blink::WebElement
GetFocusedElement() const override
;
307 WebPreferences
& GetWebkitPreferences() override
;
308 int ShowContextMenu(ContextMenuClient
* client
,
309 const ContextMenuParams
& params
) override
;
310 void CancelContextMenu(int request_id
) override
;
311 blink::WebNode
GetContextMenuNode() const override
;
312 blink::WebPlugin
* CreatePlugin(
313 blink::WebFrame
* frame
,
314 const WebPluginInfo
& info
,
315 const blink::WebPluginParams
& params
,
316 scoped_ptr
<PluginInstanceThrottler
> throttler
) override
;
317 void LoadURLExternally(blink::WebLocalFrame
* frame
,
318 const blink::WebURLRequest
& request
,
319 blink::WebNavigationPolicy policy
) override
;
320 void ExecuteJavaScript(const base::string16
& javascript
) override
;
321 bool IsHidden() override
;
322 ServiceRegistry
* GetServiceRegistry() override
;
323 #if defined(ENABLE_PLUGINS)
324 void RegisterPeripheralPlugin(
325 const GURL
& content_origin
,
326 const base::Closure
& unthrottle_callback
) override
;
327 PluginPowerSaverHelper
* plugin_power_saver_helper() {
328 return plugin_power_saver_helper_
;
331 bool IsFTPDirectoryListing() override
;
332 void AttachGuest(int element_instance_id
) override
;
333 void DetachGuest(int element_instance_id
) override
;
334 void SetSelectedText(const base::string16
& selection_text
,
336 const gfx::Range
& range
) override
;
337 void EnsureMojoBuiltinsAreAvailable(v8::Isolate
* isolate
,
338 v8::Handle
<v8::Context
> context
) override
;
340 // blink::WebFrameClient implementation:
341 blink::WebPluginPlaceholder
* createPluginPlaceholder(
342 blink::WebLocalFrame
*,
343 const blink::WebPluginParams
&) override
;
344 virtual blink::WebPlugin
* createPlugin(blink::WebLocalFrame
* frame
,
345 const blink::WebPluginParams
& params
);
346 // TODO(jrummell): Remove this method once blink updated.
347 virtual blink::WebMediaPlayer
* createMediaPlayer(
348 blink::WebLocalFrame
* frame
,
349 const blink::WebURL
& url
,
350 blink::WebMediaPlayerClient
* client
);
351 virtual blink::WebMediaPlayer
* createMediaPlayer(
352 blink::WebLocalFrame
* frame
,
353 const blink::WebURL
& url
,
354 blink::WebMediaPlayerClient
* client
,
355 blink::WebContentDecryptionModule
* initial_cdm
);
356 virtual blink::WebApplicationCacheHost
* createApplicationCacheHost(
357 blink::WebLocalFrame
* frame
,
358 blink::WebApplicationCacheHostClient
* client
);
359 virtual blink::WebWorkerContentSettingsClientProxy
*
360 createWorkerContentSettingsClientProxy(blink::WebLocalFrame
* frame
);
361 virtual blink::WebExternalPopupMenu
* createExternalPopupMenu(
362 const blink::WebPopupMenuInfo
& popup_menu_info
,
363 blink::WebExternalPopupMenuClient
* popup_menu_client
);
364 virtual blink::WebCookieJar
* cookieJar(blink::WebLocalFrame
* frame
);
365 virtual blink::WebServiceWorkerProvider
* createServiceWorkerProvider(
366 blink::WebLocalFrame
* frame
);
367 virtual void didAccessInitialDocument(blink::WebLocalFrame
* frame
);
368 virtual blink::WebFrame
* createChildFrame(
369 blink::WebLocalFrame
* parent
,
370 const blink::WebString
& name
,
371 blink::WebSandboxFlags sandboxFlags
);
372 virtual void didDisownOpener(blink::WebLocalFrame
* frame
);
373 virtual void frameDetached(blink::WebFrame
* frame
);
374 virtual void frameFocused();
375 virtual void willClose(blink::WebFrame
* frame
);
376 virtual void didChangeName(blink::WebLocalFrame
* frame
,
377 const blink::WebString
& name
);
378 virtual void didChangeSandboxFlags(blink::WebFrame
* child_frame
,
379 blink::WebSandboxFlags flags
);
380 virtual void didMatchCSS(
381 blink::WebLocalFrame
* frame
,
382 const blink::WebVector
<blink::WebString
>& newly_matching_selectors
,
383 const blink::WebVector
<blink::WebString
>& stopped_matching_selectors
);
384 virtual bool shouldReportDetailedMessageForSource(
385 const blink::WebString
& source
);
386 virtual void didAddMessageToConsole(const blink::WebConsoleMessage
& message
,
387 const blink::WebString
& source_name
,
388 unsigned source_line
,
389 const blink::WebString
& stack_trace
);
390 virtual void loadURLExternally(blink::WebLocalFrame
* frame
,
391 const blink::WebURLRequest
& request
,
392 blink::WebNavigationPolicy policy
,
393 const blink::WebString
& suggested_name
);
394 // The WebDataSource::ExtraData* is assumed to be a DocumentState* subclass.
395 virtual blink::WebNavigationPolicy
decidePolicyForNavigation(
396 const NavigationPolicyInfo
& info
);
397 virtual blink::WebHistoryItem
historyItemForNewChildFrame(
398 blink::WebFrame
* frame
);
399 virtual void willSendSubmitEvent(blink::WebLocalFrame
* frame
,
400 const blink::WebFormElement
& form
);
401 virtual void willSubmitForm(blink::WebLocalFrame
* frame
,
402 const blink::WebFormElement
& form
);
403 virtual void didCreateDataSource(blink::WebLocalFrame
* frame
,
404 blink::WebDataSource
* datasource
);
405 virtual void didStartProvisionalLoad(blink::WebLocalFrame
* frame
,
406 bool is_transition_navigation
,
407 double triggering_event_time
);
408 virtual void didReceiveServerRedirectForProvisionalLoad(
409 blink::WebLocalFrame
* frame
);
410 virtual void didFailProvisionalLoad(
411 blink::WebLocalFrame
* frame
,
412 const blink::WebURLError
& error
,
413 blink::WebHistoryCommitType commit_type
);
414 virtual void didCommitProvisionalLoad(
415 blink::WebLocalFrame
* frame
,
416 const blink::WebHistoryItem
& item
,
417 blink::WebHistoryCommitType commit_type
);
418 virtual void didCreateNewDocument(blink::WebLocalFrame
* frame
);
419 virtual void didClearWindowObject(blink::WebLocalFrame
* frame
);
420 virtual void didCreateDocumentElement(blink::WebLocalFrame
* frame
);
421 virtual void didReceiveTitle(blink::WebLocalFrame
* frame
,
422 const blink::WebString
& title
,
423 blink::WebTextDirection direction
);
424 virtual void didChangeIcon(blink::WebLocalFrame
* frame
,
425 blink::WebIconURL::Type icon_type
);
426 virtual void didFinishDocumentLoad(blink::WebLocalFrame
* frame
);
427 virtual void didHandleOnloadEvents(blink::WebLocalFrame
* frame
);
428 virtual void didFailLoad(blink::WebLocalFrame
* frame
,
429 const blink::WebURLError
& error
,
430 blink::WebHistoryCommitType commit_type
);
431 virtual void didFinishLoad(blink::WebLocalFrame
* frame
);
432 virtual void didNavigateWithinPage(blink::WebLocalFrame
* frame
,
433 const blink::WebHistoryItem
& item
,
434 blink::WebHistoryCommitType commit_type
);
435 virtual void didUpdateCurrentHistoryItem(blink::WebLocalFrame
* frame
);
436 virtual void addNavigationTransitionData(
437 const blink::WebTransitionElementData
& data
);
438 virtual void didChangeThemeColor();
439 virtual void dispatchLoad();
440 virtual void requestNotificationPermission(
441 const blink::WebSecurityOrigin
& origin
,
442 blink::WebNotificationPermissionCallback
* callback
);
443 virtual void didChangeSelection(bool is_empty_selection
);
444 virtual blink::WebColorChooser
* createColorChooser(
445 blink::WebColorChooserClient
* client
,
446 const blink::WebColor
& initial_color
,
447 const blink::WebVector
<blink::WebColorSuggestion
>& suggestions
);
448 virtual void runModalAlertDialog(const blink::WebString
& message
);
449 virtual bool runModalConfirmDialog(const blink::WebString
& message
);
450 virtual bool runModalPromptDialog(const blink::WebString
& message
,
451 const blink::WebString
& default_value
,
452 blink::WebString
* actual_value
);
453 virtual bool runModalBeforeUnloadDialog(bool is_reload
,
454 const blink::WebString
& message
);
455 virtual void showContextMenu(const blink::WebContextMenuData
& data
);
456 virtual void clearContextMenu();
457 virtual void willSendRequest(blink::WebLocalFrame
* frame
,
459 blink::WebURLRequest
& request
,
460 const blink::WebURLResponse
& redirect_response
);
461 virtual void didReceiveResponse(blink::WebLocalFrame
* frame
,
463 const blink::WebURLResponse
& response
);
464 virtual void didFinishResourceLoad(blink::WebLocalFrame
* frame
,
465 unsigned identifier
);
466 virtual void didLoadResourceFromMemoryCache(
467 blink::WebLocalFrame
* frame
,
468 const blink::WebURLRequest
& request
,
469 const blink::WebURLResponse
& response
);
470 virtual void didDisplayInsecureContent(blink::WebLocalFrame
* frame
);
471 virtual void didRunInsecureContent(blink::WebLocalFrame
* frame
,
472 const blink::WebSecurityOrigin
& origin
,
473 const blink::WebURL
& target
);
474 virtual void didAbortLoading(blink::WebLocalFrame
* frame
);
475 virtual void didCreateScriptContext(blink::WebLocalFrame
* frame
,
476 v8::Handle
<v8::Context
> context
,
479 virtual void willReleaseScriptContext(blink::WebLocalFrame
* frame
,
480 v8::Handle
<v8::Context
> context
,
482 virtual void didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame
* frame
);
483 virtual void didChangeScrollOffset(blink::WebLocalFrame
* frame
);
484 virtual void willInsertBody(blink::WebLocalFrame
* frame
);
485 virtual void reportFindInPageMatchCount(int request_id
,
488 virtual void reportFindInPageSelection(int request_id
,
489 int active_match_ordinal
,
490 const blink::WebRect
& sel
);
491 virtual void requestStorageQuota(blink::WebLocalFrame
* frame
,
492 blink::WebStorageQuotaType type
,
493 unsigned long long requested_size
,
494 blink::WebStorageQuotaCallbacks callbacks
);
495 virtual void willOpenWebSocket(blink::WebSocketHandle
* handle
);
496 virtual blink::WebGeolocationClient
* geolocationClient();
497 virtual blink::WebPushClient
* pushClient();
498 virtual blink::WebPresentationClient
* presentationClient();
499 virtual void willStartUsingPeerConnectionHandler(
500 blink::WebLocalFrame
* frame
,
501 blink::WebRTCPeerConnectionHandler
* handler
);
502 virtual blink::WebUserMediaClient
* userMediaClient();
503 virtual blink::WebEncryptedMediaClient
* encryptedMediaClient();
504 virtual blink::WebMIDIClient
* webMIDIClient();
505 virtual bool willCheckAndDispatchMessageEvent(
506 blink::WebLocalFrame
* source_frame
,
507 blink::WebFrame
* target_frame
,
508 blink::WebSecurityOrigin target_origin
,
509 blink::WebDOMMessageEvent event
);
510 virtual blink::WebString
userAgentOverride(blink::WebLocalFrame
* frame
,
511 const blink::WebURL
& url
);
512 virtual blink::WebString
doNotTrackValue(blink::WebLocalFrame
* frame
);
513 virtual bool allowWebGL(blink::WebLocalFrame
* frame
, bool default_value
);
514 virtual void didLoseWebGLContext(blink::WebLocalFrame
* frame
,
515 int arb_robustness_status_code
);
516 virtual blink::WebScreenOrientationClient
* webScreenOrientationClient();
517 virtual bool isControlledByServiceWorker(blink::WebDataSource
& data_source
);
518 virtual int64_t serviceWorkerID(blink::WebDataSource
& data_source
);
519 virtual void postAccessibilityEvent(const blink::WebAXObject
& obj
,
520 blink::WebAXEvent event
);
521 virtual void handleAccessibilityFindInPageResult(
524 const blink::WebAXObject
& start_object
,
526 const blink::WebAXObject
& end_object
,
528 virtual void didChangeManifest(blink::WebLocalFrame
*);
529 virtual void didChangeDefaultPresentation(blink::WebLocalFrame
*);
530 virtual bool enterFullscreen();
531 virtual bool exitFullscreen();
532 virtual blink::WebPermissionClient
* permissionClient();
534 // WebMediaPlayerDelegate implementation:
535 void DidPlay(blink::WebMediaPlayer
* player
) override
;
536 void DidPause(blink::WebMediaPlayer
* player
) override
;
537 void PlayerGone(blink::WebMediaPlayer
* player
) override
;
539 // TODO(nasko): Make all tests in RenderViewImplTest friends and then move
540 // this back to private member.
541 void OnNavigate(const CommonNavigationParams
& common_params
,
542 const StartNavigationParams
& start_params
,
543 const RequestNavigationParams
& request_params
);
545 // Make this frame show an empty, unscriptable page.
546 // TODO(nasko): Remove this method once swapped out state is no longer used.
547 void NavigateToSwappedOutURL();
549 // Binds this render frame's service registry.
550 void BindServiceRegistry(
551 mojo::InterfaceRequest
<mojo::ServiceProvider
> services
,
552 mojo::ServiceProviderPtr exposed_services
);
554 ManifestManager
* manifest_manager();
556 // TODO(creis): Remove when the only caller, the HistoryController, is no
558 void SetPendingNavigationParams(
559 scoped_ptr
<NavigationParams
> navigation_params
);
562 RenderFrameImpl(RenderViewImpl
* render_view
, int32 routing_id
);
565 friend class RenderFrameImplTest
;
566 friend class RenderFrameObserver
;
567 friend class RendererAccessibilityTest
;
568 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuDisplayNoneTest
, SelectItem
);
569 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest
, RemoveOnChange
);
570 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest
, NormalCase
);
571 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest
, ShowPopupThenNavigate
);
572 FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest
,
573 AccessibilityMessagesQueueWhileSwappedOut
);
574 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
,
575 OnExtendSelectionAndDelete
);
576 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, ReloadWhileSwappedOut
);
577 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, SendSwapOutACK
);
578 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, OriginReplicationForSwapOut
);
579 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
,
580 SetEditableSelectionAndComposition
);
581 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
,
582 OnSetAccessibilityMode
);
584 typedef std::map
<GURL
, double> HostZoomLevels
;
586 // Functions to add and remove observers for this object.
587 void AddObserver(RenderFrameObserver
* observer
);
588 void RemoveObserver(RenderFrameObserver
* observer
);
590 // Builds and sends DidCommitProvisionalLoad to the host.
591 void SendDidCommitProvisionalLoad(blink::WebFrame
* frame
,
592 blink::WebHistoryCommitType commit_type
);
594 // IPC message handlers ------------------------------------------------------
596 // The documentation for these functions should be in
597 // content/common/*_messages.h for the message that the function is handling.
598 void OnBeforeUnload();
599 void OnSwapOut(int proxy_routing_id
,
601 const FrameReplicationState
& replicated_frame_state
);
603 void OnShowContextMenu(const gfx::Point
& location
);
604 void OnContextMenuClosed(const CustomContextMenuContext
& custom_context
);
605 void OnCustomContextMenuAction(const CustomContextMenuContext
& custom_context
,
612 void OnPasteAndMatchStyle();
615 void OnSelectRange(const gfx::Point
& base
, const gfx::Point
& extent
);
617 void OnMoveRangeSelectionExtent(const gfx::Point
& point
);
618 void OnReplace(const base::string16
& text
);
619 void OnReplaceMisspelling(const base::string16
& text
);
620 void OnCSSInsertRequest(const std::string
& css
);
621 void OnJavaScriptExecuteRequest(const base::string16
& javascript
,
624 void OnJavaScriptExecuteRequestForTests(const base::string16
& javascript
,
627 void OnVisualStateRequest(uint64 key
);
628 void OnSetEditableSelectionOffsets(int start
, int end
);
629 void OnSetCompositionFromExistingText(
631 const std::vector
<blink::WebCompositionUnderline
>& underlines
);
632 void OnExecuteNoValueEditCommand(const std::string
& name
);
633 void OnExtendSelectionAndDelete(int before
, int after
);
634 void OnReload(bool ignore_cache
);
635 void OnTextSurroundingSelectionRequest(size_t max_length
);
636 void OnAddStyleSheetByURL(const std::string
& url
);
637 void OnSetupTransitionView(const std::string
& markup
);
638 void OnBeginExitTransition(const std::string
& css_selector
,
639 bool exit_to_native_app
);
640 void OnRevertExitTransition();
641 void OnHideTransitionElements(const std::string
& css_selector
);
642 void OnShowTransitionElements(const std::string
& css_selector
);
643 void OnSetAccessibilityMode(AccessibilityMode new_mode
);
644 void OnDisownOpener();
645 void OnDidUpdateSandboxFlags(SandboxFlags flags
);
646 void OnTextTrackSettingsChanged(
647 const FrameMsg_TextTrackSettings_Params
& params
);
648 #if defined(OS_ANDROID)
649 void OnSelectPopupMenuItems(bool canceled
,
650 const std::vector
<int>& selected_indices
);
651 #elif defined(OS_MACOSX)
652 void OnSelectPopupMenuItem(int selected_index
);
653 void OnCopyToFindPboard();
656 void OnCommitNavigation(const ResourceResponseHead
& response
,
657 const GURL
& stream_url
,
658 const CommonNavigationParams
& common_params
,
659 const RequestNavigationParams
& request_params
);
661 // Virtual since overridden by WebTestProxy for layout tests.
662 virtual blink::WebNavigationPolicy
DecidePolicyForNavigation(
663 RenderFrame
* render_frame
,
664 const NavigationPolicyInfo
& info
);
665 void OpenURL(blink::WebFrame
* frame
,
667 const Referrer
& referrer
,
668 blink::WebNavigationPolicy policy
);
670 // Update current main frame's encoding and send it to browser window.
671 // Since we want to let users see the right encoding info from menu
672 // before finishing loading, we call the UpdateEncoding in
673 // a) function:DidCommitLoadForFrame. When this function is called,
674 // that means we have got first data. In here we try to get encoding
675 // of page if it has been specified in http header.
676 // b) function:DidReceiveTitle. When this function is called,
677 // that means we have got specified title. Because in most of webpages,
678 // title tags will follow meta tags. In here we try to get encoding of
679 // page if it has been specified in meta tag.
680 // c) function:DidFinishDocumentLoadForFrame. When this function is
681 // called, that means we have got whole html page. In here we should
682 // finally get right encoding of page.
683 void UpdateEncoding(blink::WebFrame
* frame
,
684 const std::string
& encoding_name
);
686 // Dispatches the current state of selection on the webpage to the browser if
688 // TODO(varunjain): delete this method once we figure out how to keep
689 // selection handles in sync with the webpage.
690 void SyncSelectionIfRequired();
692 bool RunJavaScriptMessage(JavaScriptMessageType type
,
693 const base::string16
& message
,
694 const base::string16
& default_value
,
695 const GURL
& frame_url
,
696 base::string16
* result
);
698 // Loads the appropriate error page for the specified failure into the frame.
699 void LoadNavigationErrorPage(const blink::WebURLRequest
& failed_request
,
700 const blink::WebURLError
& error
,
703 void HandleJavascriptExecutionResult(const base::string16
& javascript
,
706 v8::Handle
<v8::Value
> result
);
708 // Initializes |web_user_media_client_|. If this fails, because it wasn't
709 // possible to create a MediaStreamClient (e.g., WebRTC is disabled), then
710 // |web_user_media_client_| will remain NULL.
711 void InitializeUserMediaClient();
713 blink::WebMediaPlayer
* CreateWebMediaPlayerForMediaStream(
714 const blink::WebURL
& url
,
715 blink::WebMediaPlayerClient
* client
);
717 // Creates a factory object used for creating audio and video renderers.
718 // The method is virtual so that layouttests can override it.
719 virtual scoped_ptr
<MediaStreamRendererFactory
> CreateRendererFactory();
721 // Checks that the RenderView is ready to display the navigation to |url|. If
722 // the return value is false, the navigation should be abandoned.
723 bool PrepareRenderViewForNavigation(
725 bool is_history_navigation
,
726 const RequestNavigationParams
& request_params
,
728 blink::WebURLRequest::CachePolicy
* cache_policy
);
731 // Sends a FrameHostMsg_BeginNavigation to the browser based on the contents
732 // of the WebURLRequest.
733 void BeginNavigation(blink::WebURLRequest
* request
);
736 void LoadDataURL(const CommonNavigationParams
& params
,
737 blink::WebFrame
* frame
);
739 // Returns the URL being loaded by the |frame_|'s request.
740 GURL
GetLoadingUrl() const;
742 // If we initiated a navigation, this function will populate |document_state|
743 // with the navigation information saved in OnNavigate().
744 void PopulateDocumentStateFromPending(DocumentState
* document_state
);
746 // Returns a new NavigationState populated with the navigation information
747 // saved in OnNavigate().
748 NavigationState
* CreateNavigationStateFromPending();
750 #if defined(OS_ANDROID)
751 blink::WebMediaPlayer
* CreateAndroidWebMediaPlayer(
752 const blink::WebURL
& url
,
753 blink::WebMediaPlayerClient
* client
,
754 media::MediaPermission
* media_permission
,
755 blink::WebContentDecryptionModule
* initial_cdm
);
757 RendererMediaPlayerManager
* GetMediaPlayerManager();
760 media::MediaPermission
* GetMediaPermission();
761 media::CdmFactory
* GetCdmFactory();
763 // Stores the WebLocalFrame we are associated with. This is null from the
764 // constructor until SetWebFrame is called, and it is null after
765 // frameDetached is called until destruction (which is asynchronous in the
766 // case of the main frame, but not subframes).
767 blink::WebLocalFrame
* frame_
;
769 // Frame is a local root if it is rendered in a process different than parent
770 // or it is a main frame.
773 base::WeakPtr
<RenderViewImpl
> render_view_
;
775 bool is_swapped_out_
;
776 // RenderFrameProxy exists only when is_swapped_out_ is true.
777 // TODO(nasko): This can be removed once we don't have a swapped out state on
778 // RenderFrame. See https://crbug.com/357747.
779 RenderFrameProxy
* render_frame_proxy_
;
782 // If this frame was created to replace a proxy, this will store the routing
783 // id of the proxy to replace at commit-time, at which time it will be
785 // TODO(creis): Remove this after switching to PlzNavigate.
786 int proxy_routing_id_
;
788 // Used when the RenderFrame is a local root. For now, RenderWidgets are
789 // added only when a child frame is in a different process from its parent
790 // frame, but eventually this will also apply to top-level frames.
791 // TODO(kenrb): Correct the above statement when top-level frames have their
792 // own RenderWidgets.
793 scoped_refptr
<RenderWidget
> render_widget_
;
795 // Temporarily holds state pertaining to a navigation that has been initiated
796 // until the NavigationState corresponding to the new navigation is created in
797 // didCreateDataSource().
798 scoped_ptr
<NavigationParams
> pending_navigation_params_
;
800 #if defined(ENABLE_PLUGINS)
801 // Current text input composition text. Empty if no composition is in
803 base::string16 pepper_composition_text_
;
805 PluginPowerSaverHelper
* plugin_power_saver_helper_
;
808 RendererWebCookieJarImpl cookie_jar_
;
810 // All the registered observers.
811 ObserverList
<RenderFrameObserver
> observers_
;
813 scoped_refptr
<ChildFrameCompositingHelper
> compositing_helper_
;
815 // The node that the context menu was pressed over.
816 blink::WebNode context_menu_node_
;
818 // External context menu requests we're waiting for. "Internal"
819 // (WebKit-originated) context menu events will have an ID of 0 and will not
822 // We don't want to add internal ones since some of the "special" page
823 // handlers in the browser process just ignore the context menu requests so
824 // avoid showing context menus, and so this will cause right clicks to leak
825 // entries in this map. Most users of the custom context menu (e.g. Pepper
826 // plugins) are normally only on "regular" pages and the regular pages will
827 // always respond properly to the request, so we don't have to worry so
829 IDMap
<ContextMenuClient
, IDMapExternalPointer
> pending_context_menus_
;
831 // The text selection the last time DidChangeSelection got called. May contain
832 // additional characters before and after the selected text, for IMEs. The
833 // portion of this string that is the actual selected text starts at index
834 // |selection_range_.GetMin() - selection_text_offset_| and has length
835 // |selection_range_.length()|.
836 base::string16 selection_text_
;
837 // The offset corresponding to the start of |selection_text_| in the document.
838 size_t selection_text_offset_
;
839 // Range over the document corresponding to the actual selected text (which
840 // could correspond to a substring of |selection_text_|; see above).
841 gfx::Range selection_range_
;
842 // Used to inform didChangeSelection() when it is called in the context
843 // of handling a InputMsg_SelectRange IPC.
844 bool handling_select_range_
;
846 // The next group of objects all implement RenderFrameObserver, so are deleted
847 // along with the RenderFrame automatically. This is why we just store weak
850 // Dispatches permission requests for Web Notifications.
851 NotificationPermissionDispatcher
* notification_permission_dispatcher_
;
853 // Destroyed via the RenderFrameObserver::OnDestruct() mechanism.
854 UserMediaClientImpl
* web_user_media_client_
;
856 // EncryptedMediaClient attached to this frame; lazily initialized.
857 scoped_ptr
<media::WebEncryptedMediaClientImpl
> web_encrypted_media_client_
;
859 // The media permission dispatcher attached to this frame, lazily initialized.
860 MediaPermissionDispatcher
* media_permission_dispatcher_
;
862 // MidiClient attached to this frame; lazily initialized.
863 MidiDispatcher
* midi_dispatcher_
;
865 #if defined(OS_ANDROID)
866 // Manages all media players in this render frame for communicating with the
867 // real media player in the browser process. It's okay to use a raw pointer
868 // since it's a RenderFrameObserver.
869 RendererMediaPlayerManager
* media_player_manager_
;
872 #if defined(ENABLE_BROWSER_CDMS)
873 // Manage all CDMs in this render frame for communicating with the real CDM in
874 // the browser process. It's okay to use a raw pointer since it's a
875 // RenderFrameObserver.
876 RendererCdmManager
* cdm_manager_
;
879 // The CDM factory attached to this frame, lazily initialized.
880 RenderCdmFactory
* cdm_factory_
;
882 #if defined(VIDEO_HOLE)
883 // Whether or not this RenderFrameImpl contains a media player. Used to
884 // register as an observer for video-hole-specific events.
885 bool contains_media_player_
;
888 // The devtools agent for this frame; only created for main frame and
890 DevToolsAgent
* devtools_agent_
;
892 // The geolocation dispatcher attached to this frame, lazily initialized.
893 GeolocationDispatcher
* geolocation_dispatcher_
;
895 // The push messaging dispatcher attached to this frame, lazily initialized.
896 PushMessagingDispatcher
* push_messaging_dispatcher_
;
898 // The presentation dispatcher implementation attached to this frame, lazily
900 PresentationDispatcher
* presentation_dispatcher_
;
902 ServiceRegistryImpl service_registry_
;
904 // The screen orientation dispatcher attached to the frame, lazily
906 ScreenOrientationDispatcher
* screen_orientation_dispatcher_
;
908 // The Manifest Manager handles the manifest requests from the browser
910 ManifestManager
* manifest_manager_
;
912 // The current accessibility mode.
913 AccessibilityMode accessibility_mode_
;
915 // Only valid if |accessibility_mode_| is anything other than
916 // AccessibilityModeOff.
917 RendererAccessibility
* renderer_accessibility_
;
919 scoped_ptr
<PermissionDispatcher
> permission_client_
;
921 #if defined(OS_MACOSX) || defined(OS_ANDROID)
922 // The external popup for the currently showing select popup.
923 scoped_ptr
<ExternalPopupMenu
> external_popup_menu_
;
926 base::WeakPtrFactory
<RenderFrameImpl
> weak_factory_
;
928 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl
);
931 } // namespace content
933 #endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_