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 // Notification from RenderView.
151 virtual void OnStop();
153 // Notifications from RenderWidget.
157 // Start/Stop loading notifications.
158 // TODO(nasko): Those are page-level methods at this time and come from
159 // WebViewClient. We should move them to be WebFrameClient calls and put
160 // logic in the browser side to balance starts/stops.
161 // |to_different_document| will be true unless the load is a fragment
162 // navigation, or triggered by history.pushState/replaceState.
163 virtual void didStartLoading(bool to_different_document
);
164 virtual void didStopLoading();
165 virtual void didChangeLoadProgress(double load_progress
);
167 AccessibilityMode
accessibility_mode() {
168 return accessibility_mode_
;
171 RendererAccessibility
* renderer_accessibility() {
172 return renderer_accessibility_
;
175 void HandleWebAccessibilityEvent(const blink::WebAXObject
& obj
,
176 blink::WebAXEvent event
);
178 // TODO(dmazzoni): the only reason this is here is to plumb it through to
179 // RendererAccessibility. It should be part of RenderFrameObserver, once
180 // blink has a separate accessibility tree per frame.
181 void FocusedNodeChanged(const blink::WebNode
& node
);
183 #if defined(ENABLE_PLUGINS)
184 // Notification that a PPAPI plugin has been created.
185 void PepperPluginCreated(RendererPpapiHost
* host
);
187 // Notifies that |instance| has changed the cursor.
188 // This will update the cursor appearance if it is currently over the plugin
190 void PepperDidChangeCursor(PepperPluginInstanceImpl
* instance
,
191 const blink::WebCursorInfo
& cursor
);
193 // Notifies that |instance| has received a mouse event.
194 void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl
* instance
);
196 // Informs the render view that a PPAPI plugin has changed text input status.
197 void PepperTextInputTypeChanged(PepperPluginInstanceImpl
* instance
);
198 void PepperCaretPositionChanged(PepperPluginInstanceImpl
* instance
);
200 // Cancels current composition.
201 void PepperCancelComposition(PepperPluginInstanceImpl
* instance
);
203 // Informs the render view that a PPAPI plugin has changed selection.
204 void PepperSelectionChanged(PepperPluginInstanceImpl
* instance
);
206 // Creates a fullscreen container for a pepper plugin instance.
207 RenderWidgetFullscreenPepper
* CreatePepperFullscreenContainer(
208 PepperPluginInstanceImpl
* plugin
);
210 bool IsPepperAcceptingCompositionEvents() const;
212 // Notification that the given plugin has crashed.
213 void PluginCrashed(const base::FilePath
& plugin_path
,
214 base::ProcessId plugin_pid
);
216 // Simulates IME events for testing purpose.
217 void SimulateImeSetComposition(
218 const base::string16
& text
,
219 const std::vector
<blink::WebCompositionUnderline
>& underlines
,
222 void SimulateImeConfirmComposition(const base::string16
& text
,
223 const gfx::Range
& replacement_range
);
225 // TODO(jam): remove these once the IPC handler moves from RenderView to
227 void OnImeSetComposition(
228 const base::string16
& text
,
229 const std::vector
<blink::WebCompositionUnderline
>& underlines
,
232 void OnImeConfirmComposition(
233 const base::string16
& text
,
234 const gfx::Range
& replacement_range
,
235 bool keep_selection
);
236 #endif // ENABLE_PLUGINS
238 // May return NULL in some cases, especially if userMediaClient() returns
240 MediaStreamDispatcher
* GetMediaStreamDispatcher();
242 #if defined(OS_MACOSX) || defined(OS_ANDROID)
243 void DidHideExternalPopupMenu();
247 virtual bool Send(IPC::Message
* msg
) OVERRIDE
;
250 virtual bool OnMessageReceived(const IPC::Message
& msg
) OVERRIDE
;
252 // RenderFrame implementation:
253 virtual RenderView
* GetRenderView() OVERRIDE
;
254 virtual int GetRoutingID() OVERRIDE
;
255 virtual blink::WebFrame
* GetWebFrame() OVERRIDE
;
256 virtual WebPreferences
& GetWebkitPreferences() OVERRIDE
;
257 virtual int ShowContextMenu(ContextMenuClient
* client
,
258 const ContextMenuParams
& params
) OVERRIDE
;
259 virtual void CancelContextMenu(int request_id
) OVERRIDE
;
260 virtual blink::WebNode
GetContextMenuNode() const OVERRIDE
;
261 virtual blink::WebPlugin
* CreatePlugin(
262 blink::WebFrame
* frame
,
263 const WebPluginInfo
& info
,
264 const blink::WebPluginParams
& params
) OVERRIDE
;
265 virtual void LoadURLExternally(blink::WebLocalFrame
* frame
,
266 const blink::WebURLRequest
& request
,
267 blink::WebNavigationPolicy policy
) OVERRIDE
;
268 virtual void ExecuteJavaScript(const base::string16
& javascript
) OVERRIDE
;
269 virtual bool IsHidden() OVERRIDE
;
270 virtual ServiceRegistry
* GetServiceRegistry() OVERRIDE
;
271 virtual bool IsFTPDirectoryListing() OVERRIDE
;
272 virtual void AttachGuest(int element_instance_id
) OVERRIDE
;
274 // blink::WebFrameClient implementation:
275 virtual blink::WebPlugin
* createPlugin(blink::WebLocalFrame
* frame
,
276 const blink::WebPluginParams
& params
);
277 virtual blink::WebMediaPlayer
* createMediaPlayer(
278 blink::WebLocalFrame
* frame
,
279 const blink::WebURL
& url
,
280 blink::WebMediaPlayerClient
* client
);
281 virtual blink::WebContentDecryptionModule
* createContentDecryptionModule(
282 blink::WebLocalFrame
* frame
,
283 const blink::WebSecurityOrigin
& security_origin
,
284 const blink::WebString
& key_system
);
285 virtual blink::WebApplicationCacheHost
* createApplicationCacheHost(
286 blink::WebLocalFrame
* frame
,
287 blink::WebApplicationCacheHostClient
* client
);
288 virtual blink::WebWorkerPermissionClientProxy
*
289 createWorkerPermissionClientProxy(blink::WebLocalFrame
* frame
);
290 virtual blink::WebExternalPopupMenu
* createExternalPopupMenu(
291 const blink::WebPopupMenuInfo
& popup_menu_info
,
292 blink::WebExternalPopupMenuClient
* popup_menu_client
);
293 virtual blink::WebCookieJar
* cookieJar(blink::WebLocalFrame
* frame
);
294 virtual blink::WebServiceWorkerProvider
* createServiceWorkerProvider(
295 blink::WebLocalFrame
* frame
);
296 virtual void didAccessInitialDocument(blink::WebLocalFrame
* frame
);
297 virtual blink::WebFrame
* createChildFrame(blink::WebLocalFrame
* parent
,
298 const blink::WebString
& name
);
299 virtual void didDisownOpener(blink::WebLocalFrame
* frame
);
300 virtual void frameDetached(blink::WebFrame
* frame
);
301 virtual void frameFocused();
302 virtual void willClose(blink::WebFrame
* frame
);
303 virtual void didChangeName(blink::WebLocalFrame
* frame
,
304 const blink::WebString
& name
);
305 virtual void didMatchCSS(
306 blink::WebLocalFrame
* frame
,
307 const blink::WebVector
<blink::WebString
>& newly_matching_selectors
,
308 const blink::WebVector
<blink::WebString
>& stopped_matching_selectors
);
309 virtual bool shouldReportDetailedMessageForSource(
310 const blink::WebString
& source
);
311 virtual void didAddMessageToConsole(const blink::WebConsoleMessage
& message
,
312 const blink::WebString
& source_name
,
313 unsigned source_line
,
314 const blink::WebString
& stack_trace
);
315 virtual void loadURLExternally(blink::WebLocalFrame
* frame
,
316 const blink::WebURLRequest
& request
,
317 blink::WebNavigationPolicy policy
,
318 const blink::WebString
& suggested_name
);
319 // The WebDataSource::ExtraData* is assumed to be a DocumentState* subclass.
320 virtual blink::WebNavigationPolicy
decidePolicyForNavigation(
321 const NavigationPolicyInfo
& info
);
322 virtual blink::WebHistoryItem
historyItemForNewChildFrame(
323 blink::WebFrame
* frame
);
324 virtual void willSendSubmitEvent(blink::WebLocalFrame
* frame
,
325 const blink::WebFormElement
& form
);
326 virtual void willSubmitForm(blink::WebLocalFrame
* frame
,
327 const blink::WebFormElement
& form
);
328 virtual void didCreateDataSource(blink::WebLocalFrame
* frame
,
329 blink::WebDataSource
* datasource
);
330 virtual void didStartProvisionalLoad(blink::WebLocalFrame
* frame
,
331 bool is_transition_navigation
);
332 virtual void didReceiveServerRedirectForProvisionalLoad(
333 blink::WebLocalFrame
* frame
);
334 virtual void didFailProvisionalLoad(
335 blink::WebLocalFrame
* frame
,
336 const blink::WebURLError
& error
);
337 virtual void didCommitProvisionalLoad(
338 blink::WebLocalFrame
* frame
,
339 const blink::WebHistoryItem
& item
,
340 blink::WebHistoryCommitType commit_type
);
341 virtual void didClearWindowObject(blink::WebLocalFrame
* frame
);
342 virtual void didCreateDocumentElement(blink::WebLocalFrame
* frame
);
343 virtual void didReceiveTitle(blink::WebLocalFrame
* frame
,
344 const blink::WebString
& title
,
345 blink::WebTextDirection direction
);
346 virtual void didChangeIcon(blink::WebLocalFrame
* frame
,
347 blink::WebIconURL::Type icon_type
);
348 virtual void didFinishDocumentLoad(blink::WebLocalFrame
* frame
);
349 virtual void didHandleOnloadEvents(blink::WebLocalFrame
* frame
);
350 virtual void didFailLoad(blink::WebLocalFrame
* frame
,
351 const blink::WebURLError
& error
);
352 virtual void didFinishLoad(blink::WebLocalFrame
* frame
);
353 virtual void didNavigateWithinPage(blink::WebLocalFrame
* frame
,
354 const blink::WebHistoryItem
& item
,
355 blink::WebHistoryCommitType commit_type
);
356 virtual void didUpdateCurrentHistoryItem(blink::WebLocalFrame
* frame
);
357 virtual void addNavigationTransitionData(
358 const blink::WebString
& allowedDestinationOrigin
,
359 const blink::WebString
& selector
,
360 const blink::WebString
& markup
);
361 virtual void didChangeThemeColor();
362 virtual void requestNotificationPermission(
363 const blink::WebSecurityOrigin
& origin
,
364 blink::WebNotificationPermissionCallback
* callback
);
365 virtual blink::WebNotificationPresenter
* notificationPresenter();
366 virtual void didChangeSelection(bool is_empty_selection
);
367 virtual blink::WebColorChooser
* createColorChooser(
368 blink::WebColorChooserClient
* client
,
369 const blink::WebColor
& initial_color
,
370 const blink::WebVector
<blink::WebColorSuggestion
>& suggestions
);
371 virtual void runModalAlertDialog(const blink::WebString
& message
);
372 virtual bool runModalConfirmDialog(const blink::WebString
& message
);
373 virtual bool runModalPromptDialog(const blink::WebString
& message
,
374 const blink::WebString
& default_value
,
375 blink::WebString
* actual_value
);
376 virtual bool runModalBeforeUnloadDialog(bool is_reload
,
377 const blink::WebString
& message
);
378 virtual void showContextMenu(const blink::WebContextMenuData
& data
);
379 virtual void clearContextMenu();
380 virtual void willSendRequest(blink::WebLocalFrame
* frame
,
382 blink::WebURLRequest
& request
,
383 const blink::WebURLResponse
& redirect_response
);
384 virtual void didReceiveResponse(blink::WebLocalFrame
* frame
,
386 const blink::WebURLResponse
& response
);
387 virtual void didFinishResourceLoad(blink::WebLocalFrame
* frame
,
388 unsigned identifier
);
389 virtual void didLoadResourceFromMemoryCache(
390 blink::WebLocalFrame
* frame
,
391 const blink::WebURLRequest
& request
,
392 const blink::WebURLResponse
& response
);
393 virtual void didDisplayInsecureContent(blink::WebLocalFrame
* frame
);
394 virtual void didRunInsecureContent(blink::WebLocalFrame
* frame
,
395 const blink::WebSecurityOrigin
& origin
,
396 const blink::WebURL
& target
);
397 virtual void didAbortLoading(blink::WebLocalFrame
* frame
);
398 virtual void didCreateScriptContext(blink::WebLocalFrame
* frame
,
399 v8::Handle
<v8::Context
> context
,
402 virtual void willReleaseScriptContext(blink::WebLocalFrame
* frame
,
403 v8::Handle
<v8::Context
> context
,
405 virtual void didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame
* frame
);
406 virtual void didChangeScrollOffset(blink::WebLocalFrame
* frame
);
407 virtual void willInsertBody(blink::WebLocalFrame
* frame
);
408 virtual void reportFindInPageMatchCount(int request_id
,
411 virtual void reportFindInPageSelection(int request_id
,
412 int active_match_ordinal
,
413 const blink::WebRect
& sel
);
414 virtual void requestStorageQuota(blink::WebLocalFrame
* frame
,
415 blink::WebStorageQuotaType type
,
416 unsigned long long requested_size
,
417 blink::WebStorageQuotaCallbacks callbacks
);
418 virtual void willOpenSocketStream(
419 blink::WebSocketStreamHandle
* handle
);
420 virtual void willOpenWebSocket(blink::WebSocketHandle
* handle
);
421 virtual blink::WebGeolocationClient
* geolocationClient();
422 virtual blink::WebPushClient
* pushClient();
423 virtual void willStartUsingPeerConnectionHandler(
424 blink::WebLocalFrame
* frame
,
425 blink::WebRTCPeerConnectionHandler
* handler
);
426 virtual blink::WebUserMediaClient
* userMediaClient();
427 virtual blink::WebMIDIClient
* webMIDIClient();
428 virtual bool willCheckAndDispatchMessageEvent(
429 blink::WebLocalFrame
* source_frame
,
430 blink::WebFrame
* target_frame
,
431 blink::WebSecurityOrigin target_origin
,
432 blink::WebDOMMessageEvent event
);
433 virtual blink::WebString
userAgentOverride(blink::WebLocalFrame
* frame
,
434 const blink::WebURL
& url
);
435 virtual blink::WebString
doNotTrackValue(blink::WebLocalFrame
* frame
);
436 virtual bool allowWebGL(blink::WebLocalFrame
* frame
, bool default_value
);
437 virtual void didLoseWebGLContext(blink::WebLocalFrame
* frame
,
438 int arb_robustness_status_code
);
439 virtual void forwardInputEvent(const blink::WebInputEvent
* event
);
440 virtual void initializeChildFrame(const blink::WebRect
& frame_rect
,
442 virtual blink::WebScreenOrientationClient
* webScreenOrientationClient();
444 // WebMediaPlayerDelegate implementation:
445 virtual void DidPlay(blink::WebMediaPlayer
* player
) OVERRIDE
;
446 virtual void DidPause(blink::WebMediaPlayer
* player
) OVERRIDE
;
447 virtual void PlayerGone(blink::WebMediaPlayer
* player
) OVERRIDE
;
449 // TODO(nasko): Make all tests in RenderViewImplTest friends and then move
450 // this back to private member.
451 void OnNavigate(const FrameMsg_Navigate_Params
& params
);
453 // Binds this render frame's service registry to a handle to the remote
455 void BindServiceRegistry(
456 mojo::ScopedMessagePipeHandle service_provider_handle
);
459 RenderFrameImpl(RenderViewImpl
* render_view
, int32 routing_id
);
462 friend class RenderFrameObserver
;
463 friend class RendererAccessibilityTest
;
464 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuDisplayNoneTest
, SelectItem
);
465 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest
, RemoveOnChange
);
466 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest
, NormalCase
);
467 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest
, ShowPopupThenNavigate
);
468 FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest
,
469 AccessibilityMessagesQueueWhileSwappedOut
);
470 FRIEND_TEST_ALL_PREFIXES(RenderFrameImplTest
,
471 ShouldUpdateSelectionTextFromContextMenuParams
);
472 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
,
473 OnExtendSelectionAndDelete
);
474 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, ReloadWhileSwappedOut
);
475 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
, SendSwapOutACK
);
476 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
,
477 SetEditableSelectionAndComposition
);
478 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest
,
479 OnSetAccessibilityMode
);
481 typedef std::map
<GURL
, double> HostZoomLevels
;
483 // Functions to add and remove observers for this object.
484 void AddObserver(RenderFrameObserver
* observer
);
485 void RemoveObserver(RenderFrameObserver
* observer
);
487 // Builds and sends DidCommitProvisionalLoad to the host.
488 void SendDidCommitProvisionalLoad(blink::WebFrame
* frame
);
490 // Gets the focused element. If no such element exists then the element will
492 blink::WebElement
GetFocusedElement();
494 // IPC message handlers ------------------------------------------------------
496 // The documentation for these functions should be in
497 // content/common/*_messages.h for the message that the function is handling.
498 void OnBeforeUnload();
499 void OnSwapOut(int proxy_routing_id
);
500 void OnShowContextMenu(const gfx::Point
& location
);
501 void OnContextMenuClosed(const CustomContextMenuContext
& custom_context
);
502 void OnCustomContextMenuAction(const CustomContextMenuContext
& custom_context
,
509 void OnPasteAndMatchStyle();
512 void OnSelectRange(const gfx::Point
& start
, const gfx::Point
& end
);
514 void OnReplace(const base::string16
& text
);
515 void OnReplaceMisspelling(const base::string16
& text
);
516 void OnCSSInsertRequest(const std::string
& css
);
517 void OnJavaScriptExecuteRequest(const base::string16
& javascript
,
520 void OnSetEditableSelectionOffsets(int start
, int end
);
521 void OnSetCompositionFromExistingText(
523 const std::vector
<blink::WebCompositionUnderline
>& underlines
);
524 void OnExtendSelectionAndDelete(int before
, int after
);
525 void OnReload(bool ignore_cache
);
526 void OnTextSurroundingSelectionRequest(size_t max_length
);
527 void OnAddStyleSheetByURL(const std::string
& url
);
528 void OnSetupTransitionView(const std::string
& markup
);
529 void OnBeginExitTransition(const std::string
& css_selector
);
530 void OnSetAccessibilityMode(AccessibilityMode new_mode
);
531 void OnDisownOpener();
532 #if defined(OS_ANDROID)
533 void OnSelectPopupMenuItems(bool canceled
,
534 const std::vector
<int>& selected_indices
);
535 #elif defined(OS_MACOSX)
536 void OnSelectPopupMenuItem(int selected_index
);
537 void OnCopyToFindPboard();
540 // Virtual since overridden by WebTestProxy for layout tests.
541 virtual blink::WebNavigationPolicy
DecidePolicyForNavigation(
542 RenderFrame
* render_frame
,
543 const NavigationPolicyInfo
& info
);
544 void OpenURL(blink::WebFrame
* frame
,
546 const Referrer
& referrer
,
547 blink::WebNavigationPolicy policy
);
549 // Update current main frame's encoding and send it to browser window.
550 // Since we want to let users see the right encoding info from menu
551 // before finishing loading, we call the UpdateEncoding in
552 // a) function:DidCommitLoadForFrame. When this function is called,
553 // that means we have got first data. In here we try to get encoding
554 // of page if it has been specified in http header.
555 // b) function:DidReceiveTitle. When this function is called,
556 // that means we have got specified title. Because in most of webpages,
557 // title tags will follow meta tags. In here we try to get encoding of
558 // page if it has been specified in meta tag.
559 // c) function:DidFinishDocumentLoadForFrame. When this function is
560 // called, that means we have got whole html page. In here we should
561 // finally get right encoding of page.
562 void UpdateEncoding(blink::WebFrame
* frame
,
563 const std::string
& encoding_name
);
565 // Dispatches the current state of selection on the webpage to the browser if
567 // TODO(varunjain): delete this method once we figure out how to keep
568 // selection handles in sync with the webpage.
569 void SyncSelectionIfRequired();
571 // Returns whether |params.selection_text| should be synchronized to the
572 // browser before bringing up the context menu. Static for testing.
573 static bool ShouldUpdateSelectionTextFromContextMenuParams(
574 const base::string16
& selection_text
,
575 size_t selection_text_offset
,
576 const gfx::Range
& selection_range
,
577 const ContextMenuParams
& params
);
579 bool RunJavaScriptMessage(JavaScriptMessageType type
,
580 const base::string16
& message
,
581 const base::string16
& default_value
,
582 const GURL
& frame_url
,
583 base::string16
* result
);
585 // Loads the appropriate error page for the specified failure into the frame.
586 void LoadNavigationErrorPage(const blink::WebURLRequest
& failed_request
,
587 const blink::WebURLError
& error
,
590 // Initializes |web_user_media_client_|. If this fails, because it wasn't
591 // possible to create a MediaStreamClient (e.g., WebRTC is disabled), then
592 // |web_user_media_client_| will remain NULL.
593 void InitializeUserMediaClient();
595 blink::WebMediaPlayer
* CreateWebMediaPlayerForMediaStream(
596 const blink::WebURL
& url
,
597 blink::WebMediaPlayerClient
* client
);
599 // Creates a factory object used for creating audio and video renderers.
600 // The method is virtual so that layouttests can override it.
601 virtual scoped_ptr
<MediaStreamRendererFactory
> CreateRendererFactory();
603 // Returns the URL being loaded by the |frame_|'s request.
604 GURL
GetLoadingUrl() const;
606 #if defined(OS_ANDROID)
607 blink::WebMediaPlayer
* CreateAndroidWebMediaPlayer(
608 const blink::WebURL
& url
,
609 blink::WebMediaPlayerClient
* client
);
611 RendererMediaPlayerManager
* GetMediaPlayerManager();
614 #if defined(ENABLE_BROWSER_CDMS)
615 RendererCdmManager
* GetCdmManager();
618 // Stores the WebLocalFrame we are associated with.
619 blink::WebLocalFrame
* frame_
;
621 base::WeakPtr
<RenderViewImpl
> render_view_
;
623 bool is_swapped_out_
;
624 // RenderFrameProxy exists only when is_swapped_out_ is true.
625 // TODO(nasko): This can be removed once we don't have a swapped out state on
626 // RenderFrame. See https://crbug.com/357747.
627 RenderFrameProxy
* render_frame_proxy_
;
630 #if defined(ENABLE_PLUGINS)
631 // Current text input composition text. Empty if no composition is in
633 base::string16 pepper_composition_text_
;
636 RendererWebCookieJarImpl cookie_jar_
;
638 // All the registered observers.
639 ObserverList
<RenderFrameObserver
> observers_
;
641 scoped_refptr
<ChildFrameCompositingHelper
> compositing_helper_
;
643 // The node that the context menu was pressed over.
644 blink::WebNode context_menu_node_
;
646 // External context menu requests we're waiting for. "Internal"
647 // (WebKit-originated) context menu events will have an ID of 0 and will not
650 // We don't want to add internal ones since some of the "special" page
651 // handlers in the browser process just ignore the context menu requests so
652 // avoid showing context menus, and so this will cause right clicks to leak
653 // entries in this map. Most users of the custom context menu (e.g. Pepper
654 // plugins) are normally only on "regular" pages and the regular pages will
655 // always respond properly to the request, so we don't have to worry so
657 IDMap
<ContextMenuClient
, IDMapExternalPointer
> pending_context_menus_
;
659 // The text selection the last time DidChangeSelection got called. May contain
660 // additional characters before and after the selected text, for IMEs. The
661 // portion of this string that is the actual selected text starts at index
662 // |selection_range_.GetMin() - selection_text_offset_| and has length
663 // |selection_range_.length()|.
664 base::string16 selection_text_
;
665 // The offset corresponding to the start of |selection_text_| in the document.
666 size_t selection_text_offset_
;
667 // Range over the document corresponding to the actual selected text (which
668 // could correspond to a substring of |selection_text_|; see above).
669 gfx::Range selection_range_
;
670 // Used to inform didChangeSelection() when it is called in the context
671 // of handling a InputMsg_SelectRange IPC.
672 bool handling_select_range_
;
674 // The next group of objects all implement RenderFrameObserver, so are deleted
675 // along with the RenderFrame automatically. This is why we just store weak
678 // Dispatches permission requests for Web Notifications.
679 NotificationPermissionDispatcher
* notification_permission_dispatcher_
;
681 // Holds a reference to the service which provides desktop notifications.
682 // TODO(peter) Remove this once Web Notifications are routed through Platform.
683 NotificationProvider
* notification_provider_
;
685 // Destroyed via the RenderFrameObserver::OnDestruct() mechanism.
686 MediaStreamImpl
* web_user_media_client_
;
688 // MidiClient attached to this frame; lazily initialized.
689 MidiDispatcher
* midi_dispatcher_
;
691 #if defined(OS_ANDROID)
692 // Manages all media players in this render frame for communicating with the
693 // real media player in the browser process. It's okay to use a raw pointer
694 // since it's a RenderFrameObserver.
695 RendererMediaPlayerManager
* media_player_manager_
;
698 #if defined(ENABLE_BROWSER_CDMS)
699 // Manage all CDMs in this render frame for communicating with the real CDM in
700 // the browser process. It's okay to use a raw pointer since it's a
701 // RenderFrameObserver.
702 RendererCdmManager
* cdm_manager_
;
705 #if defined(VIDEO_HOLE)
706 // Whether or not this RenderFrameImpl contains a media player. Used to
707 // register as an observer for video-hole-specific events.
708 bool contains_media_player_
;
711 // The geolocation dispatcher attached to this frame, lazily initialized.
712 GeolocationDispatcher
* geolocation_dispatcher_
;
714 // The push messaging dispatcher attached to this frame, lazily initialized.
715 PushMessagingDispatcher
* push_messaging_dispatcher_
;
717 ServiceRegistryImpl service_registry_
;
719 // The screen orientation dispatcher attached to the frame, lazily
721 ScreenOrientationDispatcher
* screen_orientation_dispatcher_
;
723 // The current accessibility mode.
724 AccessibilityMode accessibility_mode_
;
726 // Only valid if |accessibility_mode_| is anything other than
727 // AccessibilityModeOff.
728 RendererAccessibility
* renderer_accessibility_
;
730 #if defined(OS_MACOSX) || defined(OS_ANDROID)
731 // The external popup for the currently showing select popup.
732 scoped_ptr
<ExternalPopupMenu
> external_popup_menu_
;
735 base::WeakPtrFactory
<RenderFrameImpl
> weak_factory_
;
737 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl
);
740 } // namespace content
742 #endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_