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