Mac: Fix performance issues with remote CoreAnimation
[chromium-blink-merge.git] / content / renderer / render_frame_impl.h
blob3b828dae4cc3e726bb594889884cb98e863dc827
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_
8 #include <vector>
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/frame_message_enums.h"
19 #include "content/common/mojo/service_registry_impl.h"
20 #include "content/public/common/javascript_message_type.h"
21 #include "content/public/common/referrer.h"
22 #include "content/public/renderer/render_frame.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 "media/blink/webmediaplayer_delegate.h"
27 #include "third_party/WebKit/public/web/WebAXObject.h"
28 #include "third_party/WebKit/public/web/WebDataSource.h"
29 #include "third_party/WebKit/public/web/WebFrameClient.h"
30 #include "third_party/WebKit/public/web/WebHistoryCommitType.h"
31 #include "third_party/WebKit/public/web/WebTransitionElementData.h"
32 #include "ui/gfx/range/range.h"
34 #if defined(OS_ANDROID)
35 #include "content/renderer/media/android/renderer_media_player_manager.h"
36 #endif
38 class GURL;
39 class TransportDIB;
40 struct FrameHostMsg_AddNavigationTransitionData_Params;
41 struct FrameMsg_Navigate_Params;
42 struct FrameMsg_RequestNavigation_Params;
44 namespace blink {
45 class WebGeolocationClient;
46 class WebMouseEvent;
47 class WebContentDecryptionModule;
48 class WebMediaPlayer;
49 class WebPushClient;
50 class WebSecurityOrigin;
51 struct WebCompositionUnderline;
52 struct WebContextMenuData;
53 struct WebCursorInfo;
54 struct WebTransitionElementData;
57 namespace gfx {
58 class Point;
59 class Range;
60 class Rect;
63 namespace content {
65 class ChildFrameCompositingHelper;
66 class ExternalPopupMenu;
67 class GeolocationDispatcher;
68 class ManifestManager;
69 class MediaStreamDispatcher;
70 class MediaStreamRendererFactory;
71 class MidiDispatcher;
72 class NotificationPermissionDispatcher;
73 class PageState;
74 class PepperPluginInstanceImpl;
75 class PluginPowerSaverHelper;
76 class PushMessagingDispatcher;
77 class RendererAccessibility;
78 class RendererCdmManager;
79 class RendererMediaPlayerManager;
80 class RendererPpapiHost;
81 class RenderFrameObserver;
82 class RenderViewImpl;
83 class RenderWidget;
84 class RenderWidgetFullscreenPepper;
85 class ScreenOrientationDispatcher;
86 class UserMediaClientImpl;
87 struct CommitNavigationParams;
88 struct CommonNavigationParams;
89 struct CustomContextMenuContext;
90 struct RequestNavigationParams;
91 struct ResourceResponseHead;
93 class CONTENT_EXPORT RenderFrameImpl
94 : public RenderFrame,
95 NON_EXPORTED_BASE(public blink::WebFrameClient),
96 NON_EXPORTED_BASE(public media::WebMediaPlayerDelegate) {
97 public:
98 // Creates a new RenderFrame. |render_view| is the RenderView object that this
99 // frame belongs to.
100 // Callers *must* call |SetWebFrame| immediately after creation.
101 // Note: This is called only when RenderFrame is created by Blink through
102 // createChildFrame.
103 // TODO(creis): We should structure this so that |SetWebFrame| isn't needed.
104 static RenderFrameImpl* Create(RenderViewImpl* render_view, int32 routing_id);
106 // Creates a new RenderFrame with |routing_id| as a child of the RenderFrame
107 // identified by |parent_routing_id| or as the top-level frame if the latter
108 // is MSG_ROUTING_NONE. If |proxy_routing_id| is MSG_ROUTING_NONE, it creates
109 // the Blink WebLocalFrame and inserts it in the proper place in the frame
110 // tree. Otherwise, the frame is semi-orphaned until it commits, at which
111 // point it replaces the proxy identified by |proxy_routing_id|.
112 // Note: This is called only when RenderFrame is being created in response to
113 // IPC message from the browser process. All other frame creation is driven
114 // through Blink and Create.
115 static void CreateFrame(int routing_id,
116 int parent_routing_id,
117 int proxy_routing_id);
119 // Returns the RenderFrameImpl for the given routing ID.
120 static RenderFrameImpl* FromRoutingID(int routing_id);
122 // Just like RenderFrame::FromWebFrame but returns the implementation.
123 static RenderFrameImpl* FromWebFrame(blink::WebFrame* web_frame);
125 // Used by content_layouttest_support to hook into the creation of
126 // RenderFrameImpls.
127 static void InstallCreateHook(
128 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32));
130 virtual ~RenderFrameImpl();
132 bool is_swapped_out() const {
133 return is_swapped_out_;
136 // TODO(nasko): This can be removed once we don't have a swapped out state on
137 // RenderFrames. See https://crbug.com/357747.
138 void set_render_frame_proxy(RenderFrameProxy* proxy) {
139 render_frame_proxy_ = proxy;
142 // Out-of-process child frames receive a signal from RenderWidgetCompositor
143 // when a compositor frame has committed.
144 void DidCommitCompositorFrame();
146 // TODO(jam): this is a temporary getter until all the code is transitioned
147 // to using RenderFrame instead of RenderView.
148 RenderViewImpl* render_view() { return render_view_.get(); }
150 RendererWebCookieJarImpl* cookie_jar() { return &cookie_jar_; }
152 // Returns the RenderWidget associated with this frame.
153 RenderWidget* GetRenderWidget();
155 // This is called right after creation with the WebLocalFrame for this
156 // RenderFrame. It must be called before Initialize.
157 void SetWebFrame(blink::WebLocalFrame* web_frame);
159 // This method must be called after the frame has been added to the frame
160 // tree. It creates all objects that depend on the frame being at its proper
161 // spot.
162 void Initialize();
164 // Notifications from RenderWidget.
165 void WasHidden();
166 void WasShown();
168 // Start/Stop loading notifications.
169 // TODO(nasko): Those are page-level methods at this time and come from
170 // WebViewClient. We should move them to be WebFrameClient calls and put
171 // logic in the browser side to balance starts/stops.
172 // |to_different_document| will be true unless the load is a fragment
173 // navigation, or triggered by history.pushState/replaceState.
174 virtual void didStartLoading(bool to_different_document);
175 virtual void didStopLoading();
176 virtual void didChangeLoadProgress(double load_progress);
178 AccessibilityMode accessibility_mode() {
179 return accessibility_mode_;
182 RendererAccessibility* renderer_accessibility() {
183 return renderer_accessibility_;
186 void HandleWebAccessibilityEvent(const blink::WebAXObject& obj,
187 blink::WebAXEvent event);
189 // TODO(dmazzoni): the only reason this is here is to plumb it through to
190 // RendererAccessibility. It should be part of RenderFrameObserver, once
191 // blink has a separate accessibility tree per frame.
192 void FocusedNodeChanged(const blink::WebNode& node);
194 #if defined(ENABLE_PLUGINS)
195 // Notification that a PPAPI plugin has been created.
196 void PepperPluginCreated(RendererPpapiHost* host);
198 // Notifies that |instance| has changed the cursor.
199 // This will update the cursor appearance if it is currently over the plugin
200 // instance.
201 void PepperDidChangeCursor(PepperPluginInstanceImpl* instance,
202 const blink::WebCursorInfo& cursor);
204 // Notifies that |instance| has received a mouse event.
205 void PepperDidReceiveMouseEvent(PepperPluginInstanceImpl* instance);
207 // Informs the render view that a PPAPI plugin has changed text input status.
208 void PepperTextInputTypeChanged(PepperPluginInstanceImpl* instance);
209 void PepperCaretPositionChanged(PepperPluginInstanceImpl* instance);
211 // Cancels current composition.
212 void PepperCancelComposition(PepperPluginInstanceImpl* instance);
214 // Informs the render view that a PPAPI plugin has changed selection.
215 void PepperSelectionChanged(PepperPluginInstanceImpl* instance);
217 // Creates a fullscreen container for a pepper plugin instance.
218 RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
219 PepperPluginInstanceImpl* plugin);
221 bool IsPepperAcceptingCompositionEvents() const;
223 // Notification that the given plugin has crashed.
224 void PluginCrashed(const base::FilePath& plugin_path,
225 base::ProcessId plugin_pid);
227 // Simulates IME events for testing purpose.
228 void SimulateImeSetComposition(
229 const base::string16& text,
230 const std::vector<blink::WebCompositionUnderline>& underlines,
231 int selection_start,
232 int selection_end);
233 void SimulateImeConfirmComposition(const base::string16& text,
234 const gfx::Range& replacement_range);
236 // TODO(jam): remove these once the IPC handler moves from RenderView to
237 // RenderFrame.
238 void OnImeSetComposition(
239 const base::string16& text,
240 const std::vector<blink::WebCompositionUnderline>& underlines,
241 int selection_start,
242 int selection_end);
243 void OnImeConfirmComposition(const base::string16& text,
244 const gfx::Range& replacement_range,
245 bool keep_selection);
247 PluginPowerSaverHelper* plugin_power_saver_helper();
248 #endif // defined(ENABLE_PLUGINS)
250 // May return NULL in some cases, especially if userMediaClient() returns
251 // NULL.
252 MediaStreamDispatcher* GetMediaStreamDispatcher();
254 #if defined(OS_MACOSX) || defined(OS_ANDROID)
255 void DidHideExternalPopupMenu();
256 #endif
258 // IPC::Sender
259 bool Send(IPC::Message* msg) override;
261 // IPC::Listener
262 bool OnMessageReceived(const IPC::Message& msg) override;
264 // RenderFrame implementation:
265 RenderView* GetRenderView() override;
266 int GetRoutingID() override;
267 blink::WebLocalFrame* GetWebFrame() override;
268 WebPreferences& GetWebkitPreferences() override;
269 int ShowContextMenu(ContextMenuClient* client,
270 const ContextMenuParams& params) override;
271 void CancelContextMenu(int request_id) override;
272 blink::WebNode GetContextMenuNode() const override;
273 blink::WebPlugin* CreatePlugin(blink::WebFrame* frame,
274 const WebPluginInfo& info,
275 const blink::WebPluginParams& params,
276 CreatePluginGesture gesture) override;
277 void LoadURLExternally(blink::WebLocalFrame* frame,
278 const blink::WebURLRequest& request,
279 blink::WebNavigationPolicy policy) override;
280 void ExecuteJavaScript(const base::string16& javascript) override;
281 bool IsHidden() override;
282 ServiceRegistry* GetServiceRegistry() override;
283 bool IsFTPDirectoryListing() override;
284 void AttachGuest(int element_instance_id) override;
285 void SetSelectedText(const base::string16& selection_text,
286 size_t offset,
287 const gfx::Range& range) override;
288 void EnsureMojoBuiltinsAreAvailable(v8::Isolate* isolate,
289 v8::Handle<v8::Context> context) override;
291 // blink::WebFrameClient implementation:
292 blink::WebPluginPlaceholder* createPluginPlaceholder(
293 blink::WebLocalFrame*,
294 const blink::WebPluginParams&) override;
295 virtual blink::WebPlugin* createPlugin(blink::WebLocalFrame* frame,
296 const blink::WebPluginParams& params);
297 // TODO(jrummell): Remove this method once blink updated.
298 virtual blink::WebMediaPlayer* createMediaPlayer(
299 blink::WebLocalFrame* frame,
300 const blink::WebURL& url,
301 blink::WebMediaPlayerClient* client);
302 virtual blink::WebMediaPlayer* createMediaPlayer(
303 blink::WebLocalFrame* frame,
304 const blink::WebURL& url,
305 blink::WebMediaPlayerClient* client,
306 blink::WebContentDecryptionModule* initial_cdm);
307 virtual blink::WebContentDecryptionModule* createContentDecryptionModule(
308 blink::WebLocalFrame* frame,
309 const blink::WebSecurityOrigin& security_origin,
310 const blink::WebString& key_system);
311 virtual blink::WebApplicationCacheHost* createApplicationCacheHost(
312 blink::WebLocalFrame* frame,
313 blink::WebApplicationCacheHostClient* client);
314 virtual blink::WebWorkerPermissionClientProxy*
315 createWorkerPermissionClientProxy(blink::WebLocalFrame* frame);
316 virtual blink::WebExternalPopupMenu* createExternalPopupMenu(
317 const blink::WebPopupMenuInfo& popup_menu_info,
318 blink::WebExternalPopupMenuClient* popup_menu_client);
319 virtual blink::WebCookieJar* cookieJar(blink::WebLocalFrame* frame);
320 virtual blink::WebServiceWorkerProvider* createServiceWorkerProvider(
321 blink::WebLocalFrame* frame);
322 virtual void didAccessInitialDocument(blink::WebLocalFrame* frame);
323 virtual blink::WebFrame* createChildFrame(blink::WebLocalFrame* parent,
324 const blink::WebString& name);
325 virtual void didDisownOpener(blink::WebLocalFrame* frame);
326 virtual void frameDetached(blink::WebFrame* frame);
327 virtual void frameFocused();
328 virtual void willClose(blink::WebFrame* frame);
329 virtual void didChangeName(blink::WebLocalFrame* frame,
330 const blink::WebString& name);
331 virtual void didMatchCSS(
332 blink::WebLocalFrame* frame,
333 const blink::WebVector<blink::WebString>& newly_matching_selectors,
334 const blink::WebVector<blink::WebString>& stopped_matching_selectors);
335 virtual bool shouldReportDetailedMessageForSource(
336 const blink::WebString& source);
337 virtual void didAddMessageToConsole(const blink::WebConsoleMessage& message,
338 const blink::WebString& source_name,
339 unsigned source_line,
340 const blink::WebString& stack_trace);
341 virtual void loadURLExternally(blink::WebLocalFrame* frame,
342 const blink::WebURLRequest& request,
343 blink::WebNavigationPolicy policy,
344 const blink::WebString& suggested_name);
345 // The WebDataSource::ExtraData* is assumed to be a DocumentState* subclass.
346 virtual blink::WebNavigationPolicy decidePolicyForNavigation(
347 const NavigationPolicyInfo& info);
348 virtual blink::WebHistoryItem historyItemForNewChildFrame(
349 blink::WebFrame* frame);
350 virtual void willSendSubmitEvent(blink::WebLocalFrame* frame,
351 const blink::WebFormElement& form);
352 virtual void willSubmitForm(blink::WebLocalFrame* frame,
353 const blink::WebFormElement& form);
354 virtual void didCreateDataSource(blink::WebLocalFrame* frame,
355 blink::WebDataSource* datasource);
356 virtual void didStartProvisionalLoad(blink::WebLocalFrame* frame,
357 bool is_transition_navigation);
358 virtual void didReceiveServerRedirectForProvisionalLoad(
359 blink::WebLocalFrame* frame);
360 virtual void didFailProvisionalLoad(
361 blink::WebLocalFrame* frame,
362 const blink::WebURLError& error);
363 virtual void didCommitProvisionalLoad(
364 blink::WebLocalFrame* frame,
365 const blink::WebHistoryItem& item,
366 blink::WebHistoryCommitType commit_type);
367 virtual void didCreateNewDocument(blink::WebLocalFrame* frame);
368 virtual void didClearWindowObject(blink::WebLocalFrame* frame);
369 virtual void didCreateDocumentElement(blink::WebLocalFrame* frame);
370 virtual void didReceiveTitle(blink::WebLocalFrame* frame,
371 const blink::WebString& title,
372 blink::WebTextDirection direction);
373 virtual void didChangeIcon(blink::WebLocalFrame* frame,
374 blink::WebIconURL::Type icon_type);
375 virtual void didFinishDocumentLoad(blink::WebLocalFrame* frame);
376 virtual void didHandleOnloadEvents(blink::WebLocalFrame* frame);
377 virtual void didFailLoad(blink::WebLocalFrame* frame,
378 const blink::WebURLError& error);
379 virtual void didFinishLoad(blink::WebLocalFrame* frame);
380 virtual void didNavigateWithinPage(blink::WebLocalFrame* frame,
381 const blink::WebHistoryItem& item,
382 blink::WebHistoryCommitType commit_type);
383 virtual void didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame);
384 virtual void addNavigationTransitionData(
385 const blink::WebTransitionElementData& data);
386 virtual void didChangeThemeColor();
387 virtual void requestNotificationPermission(
388 const blink::WebSecurityOrigin& origin,
389 blink::WebNotificationPermissionCallback* callback);
390 virtual void didChangeSelection(bool is_empty_selection);
391 virtual blink::WebColorChooser* createColorChooser(
392 blink::WebColorChooserClient* client,
393 const blink::WebColor& initial_color,
394 const blink::WebVector<blink::WebColorSuggestion>& suggestions);
395 virtual void runModalAlertDialog(const blink::WebString& message);
396 virtual bool runModalConfirmDialog(const blink::WebString& message);
397 virtual bool runModalPromptDialog(const blink::WebString& message,
398 const blink::WebString& default_value,
399 blink::WebString* actual_value);
400 virtual bool runModalBeforeUnloadDialog(bool is_reload,
401 const blink::WebString& message);
402 virtual void showContextMenu(const blink::WebContextMenuData& data);
403 virtual void clearContextMenu();
404 virtual void willSendRequest(blink::WebLocalFrame* frame,
405 unsigned identifier,
406 blink::WebURLRequest& request,
407 const blink::WebURLResponse& redirect_response);
408 virtual void didReceiveResponse(blink::WebLocalFrame* frame,
409 unsigned identifier,
410 const blink::WebURLResponse& response);
411 virtual void didFinishResourceLoad(blink::WebLocalFrame* frame,
412 unsigned identifier);
413 virtual void didLoadResourceFromMemoryCache(
414 blink::WebLocalFrame* frame,
415 const blink::WebURLRequest& request,
416 const blink::WebURLResponse& response);
417 virtual void didDisplayInsecureContent(blink::WebLocalFrame* frame);
418 virtual void didRunInsecureContent(blink::WebLocalFrame* frame,
419 const blink::WebSecurityOrigin& origin,
420 const blink::WebURL& target);
421 virtual void didAbortLoading(blink::WebLocalFrame* frame);
422 virtual void didCreateScriptContext(blink::WebLocalFrame* frame,
423 v8::Handle<v8::Context> context,
424 int extension_group,
425 int world_id);
426 virtual void willReleaseScriptContext(blink::WebLocalFrame* frame,
427 v8::Handle<v8::Context> context,
428 int world_id);
429 virtual void didFirstVisuallyNonEmptyLayout(blink::WebLocalFrame* frame);
430 virtual void didChangeScrollOffset(blink::WebLocalFrame* frame);
431 virtual void willInsertBody(blink::WebLocalFrame* frame);
432 virtual void reportFindInPageMatchCount(int request_id,
433 int count,
434 bool final_update);
435 virtual void reportFindInPageSelection(int request_id,
436 int active_match_ordinal,
437 const blink::WebRect& sel);
438 virtual void requestStorageQuota(blink::WebLocalFrame* frame,
439 blink::WebStorageQuotaType type,
440 unsigned long long requested_size,
441 blink::WebStorageQuotaCallbacks callbacks);
442 virtual void willOpenWebSocket(blink::WebSocketHandle* handle);
443 virtual blink::WebGeolocationClient* geolocationClient();
444 virtual blink::WebPushClient* pushClient();
445 virtual void willStartUsingPeerConnectionHandler(
446 blink::WebLocalFrame* frame,
447 blink::WebRTCPeerConnectionHandler* handler);
448 virtual blink::WebUserMediaClient* userMediaClient();
449 virtual blink::WebMIDIClient* webMIDIClient();
450 virtual bool willCheckAndDispatchMessageEvent(
451 blink::WebLocalFrame* source_frame,
452 blink::WebFrame* target_frame,
453 blink::WebSecurityOrigin target_origin,
454 blink::WebDOMMessageEvent event);
455 virtual blink::WebString userAgentOverride(blink::WebLocalFrame* frame,
456 const blink::WebURL& url);
457 virtual blink::WebString doNotTrackValue(blink::WebLocalFrame* frame);
458 virtual bool allowWebGL(blink::WebLocalFrame* frame, bool default_value);
459 virtual void didLoseWebGLContext(blink::WebLocalFrame* frame,
460 int arb_robustness_status_code);
461 virtual blink::WebScreenOrientationClient* webScreenOrientationClient();
462 virtual bool isControlledByServiceWorker(blink::WebDataSource& data_source);
463 virtual int64_t serviceWorkerID(blink::WebDataSource& data_source);
464 virtual void postAccessibilityEvent(const blink::WebAXObject& obj,
465 blink::WebAXEvent event);
466 virtual void handleAccessibilityFindInPageResult(
467 int identifier,
468 int match_index,
469 const blink::WebAXObject& start_object,
470 int start_offset,
471 const blink::WebAXObject& end_object,
472 int end_offset);
473 virtual void didChangeManifest(blink::WebLocalFrame*);
475 // WebMediaPlayerDelegate implementation:
476 void DidPlay(blink::WebMediaPlayer* player) override;
477 void DidPause(blink::WebMediaPlayer* player) override;
478 void PlayerGone(blink::WebMediaPlayer* player) override;
480 // TODO(nasko): Make all tests in RenderViewImplTest friends and then move
481 // this back to private member.
482 void OnNavigate(const FrameMsg_Navigate_Params& params);
484 // Make this frame show an empty, unscriptable page.
485 // TODO(nasko): Remove this method once swapped out state is no longer used.
486 void NavigateToSwappedOutURL();
488 // Binds this render frame's service registry to a handle to the remote
489 // service registry.
490 void BindServiceRegistry(
491 mojo::ScopedMessagePipeHandle service_provider_handle);
493 ManifestManager* manifest_manager();
495 protected:
496 RenderFrameImpl(RenderViewImpl* render_view, int32 routing_id);
498 private:
499 friend class RenderFrameObserver;
500 friend class RendererAccessibilityTest;
501 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuDisplayNoneTest, SelectItem);
502 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuRemoveTest, RemoveOnChange);
503 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, NormalCase);
504 FRIEND_TEST_ALL_PREFIXES(ExternalPopupMenuTest, ShowPopupThenNavigate);
505 FRIEND_TEST_ALL_PREFIXES(RendererAccessibilityTest,
506 AccessibilityMessagesQueueWhileSwappedOut);
507 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
508 OnExtendSelectionAndDelete);
509 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, ReloadWhileSwappedOut);
510 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest, SendSwapOutACK);
511 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
512 SetEditableSelectionAndComposition);
513 FRIEND_TEST_ALL_PREFIXES(RenderViewImplTest,
514 OnSetAccessibilityMode);
516 typedef std::map<GURL, double> HostZoomLevels;
518 // Functions to add and remove observers for this object.
519 void AddObserver(RenderFrameObserver* observer);
520 void RemoveObserver(RenderFrameObserver* observer);
522 // Builds and sends DidCommitProvisionalLoad to the host.
523 void SendDidCommitProvisionalLoad(blink::WebFrame* frame);
525 // Gets the focused element. If no such element exists then the element will
526 // be NULL.
527 blink::WebElement GetFocusedElement();
529 // IPC message handlers ------------------------------------------------------
531 // The documentation for these functions should be in
532 // content/common/*_messages.h for the message that the function is handling.
533 void OnBeforeUnload();
534 void OnSwapOut(int proxy_routing_id);
535 void OnStop();
536 void OnShowContextMenu(const gfx::Point& location);
537 void OnContextMenuClosed(const CustomContextMenuContext& custom_context);
538 void OnCustomContextMenuAction(const CustomContextMenuContext& custom_context,
539 unsigned action);
540 void OnUndo();
541 void OnRedo();
542 void OnCut();
543 void OnCopy();
544 void OnPaste();
545 void OnPasteAndMatchStyle();
546 void OnDelete();
547 void OnSelectAll();
548 void OnSelectRange(const gfx::Point& base, const gfx::Point& extent);
549 void OnUnselect();
550 void OnMoveRangeSelectionExtent(const gfx::Point& point);
551 void OnReplace(const base::string16& text);
552 void OnReplaceMisspelling(const base::string16& text);
553 void OnCSSInsertRequest(const std::string& css);
554 void OnJavaScriptExecuteRequest(const base::string16& javascript,
555 int id,
556 bool notify_result);
557 void OnJavaScriptExecuteRequestForTests(const base::string16& javascript,
558 int id,
559 bool notify_result);
560 void OnSetEditableSelectionOffsets(int start, int end);
561 void OnSetCompositionFromExistingText(
562 int start, int end,
563 const std::vector<blink::WebCompositionUnderline>& underlines);
564 void OnExtendSelectionAndDelete(int before, int after);
565 void OnReload(bool ignore_cache);
566 void OnTextSurroundingSelectionRequest(size_t max_length);
567 void OnAddStyleSheetByURL(const std::string& url);
568 void OnSetupTransitionView(const std::string& markup);
569 void OnBeginExitTransition(const std::string& css_selector,
570 bool exit_to_native_app);
571 void OnHideTransitionElements(const std::string& css_selector);
572 void OnShowTransitionElements(const std::string& css_selector);
573 void OnSetAccessibilityMode(AccessibilityMode new_mode);
574 void OnDisownOpener();
575 #if defined(OS_ANDROID)
576 void OnSelectPopupMenuItems(bool canceled,
577 const std::vector<int>& selected_indices);
578 #elif defined(OS_MACOSX)
579 void OnSelectPopupMenuItem(int selected_index);
580 void OnCopyToFindPboard();
581 #endif
583 // PlzNavigate
584 void OnRequestNavigation(const CommonNavigationParams& common_params,
585 const RequestNavigationParams& request_params);
586 void OnCommitNavigation(const ResourceResponseHead& response,
587 const GURL& stream_url,
588 const CommonNavigationParams& common_params,
589 const CommitNavigationParams& commit_params);
591 // Virtual since overridden by WebTestProxy for layout tests.
592 virtual blink::WebNavigationPolicy DecidePolicyForNavigation(
593 RenderFrame* render_frame,
594 const NavigationPolicyInfo& info);
595 void OpenURL(blink::WebFrame* frame,
596 const GURL& url,
597 const Referrer& referrer,
598 blink::WebNavigationPolicy policy);
600 // Update current main frame's encoding and send it to browser window.
601 // Since we want to let users see the right encoding info from menu
602 // before finishing loading, we call the UpdateEncoding in
603 // a) function:DidCommitLoadForFrame. When this function is called,
604 // that means we have got first data. In here we try to get encoding
605 // of page if it has been specified in http header.
606 // b) function:DidReceiveTitle. When this function is called,
607 // that means we have got specified title. Because in most of webpages,
608 // title tags will follow meta tags. In here we try to get encoding of
609 // page if it has been specified in meta tag.
610 // c) function:DidFinishDocumentLoadForFrame. When this function is
611 // called, that means we have got whole html page. In here we should
612 // finally get right encoding of page.
613 void UpdateEncoding(blink::WebFrame* frame,
614 const std::string& encoding_name);
616 // Dispatches the current state of selection on the webpage to the browser if
617 // it has changed.
618 // TODO(varunjain): delete this method once we figure out how to keep
619 // selection handles in sync with the webpage.
620 void SyncSelectionIfRequired();
622 bool RunJavaScriptMessage(JavaScriptMessageType type,
623 const base::string16& message,
624 const base::string16& default_value,
625 const GURL& frame_url,
626 base::string16* result);
628 // Loads the appropriate error page for the specified failure into the frame.
629 void LoadNavigationErrorPage(const blink::WebURLRequest& failed_request,
630 const blink::WebURLError& error,
631 bool replace);
633 void HandleJavascriptExecutionResult(const base::string16& javascript,
634 int id,
635 bool notify_result,
636 v8::Handle<v8::Value> result);
638 // Initializes |web_user_media_client_|. If this fails, because it wasn't
639 // possible to create a MediaStreamClient (e.g., WebRTC is disabled), then
640 // |web_user_media_client_| will remain NULL.
641 void InitializeUserMediaClient();
643 blink::WebMediaPlayer* CreateWebMediaPlayerForMediaStream(
644 const blink::WebURL& url,
645 blink::WebMediaPlayerClient* client);
647 // Creates a factory object used for creating audio and video renderers.
648 // The method is virtual so that layouttests can override it.
649 virtual scoped_ptr<MediaStreamRendererFactory> CreateRendererFactory();
651 // Checks that the RenderView is ready to display the navigation to |url|. If
652 // the return value is false, the navigation should be abandonned.
653 bool PrepareRenderViewForNavigation(
654 const GURL& url,
655 FrameMsg_Navigate_Type::Value navigate_type,
656 const PageState& state,
657 bool check_history,
658 int pending_history_list_offset,
659 int32 page_id,
660 bool* is_reload,
661 blink::WebURLRequest::CachePolicy* cache_policy);
663 // PlzNavigate
664 // Sends a FrameHostMsg_BeginNavigation to the browser based on the contents
665 // of the WebURLRequest.
666 void BeginNavigation(blink::WebURLRequest* request);
668 // Returns the URL being loaded by the |frame_|'s request.
669 GURL GetLoadingUrl() const;
671 #if defined(OS_ANDROID)
672 blink::WebMediaPlayer* CreateAndroidWebMediaPlayer(
673 const blink::WebURL& url,
674 blink::WebMediaPlayerClient* client,
675 blink::WebContentDecryptionModule* initial_cdm);
677 RendererMediaPlayerManager* GetMediaPlayerManager();
678 #endif
680 #if defined(ENABLE_BROWSER_CDMS)
681 RendererCdmManager* GetCdmManager();
682 #endif
684 // Stores the WebLocalFrame we are associated with.
685 blink::WebLocalFrame* frame_;
687 base::WeakPtr<RenderViewImpl> render_view_;
688 int routing_id_;
689 bool is_swapped_out_;
690 // RenderFrameProxy exists only when is_swapped_out_ is true.
691 // TODO(nasko): This can be removed once we don't have a swapped out state on
692 // RenderFrame. See https://crbug.com/357747.
693 RenderFrameProxy* render_frame_proxy_;
694 bool is_detaching_;
696 // If this frame was created to replace a proxy, this will store the routing
697 // id of the proxy to replace at commit-time, at which time it will be
698 // cleared.
699 // TODO(creis): Remove this after switching to PlzNavigate.
700 int proxy_routing_id_;
702 #if defined(ENABLE_PLUGINS)
703 // Current text input composition text. Empty if no composition is in
704 // progress.
705 base::string16 pepper_composition_text_;
707 PluginPowerSaverHelper* plugin_power_saver_helper_;
708 #endif
710 RendererWebCookieJarImpl cookie_jar_;
712 // All the registered observers.
713 ObserverList<RenderFrameObserver> observers_;
715 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_;
717 // The node that the context menu was pressed over.
718 blink::WebNode context_menu_node_;
720 // External context menu requests we're waiting for. "Internal"
721 // (WebKit-originated) context menu events will have an ID of 0 and will not
722 // be in this map.
724 // We don't want to add internal ones since some of the "special" page
725 // handlers in the browser process just ignore the context menu requests so
726 // avoid showing context menus, and so this will cause right clicks to leak
727 // entries in this map. Most users of the custom context menu (e.g. Pepper
728 // plugins) are normally only on "regular" pages and the regular pages will
729 // always respond properly to the request, so we don't have to worry so
730 // much about leaks.
731 IDMap<ContextMenuClient, IDMapExternalPointer> pending_context_menus_;
733 // The text selection the last time DidChangeSelection got called. May contain
734 // additional characters before and after the selected text, for IMEs. The
735 // portion of this string that is the actual selected text starts at index
736 // |selection_range_.GetMin() - selection_text_offset_| and has length
737 // |selection_range_.length()|.
738 base::string16 selection_text_;
739 // The offset corresponding to the start of |selection_text_| in the document.
740 size_t selection_text_offset_;
741 // Range over the document corresponding to the actual selected text (which
742 // could correspond to a substring of |selection_text_|; see above).
743 gfx::Range selection_range_;
744 // Used to inform didChangeSelection() when it is called in the context
745 // of handling a InputMsg_SelectRange IPC.
746 bool handling_select_range_;
748 // The next group of objects all implement RenderFrameObserver, so are deleted
749 // along with the RenderFrame automatically. This is why we just store weak
750 // references.
752 // Dispatches permission requests for Web Notifications.
753 NotificationPermissionDispatcher* notification_permission_dispatcher_;
755 // Destroyed via the RenderFrameObserver::OnDestruct() mechanism.
756 UserMediaClientImpl* web_user_media_client_;
758 // MidiClient attached to this frame; lazily initialized.
759 MidiDispatcher* midi_dispatcher_;
761 #if defined(OS_ANDROID)
762 // Manages all media players in this render frame for communicating with the
763 // real media player in the browser process. It's okay to use a raw pointer
764 // since it's a RenderFrameObserver.
765 RendererMediaPlayerManager* media_player_manager_;
766 #endif
768 #if defined(ENABLE_BROWSER_CDMS)
769 // Manage all CDMs in this render frame for communicating with the real CDM in
770 // the browser process. It's okay to use a raw pointer since it's a
771 // RenderFrameObserver.
772 RendererCdmManager* cdm_manager_;
773 #endif
775 #if defined(VIDEO_HOLE)
776 // Whether or not this RenderFrameImpl contains a media player. Used to
777 // register as an observer for video-hole-specific events.
778 bool contains_media_player_;
779 #endif
781 // The geolocation dispatcher attached to this frame, lazily initialized.
782 GeolocationDispatcher* geolocation_dispatcher_;
784 // The push messaging dispatcher attached to this frame, lazily initialized.
785 PushMessagingDispatcher* push_messaging_dispatcher_;
787 ServiceRegistryImpl service_registry_;
789 // The screen orientation dispatcher attached to the frame, lazily
790 // initialized.
791 ScreenOrientationDispatcher* screen_orientation_dispatcher_;
793 // The Manifest Manager handles the manifest requests from the browser
794 // process.
795 ManifestManager* manifest_manager_;
797 // The current accessibility mode.
798 AccessibilityMode accessibility_mode_;
800 // Only valid if |accessibility_mode_| is anything other than
801 // AccessibilityModeOff.
802 RendererAccessibility* renderer_accessibility_;
804 #if defined(OS_MACOSX) || defined(OS_ANDROID)
805 // The external popup for the currently showing select popup.
806 scoped_ptr<ExternalPopupMenu> external_popup_menu_;
807 #endif
809 base::WeakPtrFactory<RenderFrameImpl> weak_factory_;
811 DISALLOW_COPY_AND_ASSIGN(RenderFrameImpl);
814 } // namespace content
816 #endif // CONTENT_RENDERER_RENDER_FRAME_IMPL_H_