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_PUBLIC_RENDERER_RENDER_FRAME_H_
      6 #define CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_
      7 
      8 #include "content/common/content_export.h"
      9 #include "ipc/ipc_listener.h"
     10 #include "ipc/ipc_sender.h"
     11 #include "third_party/WebKit/public/web/WebNavigationPolicy.h"
     12 
     13 struct WebPreferences;
     14 
     15 namespace blink {
     16 class WebFrame;
     17 class WebPlugin;
     18 class WebURLRequest;
     19 struct WebPluginParams;
     20 }
     21 
     22 namespace content {
     23 class ContextMenuClient;
     24 class RenderView;
     25 struct ContextMenuParams;
     26 struct WebPluginInfo;
     27 
     28 // This interface wraps functionality, which is specific to frames, such as
     29 // navigation. It provides communication with a corresponding RenderFrameHost
     30 // in the browser process.
     31 class CONTENT_EXPORT RenderFrame : public IPC::Listener,
     32                                    public IPC::Sender {
     33  public:
     34   // Returns the RenderView associated with this frame.
     35   virtual RenderView* GetRenderView() = 0;
     36 
     37   // Get the routing ID of the frame.
     38   virtual int GetRoutingID() = 0;
     39 
     40    // Gets WebKit related preferences associated with this frame.
     41   virtual WebPreferences& GetWebkitPreferences() = 0;
     42 
     43   // Shows a context menu with the given information. The given client will
     44   // be called with the result.
     45   //
     46   // The request ID will be returned by this function. This is passed to the
     47   // client functions for identification.
     48   //
     49   // If the client is destroyed, CancelContextMenu() should be called with the
     50   // request ID returned by this function.
     51   //
     52   // Note: if you end up having clients outliving the RenderFrame, we should add
     53   // a CancelContextMenuCallback function that takes a request id.
     54   virtual int ShowContextMenu(ContextMenuClient* client,
     55                               const ContextMenuParams& params) = 0;
     56 
     57   // Cancels a context menu in the event that the client is destroyed before the
     58   // menu is closed.
     59   virtual void CancelContextMenu(int request_id) = 0;
     60 
     61   // Create a new NPAPI/Pepper plugin depending on |info|. Returns NULL if no
     62   // plugin was found.
     63   virtual blink::WebPlugin* CreatePlugin(
     64       blink::WebFrame* frame,
     65       const WebPluginInfo& info,
     66       const blink::WebPluginParams& params) = 0;
     67 
     68   // The client should handle the navigation externally.
     69   virtual void LoadURLExternally(
     70       blink::WebFrame* frame,
     71       const blink::WebURLRequest& request,
     72       blink::WebNavigationPolicy policy) = 0;
     73 
     74  protected:
     75   virtual ~RenderFrame() {}
     76 
     77  private:
     78   // This interface should only be implemented inside content.
     79   friend class RenderFrameImpl;
     80   RenderFrame() {}
     81 };
     82 
     83 }  // namespace content
     84 
     85 #endif  // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_
     86