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