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