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