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/weak_ptr.h"
15 #include "base/observer_list.h"
16 #include "base/process/process_handle.h"
17 #include "content/common/accessibility_mode_enums.h"
18 #include "content/common/mojo/service_registry_impl.h"
19 #include "content/public/common/javascript_message_type.h"
20 #include "content/public/common/referrer.h"
21 #include "content/public/renderer/render_frame.h"
22 #include "content/renderer/media/webmediaplayer_delegate.h"
23 #include "content/renderer/render_frame_proxy.h"
24 #include "content/renderer/renderer_webcookiejar_impl.h"
25 #include "ipc/ipc_message.h"
26 #include "third_party/WebKit/public/web/WebAXObject.h"
27 #include "third_party/WebKit/public/web/WebDataSource.h"
28 #include "third_party/WebKit/public/web/WebFrameClient.h"
29 #include "third_party/WebKit/public/web/WebHistoryCommitType.h"
30 #include "ui/gfx/range/range.h"
32 #if defined(OS_ANDROID)
33 #include "content/renderer/media/android/renderer_media_player_manager.h"
37 struct FrameMsg_Navigate_Params
;
40 class WebGeolocationClient
;
43 class WebContentDecryptionModule
;
45 class WebNotificationPresenter
;
47 class WebSecurityOrigin
;
48 struct WebCompositionUnderline
;
49 struct WebContextMenuData
;
61 class ChildFrameCompositingHelper
;
62 class ExternalPopupMenu
;
63 class GeolocationDispatcher
;
64 class MediaStreamDispatcher
;
65 class MediaStreamImpl
;
66 class MediaStreamRendererFactory
;
68 class NotificationPermissionDispatcher
;
69 class NotificationProvider
;
70 class PepperPluginInstanceImpl
;
71 class PushMessagingDispatcher
;
72 class RendererAccessibility
;
73 class RendererCdmManager
;
74 class RendererMediaPlayerManager
;
75 class RendererPpapiHost
;
76 class RenderFrameObserver
;
79 class RenderWidgetFullscreenPepper
;
80 class ScreenOrientationDispatcher
;
81 struct CustomContextMenuContext
;
83 class CONTENT_EXPORT RenderFrameImpl
85 NON_EXPORTED_BASE(public blink::WebFrameClient
),
86 NON_EXPORTED_BASE(public WebMediaPlayerDelegate
) {
88 // Creates a new RenderFrame. |render_view| is the RenderView object that this
90 // Callers *must* call |SetWebFrame| immediately after creation.
91 // Note: This is called only when RenderFrame is created by Blink through
93 // TODO(creis): We should structure this so that |SetWebFrame| isn't needed.
94 static RenderFrameImpl
* Create(RenderViewImpl
* render_view
, int32 routing_id
);
96 // Creates a new RenderFrame with |routing_id| as a child of the RenderFrame
97 // identified by |parent_routing_id| or as the top-level frame if the latter
98 // is MSG_ROUTING_NONE. It creates the Blink WebLocalFrame and inserts it in
99 // the proper place in the frame tree.
100 // Note: This is called only when RenderFrame is being created in response to
101 // IPC message from the browser process. All other frame creation is driven
102 // through Blink and Create.
103 static void CreateFrame(int routing_id
, int parent_routing_id
);
105 // Returns the RenderFrameImpl for the given routing ID.
106 static RenderFrameImpl
* FromRoutingID(int routing_id
);
108 // Just like RenderFrame::FromWebFrame but returns the implementation.
109 static RenderFrameImpl
* FromWebFrame(blink::WebFrame
* web_frame
);
111 // Used by content_layouttest_support to hook into the creation of
113 static void InstallCreateHook(
114 RenderFrameImpl
* (*create_render_frame_impl
)(RenderViewImpl
*, int32
));
116 virtual ~RenderFrameImpl();
118 bool is_swapped_out() const {
119 return is_swapped_out_
;
122 // TODO(nasko): This can be removed once we don't have a swapped out state on
123 // RenderFrames. See https://crbug.com/357747.
124 void set_render_frame_proxy(RenderFrameProxy
* proxy
) {
125 render_frame_proxy_
= proxy
;
128 // Out-of-process child frames receive a signal from RenderWidgetCompositor
129 // when a compositor frame has committed.
130 void DidCommitCompositorFrame();
132 // TODO(jam): this is a temporary getter until all the code is transitioned
133 // to using RenderFrame instead of RenderView.
134 RenderViewImpl
* render_view() { return render_view_
.get(); }
136 RendererWebCookieJarImpl
* cookie_jar() { return &cookie_jar_
; }
138 // Returns the RenderWidget associated with this frame.
139 RenderWidget
* GetRenderWidget();
141 // This is called right after creation with the WebLocalFrame for this
142 // RenderFrame. It must be called before Initialize.
143 void SetWebFrame(blink::WebLocalFrame
* web_frame
);
145 // This method must be called after the frame has been added to the frame
146 // tree. It creates all objects that depend on the frame being at its proper
150 // Notifications from RenderWidget.
154 // Start/Stop loading notifications.
155 // TODO(nasko): Those are page-level methods at this time and come from
156 // WebViewClient. We should move them to be WebFrameClient calls and put
157 // logic in the browser side to balance starts/stops.
158 // |to_different_document| will be true unless the load is a fragment
159 // navigation, or triggered by history.pushState/replaceState.
160 virtual void didStartLoading(bool to_different_document
);
161 virtual void didStopLoading();
162 virtual void didChangeLoadProgress(double load_progress
);
164 AccessibilityMode
accessibility_mode() {
165 return accessibility_mode_
;
168 RendererAccessibility
* renderer_accessibility() {
169 return renderer_accessibility_
;
172 void HandleWebAccessibilityEvent(const blink::WebAXObject
& obj
,
173 blink::WebAXEvent event
);
175 // TODO(dmazzoni): the only reason this is here is to plumb it through to
176 // RendererAccessibility. It should be part of RenderFrameObserver, once
177 // blink has a separate accessibility tree per frame.
178 void FocusedNodeChanged(const blink::WebNode
& node
);
180 #if defined(ENABLE_PLUGINS)
181 // Notification that a PPAPI plugin has been created.
182 void PepperPluginCreated(RendererPpapiHost
* host
);
184 // Notifies that |instance| has changed the cursor.
185 // This will update the cursor appearance if it is currently over the plugin
187 void PepperDidChangeCursor(PepperPluginInstanceImpl
* instance
,
188 const blink::WebCursorInfo
& cursor
);
190 // Notifies that |instance| has received a mouse event.
191 void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl
* instance
);
193 // Informs the render view that a PPAPI plugin has changed text input status.
194 void PepperTextInputTypeChanged(PepperPluginInstanceImpl
* instance
);
195 void PepperCaretPositionChanged(PepperPluginInstanceImpl
* instance
);
197 // Cancels current composition.
198 void PepperCancelComposition(PepperPluginInstanceImpl
* instance
);
200 // Informs the render view that a PPAPI plugin has changed selection.
201 void PepperSelectionChanged(PepperPluginInstanceImpl
* instance
);
203 // Creates a fullscreen container for a pepper plugin instance.
204 RenderWidgetFullscreenPepper
* CreatePepperFullscreenContainer(
205 PepperPluginInstanceImpl
* plugin
);
207 bool IsPepperAcceptingCompositionEvents() const;
209 // Notification that the given plugin has crashed.
210 void PluginCrashed(const base::FilePath
& plugin_path
,
211 base::ProcessId plugin_pid
);
213 // Simulates IME events for testing purpose.
214 void SimulateImeSetComposition(
215 const base::string16
& text
,
216 const std::vector
<blink::WebCompositionUnderline
>& underlines
,
219 void SimulateImeConfirmComposition(const base::string16
& text
,
220 const gfx::Range
& replacement_range
);
222 // TODO(jam): remove these once the IPC handler moves from RenderView to
224 void OnImeSetComposition(
225 const base::string16
& text
,
226 const std::vector
<blink::WebCompositionUnderline
>& underlines
,
229 void OnImeConfirmComposition(
230 const base::string16
& text
,
231 const gfx::Range
& replacement_range
,
232 bool keep_selection
);
233 #endif // ENABLE_PLUGINS
235 // May return NULL in some cases, especially if userMediaClient() returns
237 MediaStreamDispatcher
* GetMediaStreamDispatcher();
239 #if defined(OS_MACOSX) || defined(OS_ANDROID)
240 void DidHideExternalPopupMenu();
244 virtual bool Send(IPC::Message
* msg
) OVERRIDE
;
247 virtual bool OnMessageReceived(const IPC::Message
& msg
) OVERRIDE
;
249 // RenderFrame implementation:
250 virtual RenderView
* GetRenderView() OVERRIDE
;
251 virtual int GetRoutingID() OVERRIDE
;
252 virtual blink::WebFrame
* GetWebFrame() OVERRIDE
;
253 virtual WebPreferences
& GetWebkitPreferences() OVERRIDE
;
254 virtual int ShowContextMenu(ContextMenuClient
* client
,
255 const ContextMenuParams
& params
) OVERRIDE
;
256 virtual void CancelContextMenu(int request_id
) OVERRIDE
;
257 virtual blink::WebNode
GetContextMenuNode() const OVERRIDE
;
258 virtual blink::WebPlugin
* CreatePlugin(
259 blink::WebFrame
* frame
,
260 const WebPluginInfo
& info
,
261 const blink::WebPluginParams
& params
) OVERRIDE
;
262 virtual void LoadURLExternally(blink::WebLocalFrame
* frame
,
263 const blink::WebURLRequest
& request
,
264 blink::WebNavigationPolicy policy
) OVERRIDE
;
265 virtual void ExecuteJavaScript(const base::string16
& javascript
) OVERRIDE
;
266 virtual bool IsHidden() OVERRIDE
;
267 virtual ServiceRegistry
* GetServiceRegistry() OVERRIDE
;
268 virtual bool IsFTPDirectoryListing() OVERRIDE
;
269 virtual void AttachGuest(int element_instance_id
) OVERRIDE
;
271 // blink::WebFrameClient implementation:
272 virtual blink::WebPlugin
* createPlugin(blink::WebLocalFrame
* frame
,
273 const blink::WebPluginParams
& params
);
274 virtual blink::WebMediaPlayer
* createMediaPlayer(
275 blink::WebLocalFrame
* frame
,
276 const blink::WebURL
& url
,
277 blink::WebMediaPlayerClient
* client
);
278 virtual blink::WebContentDecryptionModule
* createContentDecryptionModule(
279 blink::WebLocalFrame
* frame
,
280 const blink::WebSecurityOrigin
& security_origin
,
281 const blink::WebString
& key_system
);
282 virtual blink::WebApplicationCacheHost
* createApplicationCacheHost(
283 blink::WebLocalFrame
* frame
,
284 blink::WebApplicationCacheHostClient
* client
);
285 virtual blink::WebWorkerPermissionClientProxy
*
286 createWorkerPermissionClientProxy(blink::WebLocalFrame
* frame
);
287 virtual blink::WebExternalPopupMenu
* createExternalPopupMenu(
288 const blink::WebPopupMenuInfo
& popup_menu_info
,
289 blink::WebExternalPopupMenuClient
* popup_menu_client
);
290 virtual blink::WebCookieJar
* cookieJar(blink::WebLocalFrame
* frame
);
291 virtual blink::WebServiceWorkerProvider
* createServiceWorkerProvider(
292 blink::WebLocalFrame
* frame
);
293 virtual void didAccessInitialDocument(blink::WebLocalFrame
* frame
);
294 virtual blink::WebFrame
* createChildFrame(blink::WebLocalFrame
* parent
,
295 const blink::WebString
& name
);
296 virtual void didDisownOpener(blink::WebLocalFrame
* frame
);
297 virtual void frameDetached(blink::WebFrame
* frame
);
298 virtual void frameFocused();
299 virtual void willClose(blink::WebFrame
* frame
);
300 virtual void didChangeName(blink::WebLocalFrame
* frame
,
301 const blink::WebString
& name
);
302 virtual void didMatchCSS(
303 blink::WebLocalFrame
* frame
,
304 const blink::WebVector
<blink::WebString
>& newly_matching_selectors
,
305 const blink::WebVector
<blink::WebString
>& stopped_matching_selectors
);
306 virtual bool shouldReportDetailedMessageForSource(
307 const blink::WebString
& source
);
308 virtual void didAddMessageToConsole(const blink::WebConsoleMessage
& message
,
309 const blink::WebString
& source_name
,
310 unsigned source_line
,
311 const blink::WebString
& stack_trace
);
312 virtual void loadURLExternally(blink::WebLocalFrame
* frame
,
313 const blink::WebURLRequest
& request
,
314 blink::WebNavigationPolicy policy
,
315 const blink::WebString
& suggested_name
);
316 // The WebDataSource::ExtraData* is assumed to be a DocumentState* subclass.
317 virtual blink::WebNavigationPolicy
decidePolicyForNavigation(
318 const NavigationPolicyInfo
& info
);
319 virtual blink::WebHistoryItem
historyItemForNewChildFrame(
320 blink::WebFrame
* frame
);
321 virtual void willSendSubmitEvent(blink::WebLocalFrame
* frame
,
322 const blink::WebFormElement
& form
);
323 virtual void willSubmitForm(blink::WebLocalFrame
* frame
,
324 const blink::WebFormElement
& form
);
325 virtual void didCreateDataSource(blink::WebLocalFrame
* frame
,
326 blink::WebDataSource
* datasource
);
327 virtual void didStartProvisionalLoad(blink::WebLocalFrame
* frame
,
328 bool is_transition_navigation
);
329 virtual void didReceiveServerRedirectForProvisionalLoad(
330 blink::WebLocalFrame
* frame
);
331 virtual void didFailProvisionalLoad(
332 blink::WebLocalFrame
* frame
,
333 const blink::WebURLError
& error
);
334 virtual void didCommitProvisionalLoad(
335 blink::WebLocalFrame
* frame
,
336 const blink::WebHistoryItem
& item
,
337 blink::WebHistoryCommitType commit_type
);
338 virtual void didClearWindowObject(blink::WebLocalFrame
* frame
);
339 virtual void didCreateDocumentElement(blink::WebLocalFrame
* frame
);
340 virtual void didReceiveTitle(blink::WebLocalFrame
* frame
,
341 const blink::WebString
& title
,
342 blink::WebTextDirection direction
);
343 virtual void didChangeIcon(blink::WebLocalFrame
* frame
,
344 blink::WebIconURL::Type icon_type
);
345 virtual void didFinishDocumentLoad(blink::WebLocalFrame
* frame
);
346 virtual void didHandleOnloadEvents(blink::WebLocalFrame
* frame
);
347 virtual void didFailLoad(blink::WebLocalFrame
* frame
,
348 const blink::WebURLError
& error
);
349 virtual void didFinishLoad(blink::WebLocalFrame
* frame
);
350 virtual void didNavigateWithinPage(blink::WebLocalFrame
* frame
,
351 const blink::WebHistoryItem
& item
,
352 blink::WebHistoryCommitType commit_type
);
353 virtual void didUpdateCurrentHistoryItem(blink::WebLocalFrame
* frame
);
354 virtual void addNavigationTransitionData(
355 const blink::WebString
& allowedDestinationOrigin
,
356 const blink::WebString
& selector
,
357 const blink::WebString
& markup
);
358 virtual void didChangeThemeColor();
359 virtual void requestNotificationPermission(
360 const blink::WebSecurityOrigin
& origin
,
361 blink::WebNotificationPermissionCallback
* callback
);
362 virtual blink::WebNotificationPresenter
* notificationPresenter();
363 virtual void didChangeSelection(bool is_empty_selection
);
364 virtual blink::WebColorChooser
* createColorChooser(
365 blink::WebColorChooserClient
* client
,
366 const blink::WebColor
& initial_color
,
367 const blink::WebVector
<blink::WebColorSuggestion
>& suggestions
);
368 virtual void runModalAlertDialog(const blink::WebString
& message
);
369 virtual bool runModalConfirmDialog(const blink::WebString
& message
);
370 virtual bool runModalPromptDialog(const blink::WebString
& message
,
371 const blink::WebString
& default_value
,
372 blink::WebString
* actual_value
);
373 virtual bool runModalBeforeUnloadDialog(bool is_reload
,
374 const blink::WebString
& message
);
375 virtual void showContextMenu(const blink::WebContextMenuData
& data
);
376 virtual void clearContextMenu();
377 virtual void willSendRequest(blink::WebLocalFrame
* frame
,
379 blink::WebURLRequest
& request
,
380 const blink::WebURLResponse
& redirect_response
);
381 virtual void didReceiveResponse(blink::WebLocalFrame
* frame
,
383 const blink::WebURLResponse
& response
);
384 virtual void didFinishResourceLoad(blink::WebLocalFrame
* frame
,
385 unsigned identifier
);
386 virtual void didLoadResourceFromMemoryCache(
387 blink::WebLocalFrame
* frame
,
388 const blink::WebURLRequest
& request
,
389 const blink::WebURLResponse
& response
);
390 virtual void didDisplayInsecureContent(blink::WebLocalFrame
* frame
);
391 virtual void didRunInsecureContent(blink::WebLocalFrame
* frame
,
392 const blink::WebSecurityOrigin
& origin
,
393 const blink::WebURL
& target
);
394 virtual void didAbortLoading(blink::WebLocalFrame
* frame
);
395 virtual void didCreateScriptContext(blink::WebLocalFrame
* frame
,
396 v8::Handle
<v8::Context
> context
,
399 virtual void willReleaseScriptContext(blink::WebLocalFrame
* frame
,
400 v8::Handle
<v8::Context
> context
,
402 virtual void didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame
* frame
);
403 virtual void didChangeScrollOffset(blink::WebLocalFrame
* frame
);
404 virtual void willInsertBody(blink::WebLocalFrame
* frame
);
405 virtual void reportFindInPageMatchCount(int request_id
,
408 virtual void reportFindInPageSelection(int request_id
,
409 int active_match_ordinal
,
410 const blink::WebRect
& sel
);
411 virtual void requestStorageQuota(blink::WebLocalFrame
* frame
,
412 blink::WebStorageQuotaType type
,
413 unsigned long long requested_size
,
414 blink::WebStorageQuotaCallbacks callbacks
);
415 virtual void willOpenSocketStream(
416 blink::WebSocketStreamHandle
* handle
);
417 virtual void willOpenWebSocket(blink::WebSocketHandle
* handle
);
418 virtual blink::WebGeolocationClient
* geolocationClient();
419 virtual blink::WebPushClient
* pushClient();
420 virtual void willStartUsingPeerConnectionHandler(
421 blink::WebLocalFrame
* frame
,
422 blink::WebRTCPeerConnectionHandler
* handler
);
423 virtual blink::WebUserMediaClient
* userMediaClient();
424 virtual blink::WebMIDIClient
* webMIDIClient();
425 virtual bool willCheckAndDispatchMessageEvent(
426 blink::WebLocalFrame
* source_frame
,
427 blink::WebFrame
* target_frame
,
428 blink::WebSecurityOrigin target_origin
,
429 blink::WebDOMMessageEvent event
);
430 virtual blink::WebString
userAgentOverride(blink::WebLocalFrame
* frame
,
431 const blink::WebURL
& url
);
432 virtual blink::WebString
doNotTrackValue(blink::WebLocalFrame
* frame
);
433 virtual bool allowWebGL(blink::WebLocalFrame
* frame
, bool default_value
);
434 virtual void didLoseWebGLContext(blink::WebLocalFrame
* frame
,
435 int arb_robustness_status_code
);
436 virtual void forwardInputEvent(const blink::WebInputEvent
* event
);
437 virtual void initializeChildFrame(const blink::WebRect
& frame_rect
,
439 virtual blink::WebScreenOrientationClient
* webScreenOrientationClient();
441 // WebMediaPlayerDelegate implementation:
442 virtual void DidPlay(blink::WebMediaPlayer
* player
) OVERRIDE
;
443 virtual void DidPause(blink::WebMediaPlayer
* player
) OVERRIDE
;
444 virtual void PlayerGone(blink::WebMediaPlayer
* player
) OVERRIDE
;
446 // TODO(nasko): Make all tests in RenderViewImplTest friends and then move
447 // this back to private member.
448 void OnNavigate(const FrameMsg_Navigate_Params
& params
);
450 // Binds this render frame's service registry to a handle to the remote
452 void BindServiceRegistry(
453 mojo::ScopedMessagePipeHandle service_provider_handle
);
456 RenderFrameImpl(RenderViewImpl
* render_view
, int32 routing_id
);
459 friend class RenderFrameObserver
;
460 friend class RendererAccessibilityTest
;
461 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuDisplayNoneTest
, SelectItem
);
462 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest
, RemoveOnChange
);
463 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest
, NormalCase
);
464 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest
, ShowPopupThenNavigate
);
465 FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest
,
466 AccessibilityMessagesQueueWhileSwappedOut
);
467 FRIEND_TEST_ALL_PREFIXES(RenderFrameImplTest
,
468 ShouldUpdateSelectionTextFromContextMenuParams
);
469 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
,
470 OnExtendSelectionAndDelete
);
471 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, ReloadWhileSwappedOut
);
472 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, SendSwapOutACK
);
473 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
,
474 SetEditableSelectionAndComposition
);
475 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
,
476 OnSetAccessibilityMode
);
478 typedef std::map
<GURL
, double> HostZoomLevels
;
480 // Functions to add and remove observers for this object.
481 void AddObserver(RenderFrameObserver
* observer
);
482 void RemoveObserver(RenderFrameObserver
* observer
);
484 // Builds and sends DidCommitProvisionalLoad to the host.
485 void SendDidCommitProvisionalLoad(blink::WebFrame
* frame
);
487 // Gets the focused element. If no such element exists then the element will
489 blink::WebElement
GetFocusedElement();
491 // IPC message handlers ------------------------------------------------------
493 // The documentation for these functions should be in
494 // content/common/*_messages.h for the message that the function is handling.
495 void OnBeforeUnload();
496 void OnSwapOut(int proxy_routing_id
);
498 void OnShowContextMenu(const gfx::Point
& location
);
499 void OnContextMenuClosed(const CustomContextMenuContext
& custom_context
);
500 void OnCustomContextMenuAction(const CustomContextMenuContext
& custom_context
,
507 void OnPasteAndMatchStyle();
510 void OnSelectRange(const gfx::Point
& start
, const gfx::Point
& end
);
512 void OnReplace(const base::string16
& text
);
513 void OnReplaceMisspelling(const base::string16
& text
);
514 void OnCSSInsertRequest(const std::string
& css
);
515 void OnJavaScriptExecuteRequest(const base::string16
& javascript
,
518 void OnSetEditableSelectionOffsets(int start
, int end
);
519 void OnSetCompositionFromExistingText(
521 const std::vector
<blink::WebCompositionUnderline
>& underlines
);
522 void OnExtendSelectionAndDelete(int before
, int after
);
523 void OnReload(bool ignore_cache
);
524 void OnTextSurroundingSelectionRequest(size_t max_length
);
525 void OnAddStyleSheetByURL(const std::string
& url
);
526 void OnSetupTransitionView(const std::string
& markup
);
527 void OnBeginExitTransition(const std::string
& css_selector
);
528 void OnSetAccessibilityMode(AccessibilityMode new_mode
);
529 void OnDisownOpener();
530 #if defined(OS_ANDROID)
531 void OnSelectPopupMenuItems(bool canceled
,
532 const std::vector
<int>& selected_indices
);
533 #elif defined(OS_MACOSX)
534 void OnSelectPopupMenuItem(int selected_index
);
535 void OnCopyToFindPboard();
538 // Virtual since overridden by WebTestProxy for layout tests.
539 virtual blink::WebNavigationPolicy
DecidePolicyForNavigation(
540 RenderFrame
* render_frame
,
541 const NavigationPolicyInfo
& info
);
542 void OpenURL(blink::WebFrame
* frame
,
544 const Referrer
& referrer
,
545 blink::WebNavigationPolicy policy
);
547 // Update current main frame's encoding and send it to browser window.
548 // Since we want to let users see the right encoding info from menu
549 // before finishing loading, we call the UpdateEncoding in
550 // a) function:DidCommitLoadForFrame. When this function is called,
551 // that means we have got first data. In here we try to get encoding
552 // of page if it has been specified in http header.
553 // b) function:DidReceiveTitle. When this function is called,
554 // that means we have got specified title. Because in most of webpages,
555 // title tags will follow meta tags. In here we try to get encoding of
556 // page if it has been specified in meta tag.
557 // c) function:DidFinishDocumentLoadForFrame. When this function is
558 // called, that means we have got whole html page. In here we should
559 // finally get right encoding of page.
560 void UpdateEncoding(blink::WebFrame
* frame
,
561 const std::string
& encoding_name
);
563 // Dispatches the current state of selection on the webpage to the browser if
565 // TODO(varunjain): delete this method once we figure out how to keep
566 // selection handles in sync with the webpage.
567 void SyncSelectionIfRequired();
569 // Returns whether |params.selection_text| should be synchronized to the
570 // browser before bringing up the context menu. Static for testing.
571 static bool ShouldUpdateSelectionTextFromContextMenuParams(
572 const base::string16
& selection_text
,
573 size_t selection_text_offset
,
574 const gfx::Range
& selection_range
,
575 const ContextMenuParams
& params
);
577 bool RunJavaScriptMessage(JavaScriptMessageType type
,
578 const base::string16
& message
,
579 const base::string16
& default_value
,
580 const GURL
& frame_url
,
581 base::string16
* result
);
583 // Loads the appropriate error page for the specified failure into the frame.
584 void LoadNavigationErrorPage(const blink::WebURLRequest
& failed_request
,
585 const blink::WebURLError
& error
,
588 // Initializes |web_user_media_client_|. If this fails, because it wasn't
589 // possible to create a MediaStreamClient (e.g., WebRTC is disabled), then
590 // |web_user_media_client_| will remain NULL.
591 void InitializeUserMediaClient();
593 blink::WebMediaPlayer
* CreateWebMediaPlayerForMediaStream(
594 const blink::WebURL
& url
,
595 blink::WebMediaPlayerClient
* client
);
597 // Creates a factory object used for creating audio and video renderers.
598 // The method is virtual so that layouttests can override it.
599 virtual scoped_ptr
<MediaStreamRendererFactory
> CreateRendererFactory();
601 // Returns the URL being loaded by the |frame_|'s request.
602 GURL
GetLoadingUrl() const;
604 #if defined(OS_ANDROID)
605 blink::WebMediaPlayer
* CreateAndroidWebMediaPlayer(
606 const blink::WebURL
& url
,
607 blink::WebMediaPlayerClient
* client
);
609 RendererMediaPlayerManager
* GetMediaPlayerManager();
612 #if defined(ENABLE_BROWSER_CDMS)
613 RendererCdmManager
* GetCdmManager();
616 // Stores the WebLocalFrame we are associated with.
617 blink::WebLocalFrame
* frame_
;
619 base::WeakPtr
<RenderViewImpl
> render_view_
;
621 bool is_swapped_out_
;
622 // RenderFrameProxy exists only when is_swapped_out_ is true.
623 // TODO(nasko): This can be removed once we don't have a swapped out state on
624 // RenderFrame. See https://crbug.com/357747.
625 RenderFrameProxy
* render_frame_proxy_
;
628 #if defined(ENABLE_PLUGINS)
629 // Current text input composition text. Empty if no composition is in
631 base::string16 pepper_composition_text_
;
634 RendererWebCookieJarImpl cookie_jar_
;
636 // All the registered observers.
637 ObserverList
<RenderFrameObserver
> observers_
;
639 scoped_refptr
<ChildFrameCompositingHelper
> compositing_helper_
;
641 // The node that the context menu was pressed over.
642 blink::WebNode context_menu_node_
;
644 // External context menu requests we're waiting for. "Internal"
645 // (WebKit-originated) context menu events will have an ID of 0 and will not
648 // We don't want to add internal ones since some of the "special" page
649 // handlers in the browser process just ignore the context menu requests so
650 // avoid showing context menus, and so this will cause right clicks to leak
651 // entries in this map. Most users of the custom context menu (e.g. Pepper
652 // plugins) are normally only on "regular" pages and the regular pages will
653 // always respond properly to the request, so we don't have to worry so
655 IDMap
<ContextMenuClient
, IDMapExternalPointer
> pending_context_menus_
;
657 // The text selection the last time DidChangeSelection got called. May contain
658 // additional characters before and after the selected text, for IMEs. The
659 // portion of this string that is the actual selected text starts at index
660 // |selection_range_.GetMin() - selection_text_offset_| and has length
661 // |selection_range_.length()|.
662 base::string16 selection_text_
;
663 // The offset corresponding to the start of |selection_text_| in the document.
664 size_t selection_text_offset_
;
665 // Range over the document corresponding to the actual selected text (which
666 // could correspond to a substring of |selection_text_|; see above).
667 gfx::Range selection_range_
;
668 // Used to inform didChangeSelection() when it is called in the context
669 // of handling a InputMsg_SelectRange IPC.
670 bool handling_select_range_
;
672 // The next group of objects all implement RenderFrameObserver, so are deleted
673 // along with the RenderFrame automatically. This is why we just store weak
676 // Dispatches permission requests for Web Notifications.
677 NotificationPermissionDispatcher
* notification_permission_dispatcher_
;
679 // Holds a reference to the service which provides desktop notifications.
680 // TODO(peter) Remove this once Web Notifications are routed through Platform.
681 NotificationProvider
* notification_provider_
;
683 // Destroyed via the RenderFrameObserver::OnDestruct() mechanism.
684 MediaStreamImpl
* web_user_media_client_
;
686 // MidiClient attached to this frame; lazily initialized.
687 MidiDispatcher
* midi_dispatcher_
;
689 #if defined(OS_ANDROID)
690 // Manages all media players in this render frame for communicating with the
691 // real media player in the browser process. It's okay to use a raw pointer
692 // since it's a RenderFrameObserver.
693 RendererMediaPlayerManager
* media_player_manager_
;
696 #if defined(ENABLE_BROWSER_CDMS)
697 // Manage all CDMs in this render frame for communicating with the real CDM in
698 // the browser process. It's okay to use a raw pointer since it's a
699 // RenderFrameObserver.
700 RendererCdmManager
* cdm_manager_
;
703 #if defined(VIDEO_HOLE)
704 // Whether or not this RenderFrameImpl contains a media player. Used to
705 // register as an observer for video-hole-specific events.
706 bool contains_media_player_
;
709 // The geolocation dispatcher attached to this frame, lazily initialized.
710 GeolocationDispatcher
* geolocation_dispatcher_
;
712 // The push messaging dispatcher attached to this frame, lazily initialized.
713 PushMessagingDispatcher
* push_messaging_dispatcher_
;
715 ServiceRegistryImpl service_registry_
;
717 // The screen orientation dispatcher attached to the frame, lazily
719 ScreenOrientationDispatcher
* screen_orientation_dispatcher_
;
721 // The current accessibility mode.
722 AccessibilityMode accessibility_mode_
;
724 // Only valid if |accessibility_mode_| is anything other than
725 // AccessibilityModeOff.
726 RendererAccessibility
* renderer_accessibility_
;
728 #if defined(OS_MACOSX) || defined(OS_ANDROID)
729 // The external popup for the currently showing select popup.
730 scoped_ptr
<ExternalPopupMenu
> external_popup_menu_
;
733 base::WeakPtrFactory
<RenderFrameImpl
> weak_factory_
;
735 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl
);
738 } // namespace content
740 #endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_