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