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.
5 #ifndef CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_
6 #define CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_
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"
14 struct WebPreferences
;
22 struct WebPluginParams
;
26 class ContextMenuClient
;
28 struct ContextMenuParams
;
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
,
37 // Returns the RenderFrame given a WebFrame.
38 static RenderFrame
* FromWebFrame(blink::WebFrame
* web_frame
);
40 // Returns the RenderView associated with this frame.
41 virtual RenderView
* GetRenderView() = 0;
43 // Get the routing ID of the frame.
44 virtual int GetRoutingID() = 0;
46 // Returns the associated WebFrame.
47 virtual blink::WebFrame
* GetWebFrame() = 0;
49 // Gets WebKit related preferences associated with this frame.
50 virtual WebPreferences
& GetWebkitPreferences() = 0;
52 // Shows a context menu with the given information. The given client will
53 // be called with the result.
55 // The request ID will be returned by this function. This is passed to the
56 // client functions for identification.
58 // If the client is destroyed, CancelContextMenu() should be called with the
59 // request ID returned by this function.
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;
66 // Cancels a context menu in the event that the client is destroyed before the
68 virtual void CancelContextMenu(int request_id
) = 0;
70 // Gets the node that the context menu was pressed over.
71 virtual blink::WebNode
GetContextMenuNode() const = 0;
73 // Create a new NPAPI/Pepper plugin depending on |info|. Returns NULL if no
75 virtual blink::WebPlugin
* CreatePlugin(
76 blink::WebFrame
* frame
,
77 const WebPluginInfo
& info
,
78 const blink::WebPluginParams
& params
) = 0;
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;
85 // Execute a string of JavaScript in this frame's context.
86 virtual void ExecuteJavaScript(const base::string16
& javascript
) = 0;
89 virtual ~RenderFrame() {}
92 // This interface should only be implemented inside content.
93 friend class RenderFrameImpl
;
97 } // namespace content
99 #endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_