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