render_frame.h revision 116680a4aac90f2aa7413d9095a592090648e557
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
14namespace blink {
15class WebFrame;
16class WebLocalFrame;
17class WebNode;
18class WebPlugin;
19class WebURLRequest;
20struct WebPluginParams;
21}
22
23namespace content {
24class ContextMenuClient;
25class RenderView;
26class ServiceRegistry;
27struct ContextMenuParams;
28struct WebPluginInfo;
29struct WebPreferences;
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.
34class 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  // Returns the ServiceRegistry for this frame.
92  virtual ServiceRegistry* GetServiceRegistry() = 0;
93
94 protected:
95  virtual ~RenderFrame() {}
96
97 private:
98  // This interface should only be implemented inside content.
99  friend class RenderFrameImpl;
100  RenderFrame() {}
101};
102
103}  // namespace content
104
105#endif  // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_
106